Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
146
Merge Requests
146
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
bf1987e7
Commit
bf1987e7
authored
Oct 21, 2019
by
Bryton Lacquement
🚪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
20894861
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
19 deletions
+16
-19
product/ERP5/Document/File.py
product/ERP5/Document/File.py
+11
-18
product/ERP5/ERP5Site.py
product/ERP5/ERP5Site.py
+5
-1
No files found.
product/ERP5/Document/File.py
View file @
bf1987e7
...
...
@@ -99,20 +99,6 @@ class File(Document, OFS.Image.File):
# 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
):
...
...
@@ -132,8 +118,14 @@ class File(Document, OFS.Image.File):
filename
=
kw
.
get
(
'filename'
)
if
filename
:
self
.
_setFilename
(
filename
)
if
self
.
_isNotEmpty
(
file_object
):
self
.
_setFile
(
file_object
,
precondition
=
precondition
)
if
file_object
is
not
None
:
# XXX: Rather than doing nothing if empty, consider changing:
# - _update_image_info to clear metadata
# - interactions to do nothing (or else?)
file_object
.
seek
(
0
,
2
)
if
file_object
.
tell
():
file_object
.
seek
(
0
)
self
.
_setFile
(
file_object
,
precondition
=
precondition
)
Base
.
_edit
(
self
,
**
kw
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'edit'
)
...
...
@@ -162,13 +154,14 @@ class File(Document, OFS.Image.File):
def
_setFile
(
self
,
data
,
precondition
=
None
):
if
data
is
not
None
and
self
.
hasData
()
and
\
str
(
data
.
read
())
==
str
(
self
.
getData
()):
# Same data as previous, no need to change it
'
s content
# Same data as previous, no need to change its content
return
# from Products.CMFDefault.File
if
precondition
:
self
.
precondition
=
precondition
elif
self
.
precondition
:
del
self
.
precondition
if
self
.
_isNotEmpty
(
data
):
if
data
is
not
None
and
data
.
tell
():
data
.
seek
(
0
)
self
.
manage_upload
(
data
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'setFile'
)
...
...
product/ERP5/ERP5Site.py
View file @
bf1987e7
...
...
@@ -366,10 +366,14 @@ class ERP5Site(FolderMixIn, PortalObjectBase, CacheCookieMixin):
sm
.
registerUtility
(
aq_base
(
tool
),
tool_interface
)
# "Symlink" for migration purposes (drop Products.CMFDefault)
self
.
portal_properties
=
self
.
portal_actions
#
self.portal_properties = self.portal_actions
return
True
@
property
def
portal_properties
(
self
):
return
self
.
portal_actions
# backward compatibility auto-migration
def
getSiteManager
(
self
):
# NOTE: do not add a docstring! This method is private by virtue of
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment