[CMF-checkins] CVS: CMF/CMFCore - ActionInformation.py:1.17.6.2 Expression.py:1.5.44.2

Yvo Schubbe cvs-admin at zope.org
Wed Nov 26 05:25:54 EST 2003


Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv23031/CMFCore

Modified Files:
      Tag: yuppie-listActionInfos-branch
	ActionInformation.py Expression.py 
Log Message:
works now even if there is no REQUEST, caching is disabled in that case


=== CMF/CMFCore/ActionInformation.py 1.17.6.1 => 1.17.6.2 ===
--- CMF/CMFCore/ActionInformation.py:1.17.6.1	Fri Nov 21 14:21:51 2003
+++ CMF/CMFCore/ActionInformation.py	Wed Nov 26 05:25:53 2003
@@ -196,10 +196,14 @@
 
 
 def getOAI(context, object=None):
-    cache = context.REQUEST.get('_oai_cache', None)
-    if cache is None:
-        context.REQUEST['_oai_cache'] = cache = {}
-    info = cache.get( str(object), None )
+    request = getattr(context, 'REQUEST', None)
+    if request:
+        cache = request.get('_oai_cache', None)
+        if cache is None:
+            request['_oai_cache'] = cache = {}
+        info = cache.get( str(object), None )
+    else:
+        info = None
     if info is None:
         if object is None or not hasattr(object, 'aq_base'):
             folder = None
@@ -213,7 +217,9 @@
                     break
                 else:
                     folder = aq_parent(aq_inner(folder))
-        cache[ str(object) ] = info = oai(context, folder, object)
+        info = oai(context, folder, object)
+        if request:
+            cache[ str(object) ] = info
     return info
 
 


=== CMF/CMFCore/Expression.py 1.5.44.1 => 1.5.44.2 ===
--- CMF/CMFCore/Expression.py:1.5.44.1	Fri Nov 21 14:21:51 2003
+++ CMF/CMFCore/Expression.py	Wed Nov 26 05:25:53 2003
@@ -52,10 +52,14 @@
 
 
 def getExprContext(context, object=None):
-    cache = context.REQUEST.get('_ec_cache', None)
-    if cache is None:
-        context.REQUEST['_ec_cache'] = cache = {}
-    ec = cache.get( str(object), None )
+    request = getattr(context, 'REQUEST', None)
+    if request:
+        cache = request.get('_ec_cache', None)
+        if cache is None:
+            request['_ec_cache'] = cache = {}
+        ec = cache.get( str(object), None )
+    else:
+        ec = None
     if ec is None:
         utool = getToolByName(context, 'portal_url')
         portal = utool.getPortalObject()
@@ -71,7 +75,9 @@
                     break
                 else:
                     folder = aq_parent(aq_inner(folder))
-        cache[ str(object) ] = ec = createExprContext(folder, portal, object)
+        ec = createExprContext(folder, portal, object)
+        if request:
+            cache[ str(object) ] = ec
     return ec
 
 




More information about the CMF-checkins mailing list