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
Sebastien Robin
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
Hide 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):
# Default value is 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
):
# Simple method : the one that defines a destination section wins
if
a
.
getDestinationSection
():
...
...
product/ERP5Type/Base.py
View file @
5184f5ea
...
...
@@ -2957,18 +2957,6 @@ class Base( CopyContainer,
return
object
.
__of__
(
self
)
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
):
"""This method returns the value of acquire_local_roles of the object's
portal_type.
...
...
product/ERP5Type/Core/Predicate.py
View file @
5184f5ea
...
...
@@ -41,6 +41,7 @@ from Products.ERP5Type.Document import newTempBase
from
Products.ERP5Type.XMLObject
import
XMLObject
from
Products.ERP5Type.Utils
import
convertToUpperCase
from
Products.ERP5Type.Cache
import
readOnlyTransactionCache
from
Products.ERP5Type.TransactionalVariable
import
getTransactionalVariable
from
Products.ZSQLCatalog.SQLCatalog
import
SQLQuery
from
Products.ERP5Type.Globals
import
PersistentMapping
from
Products.ERP5Type.UnrestrictedMethod
import
UnrestrictedMethod
...
...
@@ -579,21 +580,25 @@ class Predicate(XMLObject):
return
new_self
# 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 ${PortalType}_asPredicate,
${MetaType}_asPredicate, ${Class}_asPredicate
looking up methods named Class_asPredictae, MetaType_asPredicate, PortalType_asPredicate
"""
if
script_id
is
not
None
:
script
=
getattr
(
self
,
script_id
,
None
)
cache
=
getTransactionalVariable
()
key
=
id
(
self
),
script_id
if
'asPredicate'
in
cache
:
cache
=
cache
[
'asPredicate'
]
if
key
in
cache
:
return
cache
[
key
]
else
:
script
=
self
.
_getTypeBasedMethod
(
'asPredicate'
)
cache
=
cache
[
'asPredicate'
]
=
{}
script
=
self
.
_getTypeBasedMethod
(
'asPredicate'
,
script_id
)
if
script
is
not
None
:
return
script
()
self
=
script
()
cache
[
key
]
=
self
return
self
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