Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
nexedi
/
erp5
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Merge Requests
111
Wiki
Snippets
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 83757f4e
authored
2019-09-25 12:41:20 +0200
by
Bryton Lacquement
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Get rid of Products.CMFDefault.{File.File,Portal.CMFSite}
1 parent
669eac14
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
25 deletions
product/ERP5/Document/File.py
product/ERP5/ERP5Site.py
product/ERP5OOo/tests/testDms.py
product/ERP5Type/Base.py
product/ERP5Type/tests/testERP5Type.py
product/ERP5/Document/File.py
View file @
83757f4
...
...
@@ -27,6 +27,7 @@
#
##############################################################################
from
DateTime
import
DateTime
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type.Base
import
WorkflowMethod
from
Products.ERP5Type
import
Permissions
,
PropertySheet
...
...
@@ -34,8 +35,7 @@ from Products.ERP5.Document.Document import Document, VALID_TEXT_FORMAT_LIST
from
Products.ERP5.Document.Document
import
VALID_IMAGE_FORMAT_LIST
from
Products.ERP5.Document.Document
import
ConversionError
from
Products.ERP5Type.Base
import
Base
,
removeIContentishInterface
from
Products.CMFDefault.File
import
File
as
CMFFile
from
OFS.Image
import
Pdata
import
OFS.Image
from
cStringIO
import
StringIO
from
Products.ERP5Type.Utils
import
deprecated
...
...
@@ -48,7 +48,7 @@ def _unpackData(data):
_MARKER
=
object
()
class
File
(
Document
,
CMF
File
):
class
File
(
Document
,
OFS
.
Image
.
File
):
"""
A File can contain raw data which can be uploaded and downloaded.
It is the root class of Image, OOoDocument (ERP5OOo product),
...
...
@@ -94,6 +94,25 @@ class File(Document, CMFFile):
# OFS.File has an overloaded __str__ that returns the file content
__str__
=
object
.
__str__
def
CreationDate
():
# Required to not create a regression after dropping the Products.CMFDefault
# dependency (cf product.ERP5Type.Base.Base.getCreationDate)
pass
security
.
declarePrivate
(
'_isNotEmpty'
)
def
_isNotEmpty
(
self
,
file
):
"""from Products.CMFDefault.File"""
if
not
file
:
return
0
elif
type
(
file
)
is
str
or
hasattr
(
file
,
'filename'
):
return
1
elif
not
hasattr
(
file
,
'read'
):
return
0
file
.
seek
(
0
,
2
)
t
=
file
.
tell
()
file
.
seek
(
0
)
return
1
if
t
else
0
### Special edit method
security
.
declarePrivate
(
'_edit'
)
def
_edit
(
self
,
**
kw
):
...
...
@@ -145,7 +164,12 @@ class File(Document, CMFFile):
str
(
data
.
read
())
==
str
(
self
.
getData
()):
# Same data as previous, no need to change it's content
return
CMFFile
.
_edit
(
self
,
precondition
=
precondition
,
file
=
data
)
# from Products.CMFDefault.File
if
precondition
:
self
.
precondition
=
precondition
elif
self
.
precondition
:
del
self
.
precondition
if
self
.
_isNotEmpty
(
data
):
self
.
manage_upload
(
data
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'setFile'
)
def
setFile
(
self
,
data
,
precondition
=
None
):
...
...
@@ -193,11 +217,16 @@ class File(Document, CMFFile):
return
str
(
data
)
# DAV Support
PUT
=
CMFFile
.
PUT
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'PUT'
)
def
PUT
(
self
,
REQUEST
,
RESPONSE
):
"""from Products.CMFDefault.File"""
OFS
.
Image
.
File
.
PUT
(
self
,
REQUEST
,
RESPONSE
)
self
.
reindexObject
()
security
.
declareProtected
(
Permissions
.
FTPAccess
,
'manage_FTPstat'
,
'manage_FTPlist'
)
manage_FTPlist
=
CMF
File
.
manage_FTPlist
manage_FTPstat
=
CMF
File
.
manage_FTPstat
manage_FTPlist
=
OFS
.
Image
.
File
.
manage_FTPlist
manage_FTPstat
=
OFS
.
Image
.
File
.
manage_FTPstat
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getMimeTypeAndContent'
)
def
getMimeTypeAndContent
(
self
):
...
...
product/ERP5/ERP5Site.py
View file @
83757f4
...
...
@@ -15,6 +15,7 @@
Portal class
"""
from
DateTime
import
DateTime
from
six.moves
import
map
import
threading
from
weakref
import
ref
as
weakref
...
...
@@ -26,7 +27,7 @@ from Products.SiteErrorLog.SiteErrorLog import manage_addErrorLog
from
ZPublisher
import
BeforeTraverse
from
ZPublisher.BaseRequest
import
RequestContainer
from
AccessControl
import
ClassSecurityInfo
from
Products.CMF
Default.Portal
import
CMFSit
e
from
Products.CMF
Core.PortalObject
import
PortalObjectBas
e
from
Products.ERP5Type
import
Permissions
from
Products.ERP5Type.Core.Folder
import
FolderMixIn
from
Acquisition
import
aq_base
...
...
@@ -228,7 +229,7 @@ class _site(threading.local):
getSite
,
setSite
=
_site
()
class
ERP5Site
(
FolderMixIn
,
CMFSit
e
,
CacheCookieMixin
):
class
ERP5Site
(
FolderMixIn
,
PortalObjectBas
e
,
CacheCookieMixin
):
"""
The *only* function this class should have is to help in the setup
of a new ERP5. It should not assist in the functionality at all.
...
...
@@ -269,6 +270,15 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
security
=
ClassSecurityInfo
()
security
.
declareObjectProtected
(
Permissions
.
AccessContentsInformation
)
def
__init__
(
self
,
id
):
PortalObjectBase
.
__init__
(
self
,
id
)
self
.
creation_date
=
DateTime
()
security
.
declarePrivate
(
'reindexObject'
)
def
reindexObject
(
self
,
idxs
=
[]):
"""from Products.CMFDefault.Portal"""
pass
security
.
declarePublic
(
'isSubtreeIndexable'
)
def
isSubtreeIndexable
(
self
):
"""
...
...
@@ -400,7 +410,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
return
self
.
index_html
()
def
__of__
(
self
,
parent
):
self
=
CMFSit
e
.
__of__
(
self
,
parent
)
self
=
PortalObjectBas
e
.
__of__
(
self
,
parent
)
# Use a transactional variable for performance reason,
# since ERP5Site.__of__ is called quite often.
tv
=
getTransactionalVariable
()
...
...
@@ -470,7 +480,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
path_item_list
=
path_item_list
,
new_id
=
new_id
)
# Rename the object
return
CMFSit
e
.
manage_renameObject
(
self
,
id
=
id
,
new_id
=
new_id
,
return
PortalObjectBas
e
.
manage_renameObject
(
self
,
id
=
id
,
new_id
=
new_id
,
REQUEST
=
REQUEST
)
...
...
@@ -588,7 +598,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
# _getProperty is missing, but since there are no protected properties
# on an ERP5 Site, we can just use getProperty instead.
_getProperty
=
CMFSit
e
.
getProperty
_getProperty
=
PortalObjectBas
e
.
getProperty
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getUid'
)
def
getUid
(
self
):
...
...
@@ -702,7 +712,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
email_from_address
,
email_from_name
,
validate_email
):
CMFSit
e
.
setupDefaultProperties
(
self
,
p
,
title
,
description
,
PortalObjectBas
e
.
setupDefaultProperties
(
self
,
p
,
title
,
description
,
email_from_address
,
email_from_name
,
validate_email
)
...
...
@@ -1866,7 +1876,7 @@ factory_type_information = () # No original CMF portal_types installed by defaul
class
PortalGenerator
:
klass
=
CMFSit
e
klass
=
PortalObjectBas
e
def
setupTools
(
self
,
p
):
"""Set up initial tools"""
...
...
product/ERP5OOo/tests/testDms.py
View file @
83757f4
...
...
@@ -682,10 +682,9 @@ class TestDocument(TestDocumentMixin):
for
document_type
in
portal
.
getPortalDocumentTypeList
():
module
=
portal
.
getDefaultModule
(
document_type
)
obj
=
module
.
newContent
(
portal_type
=
document_type
)
self
.
assertNotEquals
(
obj
.
getCreationDate
(),
module
.
getCreationDate
())
self
.
assertNotEquals
(
obj
.
getCreationDate
(),
portal
.
CreationDate
())
self
.
assertIsInstance
(
portal
.
creation_date
,
DateTime
)
self
.
assertLess
(
portal
.
creation_date
,
obj
.
getCreationDate
())
self
.
assertIsNone
(
module
.
getCreationDate
())
def
test_06_ProcessingStateOfAClonedDocument
(
self
):
"""
...
...
product/ERP5Type/Base.py
View file @
83757f4
...
...
@@ -85,7 +85,6 @@ from CopySupport import CopyContainer, CopyError,\
from
Errors
import
DeferredCatalogError
,
UnsupportedWorkflowMethod
from
Products.CMFActivity.ActiveObject
import
ActiveObject
from
Products.ERP5Type.Accessor.Accessor
import
Accessor
as
Method
from
Products.ERP5Type.Accessor.TypeDefinition
import
asDate
from
Products.ERP5Type.Message
import
Message
from
Products.ERP5Type.ConsistencyMessage
import
ConsistencyMessage
from
Products.ERP5Type.UnrestrictedMethod
import
UnrestrictedMethod
,
super_user
...
...
@@ -3226,9 +3225,9 @@ class Base( CopyContainer,
if
history
)
except
ValueError
:
pass
if
getattr
(
aq_base
(
self
),
'CreationDate'
,
None
)
is
not
None
:
return
asDate
(
self
.
CreationDate
())
return
None
# JPS-XXX - try to find a way to return a creation date instead of None
# "CreationDate" is a marker used only here
if
getattr
(
aq_base
(
self
),
'CreationDate'
,
None
):
return
self
.
creation_date
.
toZone
(
DateTime
()
.
timezone
())
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getModificationDate'
)
def
getModificationDate
(
self
):
...
...
@@ -3257,7 +3256,13 @@ class Base( CopyContainer,
# Return a copy of history time, to prevent modification
return
DateTime
(
max_date
)
if
self
.
_p_serial
:
return
DateTime
(
TimeStamp
(
self
.
_p_serial
)
.
timeTime
())
return
DateTime
(
self
.
_p_mtime
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'modified'
)
def
modified
(
self
):
warnings
.
warn
(
'modified is a deprecated alias to getModificationDate.'
,
DeprecationWarning
)
return
self
.
getModificationDate
()
# Layout management
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getApplicableLayout'
)
...
...
product/ERP5Type/tests/testERP5Type.py
View file @
83757f4
...
...
@@ -38,6 +38,7 @@ import transaction
from
random
import
randint
from
unittest
import
expectedFailure
from
Acquisition
import
aq_base
from
DateTime
import
DateTime
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.utils
import
DummyLocalizer
from
zLOG
import
INFO
...
...
@@ -2570,8 +2571,9 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
portal
=
self
.
getPortalObject
()
folder
=
self
.
getOrganisationModule
()
object
=
folder
.
newContent
(
portal_type
=
'Organisation'
)
self
.
assertNotEquals
(
object
.
getCreationDate
(),
portal
.
CreationDate
())
self
.
assertNotEquals
(
object
.
getCreationDate
(),
folder
.
getCreationDate
())
self
.
assertIsInstance
(
portal
.
creation_date
,
DateTime
)
self
.
assertLess
(
portal
.
creation_date
,
object
.
getCreationDate
())
self
.
assertIsNone
(
folder
.
getCreationDate
())
def
test_copyWithoutModificationRight
(
self
):
"""
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment