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
140
Merge Requests
140
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
5184f5ea
Commit
5184f5ea
authored
Dec 09, 2013
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache instanciation of predicates
Resource.asPredicate was broken and Base.asPredicate is useless.
parent
73b6cf17
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
33 deletions
+12
-33
product/ERP5/Document/Resource.py
product/ERP5/Document/Resource.py
+0
-14
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+0
-12
product/ERP5Type/Core/Predicate.py
product/ERP5Type/Core/Predicate.py
+12
-7
No files found.
product/ERP5/Document/Resource.py
View file @
5184f5ea
...
@@ -630,20 +630,6 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin):
...
@@ -630,20 +630,6 @@ class Resource(XMLObject, XMLMatrix, VariatedMixin):
# Default value is None
# Default value is None
return
None
return
None
# Predicate handling
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'asPredicate'
)
def
asPredicate
(
self
):
"""
Returns a temporary Predicate based on the Resource properties
"""
from
Products.ERP5
import
newTempPredicateGroup
as
newTempPredicate
p
=
newTempPredicate
(
self
.
getId
(),
uid
=
self
.
getUid
())
p
.
setMembershipCriterionBaseCategoryList
((
'resource'
,))
p
.
setMembershipCriterionCategoryList
((
'resource/%s'
%
self
.
getRelativeUrl
(),))
return
p
def
_pricingSortMethod
(
self
,
a
,
b
):
def
_pricingSortMethod
(
self
,
a
,
b
):
# Simple method : the one that defines a destination section wins
# Simple method : the one that defines a destination section wins
if
a
.
getDestinationSection
():
if
a
.
getDestinationSection
():
...
...
product/ERP5Type/Base.py
View file @
5184f5ea
...
@@ -2957,18 +2957,6 @@ class Base( CopyContainer,
...
@@ -2957,18 +2957,6 @@ class Base( CopyContainer,
return
object
.
__of__
(
self
)
return
object
.
__of__
(
self
)
raise
AttributeError
(
id
)
raise
AttributeError
(
id
)
# Predicate handling
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'asPredicate'
)
def
asPredicate
(
self
,
script_id
=
None
):
"""
This method tries to convert the current Document into a predicate
looking up methods named Class_asPredictae, MetaType_asPredicate, PortalType_asPredicate
"""
script
=
self
.
_getTypeBasedMethod
(
'asPredicate'
,
script_id
=
script_id
)
if
script
is
not
None
:
return
script
()
return
None
def
_getAcquireLocalRoles
(
self
):
def
_getAcquireLocalRoles
(
self
):
"""This method returns the value of acquire_local_roles of the object's
"""This method returns the value of acquire_local_roles of the object's
portal_type.
portal_type.
...
...
product/ERP5Type/Core/Predicate.py
View file @
5184f5ea
...
@@ -41,6 +41,7 @@ from Products.ERP5Type.Document import newTempBase
...
@@ -41,6 +41,7 @@ from Products.ERP5Type.Document import newTempBase
from
Products.ERP5Type.XMLObject
import
XMLObject
from
Products.ERP5Type.XMLObject
import
XMLObject
from
Products.ERP5Type.Utils
import
convertToUpperCase
from
Products.ERP5Type.Utils
import
convertToUpperCase
from
Products.ERP5Type.Cache
import
readOnlyTransactionCache
from
Products.ERP5Type.Cache
import
readOnlyTransactionCache
from
Products.ERP5Type.TransactionalVariable
import
getTransactionalVariable
from
Products.ZSQLCatalog.SQLCatalog
import
SQLQuery
from
Products.ZSQLCatalog.SQLCatalog
import
SQLQuery
from
Products.ERP5Type.Globals
import
PersistentMapping
from
Products.ERP5Type.Globals
import
PersistentMapping
from
Products.ERP5Type.UnrestrictedMethod
import
UnrestrictedMethod
from
Products.ERP5Type.UnrestrictedMethod
import
UnrestrictedMethod
...
@@ -579,21 +580,25 @@ class Predicate(XMLObject):
...
@@ -579,21 +580,25 @@ class Predicate(XMLObject):
return
new_self
return
new_self
# Predicate handling
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'asPredicate'
)
'asPredicate'
)
def
asPredicate
(
self
,
script_id
=
None
):
def
asPredicate
(
self
,
script_id
=
None
):
"""
"""
This method tries to convert the current Document into a predicate
This method tries to convert the current Document into a predicate
looking up methods named ${PortalType}_asPredicate,
looking up methods named Class_asPredictae, MetaType_asPredicate, PortalType_asPredicate
${MetaType}_asPredicate, ${Class}_asPredicate
"""
"""
cache
=
getTransactionalVariable
()
if
script_id
is
not
None
:
key
=
id
(
self
),
script_id
script
=
getattr
(
self
,
script_id
,
None
)
if
'asPredicate'
in
cache
:
cache
=
cache
[
'asPredicate'
]
if
key
in
cache
:
return
cache
[
key
]
else
:
else
:
script
=
self
.
_getTypeBasedMethod
(
'asPredicate'
)
cache
=
cache
[
'asPredicate'
]
=
{}
script
=
self
.
_getTypeBasedMethod
(
'asPredicate'
,
script_id
)
if
script
is
not
None
:
if
script
is
not
None
:
return
script
()
self
=
script
()
cache
[
key
]
=
self
return
self
return
self
def
searchPredicate
(
self
,
**
kw
):
def
searchPredicate
(
self
,
**
kw
):
...
...
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