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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
erp5
Commits
1e87d0fe
Commit
1e87d0fe
authored
Nov 29, 2016
by
iv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow: add _initPersistentObjects method
This fixes Image.py, which was using _initBTree method.
parent
e7a50455
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
14 deletions
+29
-14
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+9
-11
product/ERP5/Document/Image.py
product/ERP5/Document/Image.py
+6
-1
product/ERP5Type/Core/ERP5PersistentMappingFolder.py
product/ERP5Type/Core/ERP5PersistentMappingFolder.py
+8
-0
product/ERP5Type/Core/Folder.py
product/ERP5Type/Core/Folder.py
+6
-2
No files found.
product/ERP5/Document/BusinessTemplate.py
View file @
1e87d0fe
...
@@ -1373,18 +1373,16 @@ class ObjectTemplateItem(BaseTemplateItem):
...
@@ -1373,18 +1373,16 @@ class ObjectTemplateItem(BaseTemplateItem):
if
getattr
(
obj
,
'_folder_handler'
,
None
)
==
PERSISTENT_MAPPING_HANDLER
:
if
getattr
(
obj
,
'_folder_handler'
,
None
)
==
PERSISTENT_MAPPING_HANDLER
:
# XXX(WORKFLOW): if obj._count(), then, we should export the content
# XXX(WORKFLOW): if obj._count(), then, we should export the content
# of the btree folder to the persistent mapping one
# of the btree folder to the persistent mapping one
obj
.
_cleanup
()
obj
.
_initPersistentObjects
()
obj
.
__init__
(
obj
.
id
)
elif
(
getattr
(
aq_base
(
obj
),
'_mt_index'
,
None
)
is
not
None
and
else
:
if
(
getattr
(
aq_base
(
obj
),
'_mt_index'
,
None
)
is
not
None
and
obj
.
_count
()
==
0
):
obj
.
_count
()
==
0
):
# some btrees were exported in a corrupted state. They're empty but
# some btrees were exported in a corrupted state. They're empty but
# their metadata-index (._mt_index) contains entries which in
# their metadata-index (._mt_index) contains entries which in
# Zope 2.12 are used for .objectIds(), .objectValues() and
# Zope 2.12 are used for .objectIds(), .objectValues() and
# .objectItems(). In these cases, force the
# .objectItems(). In these cases, force the
LOG
(
'Products.ERP5.Document.BusinessTemplate'
,
WARNING
,
LOG
(
'Products.ERP5.Document.BusinessTemplate'
,
WARNING
,
'Cleaning corrupted BTreeFolder2 object at %r.'
%
(
path
,))
'Cleaning corrupted BTreeFolder2 object at %r.'
%
(
path
,))
obj
.
_initBTrees
()
obj
.
_initBTrees
()
obj
=
obj
.
_getCopy
(
container
)
obj
=
obj
.
_getCopy
(
container
)
self
.
removeProperties
(
obj
,
0
)
self
.
removeProperties
(
obj
,
0
)
__traceback_info__
=
(
container
,
object_id
,
obj
)
__traceback_info__
=
(
container
,
object_id
,
obj
)
...
...
product/ERP5/Document/Image.py
View file @
1e87d0fe
...
@@ -53,6 +53,8 @@ from zLOG import LOG, WARNING
...
@@ -53,6 +53,8 @@ from zLOG import LOG, WARNING
from
Products.ERP5Type.ImageUtil
import
transformUrlToDataURI
from
Products.ERP5Type.ImageUtil
import
transformUrlToDataURI
from
Products.ERP5Type.Core.Folder
import
PERSISTENT_MAPPING_HANDLER
# import mixin
# import mixin
from
Products.ERP5.mixin.text_convertable
import
TextConvertableMixin
from
Products.ERP5.mixin.text_convertable
import
TextConvertableMixin
...
@@ -136,7 +138,10 @@ class Image(TextConvertableMixin, File, OFSImage):
...
@@ -136,7 +138,10 @@ class Image(TextConvertableMixin, File, OFSImage):
"""
"""
# Quick hack to maintain just enough compatibility for existing sites
# Quick hack to maintain just enough compatibility for existing sites
# Convert to new BTreeFolder2 based class
# Convert to new BTreeFolder2 based class
if
getattr
(
aq_base
(
self
),
'_count'
,
None
)
is
None
:
if
(
getattr
(
aq_base
(
self
),
'_folder_handler'
,
None
)
==
PERSISTENT_MAPPING_HANDLER
):
self
.
_initPersistentObjects
()
elif
getattr
(
aq_base
(
self
),
'_count'
,
None
)
is
None
:
self
.
_initBTrees
()
self
.
_initBTrees
()
# Make sure old Image objects can still be accessed
# Make sure old Image objects can still be accessed
...
...
product/ERP5Type/Core/ERP5PersistentMappingFolder.py
View file @
1e87d0fe
...
@@ -9,6 +9,7 @@ from App.special_dtml import DTMLFile
...
@@ -9,6 +9,7 @@ from App.special_dtml import DTMLFile
from
zope.event
import
notify
from
zope.event
import
notify
from
OFS.event
import
ObjectWillBeAddedEvent
from
OFS.event
import
ObjectWillBeAddedEvent
from
OFS.subscribers
import
compatibilityCall
from
OFS.subscribers
import
compatibilityCall
from
OFS.ObjectManager
import
BadRequestException
from
zope.lifecycleevent
import
ObjectAddedEvent
from
zope.lifecycleevent
import
ObjectAddedEvent
from
zope.lifecycleevent
import
ObjectRemovedEvent
from
zope.lifecycleevent
import
ObjectRemovedEvent
from
zope.container.contained
import
notifyContainerModified
from
zope.container.contained
import
notifyContainerModified
...
@@ -45,6 +46,13 @@ class ERP5PersistentMappingFolder(PortalFolderBase):
...
@@ -45,6 +46,13 @@ class ERP5PersistentMappingFolder(PortalFolderBase):
def
__len__
(
self
):
def
__len__
(
self
):
return
self
.
objectCount
()
return
self
.
objectCount
()
def
_initPersistentObjects
(
self
,
object_id
=
None
):
self
.
_cleanup
()
if
object_id
is
None
:
self
.
__init__
(
self
.
id
)
else
:
self
.
__init__
(
object_id
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'get'
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'get'
)
def
get
(
self
,
name
,
default
=
None
):
def
get
(
self
,
name
,
default
=
None
):
return
self
.
_getOb
(
name
,
default
)
return
self
.
_getOb
(
name
,
default
)
...
...
product/ERP5Type/Core/Folder.py
View file @
1e87d0fe
...
@@ -613,9 +613,10 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder,
...
@@ -613,9 +613,10 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder,
# Overload __init__ so that we do not take into account title
# Overload __init__ so that we do not take into account title
# This is required for test_23_titleIsNotDefinedByDefault
# This is required for test_23_titleIsNotDefinedByDefault
def
__init__
(
self
,
id
):
def
__init__
(
self
,
id
,
_folder_handler
=
PERSISTENT_MAPPING_HANDLER
):
self
.
id
=
id
self
.
id
=
id
if
self
.
_folder_handler
==
PERSISTENT_MAPPING_HANDLER
:
self
.
_folder_handler
=
_folder_handler
if
_folder_handler
==
PERSISTENT_MAPPING_HANDLER
:
ERP5PersistentMappingFolder
.
__init__
(
self
,
id
)
ERP5PersistentMappingFolder
.
__init__
(
self
,
id
)
security
.
declarePublic
(
'newContent'
)
security
.
declarePublic
(
'newContent'
)
...
@@ -734,6 +735,9 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder,
...
@@ -734,6 +735,9 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder,
obj
=
getOb
(
self
,
id
)
obj
=
getOb
(
self
,
id
)
setOb
(
self
,
id
,
obj
)
setOb
(
self
,
id
,
obj
)
def
_setFolderHandler
(
self
,
folder_handler
):
self
.
_folder_handler
=
folder_handler
# Override all BTree and HBTree methods to use if/else
# Override all BTree and HBTree methods to use if/else
# method to check wich method must be called
# method to check wich method must be called
# We use this method instead of plugin because it make
# We use this method instead of plugin because it make
...
...
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