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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
francois
erp5
Commits
e8eea5ad
Commit
e8eea5ad
authored
Jan 25, 2012
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't create subobject when provided FileUpload is empty
Follow commit
f3ee1917
parent
9e31191f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
product/ERP5Type/Accessor/ContentProperty.py
product/ERP5Type/Accessor/ContentProperty.py
+15
-3
No files found.
product/ERP5Type/Accessor/ContentProperty.py
View file @
e8eea5ad
...
...
@@ -27,6 +27,7 @@
##############################################################################
from
ZPublisher.HTTPRequest
import
FileUpload
from
Base
import
func_code
,
type_definition
,
ATTRIBUTE_PREFIX
,
Method
import
Base
from
Products.ERP5Type.PsycoWrapper
import
psyco
...
...
@@ -203,7 +204,7 @@ class Setter(Base.Setter):
self
.
_portal_type
=
portal_type
self
.
_acquired_property
=
acquired_property
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
def
__call__
(
self
,
instance
,
value
,
*
args
,
**
kw
):
# We return the first available object in the list
o
=
None
available_id
=
None
...
...
@@ -212,14 +213,25 @@ class Setter(Base.Setter):
o
=
instance
.
_getOb
(
k
,
None
)
if
o
is
None
:
available_id
=
k
if
o
is
not
None
and
o
.
portal_type
in
self
.
_portal_type
:
o
.
_setProperty
(
self
.
_acquired_property
,
*
args
,
**
kw
)
o
.
_setProperty
(
self
.
_acquired_property
,
value
,
*
args
,
**
kw
)
modified_object_list
=
(
o
,
)
if
o
is
None
and
available_id
is
not
None
:
from
Products.ERP5Type.Utils
import
assertAttributePortalType
assertAttributePortalType
(
instance
,
available_id
,
self
.
_portal_type
)
if
self
.
_acquired_property
==
'file'
:
if
isinstance
(
value
,
FileUpload
)
or
\
getattr
(
aq_base
(
value
),
'tell'
,
None
)
is
not
None
:
# When editing through the web interface, we are always provided a
# FileUpload, and when no file has been specified, the file is empty.
# In the case of empty file, we should not create the sub document.
value
.
seek
(
0
,
2
)
is_empty_file
=
not
value
.
tell
()
value
.
seek
(
0
)
if
is_empty_file
:
return
()
o
=
instance
.
newContent
(
id
=
available_id
,
portal_type
=
self
.
_portal_type
[
0
])
o
.
_setProperty
(
self
.
_acquired_property
,
*
args
,
**
kw
)
o
.
_setProperty
(
self
.
_acquired_property
,
value
,
*
args
,
**
kw
)
modified_object_list
=
(
o
,
)
return
modified_object_list
...
...
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