Commit c81c0fbe authored by Jean-Paul Smets's avatar Jean-Paul Smets

Make permanentURL system usable in standard ERP5.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19793 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1d3b9ac9
......@@ -232,6 +232,9 @@ class PermanentURLMixIn(ExtensibleTraversableMixIn):
can also use the permanent URL principle.
"""
# Declarative security
security = ClassSecurityInfo()
### Extensible content
def _getExtensibleContent(self, request, name):
# Permanent URL traversal
......@@ -289,6 +292,44 @@ class PermanentURLMixIn(ExtensibleTraversableMixIn):
editable_absolute_url=document.absolute_url()))
return document.__of__(self)
security.declareProtected(Permissions.View, 'getDocumentValue')
def getDocumentValue(self, name=None, portal=None, **kw):
"""
Return the default document with the given
name. The name parameter may represent anything
such as a document reference, an identifier,
etc.
If name is not provided, the method defaults
to returning the default document by calling
getDefaultDocumentValue.
kw parameters can be useful to filter content
(ex. force a given validation state)
This method must be implemented through a
portal type dependent script:
WebSection_getDocumentValue
"""
if name is None:
return self.getDefaultDocumentValue()
cache = getReadOnlyTransactionCache(self)
method = None
if cache is not None:
key = ('getDocumentValue', self)
try:
method = cache[key]
except KeyError:
pass
if method is None: method = self._getTypeBasedMethod('getDocumentValue',
fallback_script_id='WebSection_getDocumentValue')
if cache is not None:
if cache.get(key, _MARKER) is _MARKER: cache[key] = method
return method(name, portal=portal, **kw)
class Document(PermanentURLMixIn, XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin):
"""
......
......@@ -175,45 +175,6 @@ class WebSection(Domain, PermanentURLMixIn):
return self.getContainerLayout()
# WebSection API
security.declareProtected(Permissions.View, 'getDocumentValue')
def getDocumentValue(self, name=None, portal=None, **kw):
"""
Return the default document with the given
name. The name parameter may represent anything
such as a document reference, an identifier,
etc.
If name is not provided, the method defaults
to returning the default document by calling
getDefaultDocumentValue.
kw parameters can be useful to filter content
(ex. force a given validation state)
This method must be implemented through a
portal type dependent script:
WebSection_getDocumentValue
"""
if name is None:
return self.getDefaultDocumentValue()
cache = getReadOnlyTransactionCache(self)
method = None
if cache is not None:
key = ('getDocumentValue', self)
try:
method = cache[key]
except KeyError:
pass
if method is None: method = self._getTypeBasedMethod('getDocumentValue',
fallback_script_id='WebSection_getDocumentValue')
if cache is not None:
if cache.get(key, MARKER) is MARKER: cache[key] = method
return method(name, portal=portal, **kw)
security.declareProtected(Permissions.View, 'getDefaultDocumentValue')
def getDefaultDocumentValue(self):
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment