[Checkins] SVN: five.pt/trunk/ Fixed issue (?) where a view is a view for a view.

Malthe Borch mborch at gmail.com
Wed Feb 18 15:20:05 EST 2009


Log message for revision 96708:
  Fixed issue (?) where a view is a view for a view.

Changed:
  U   five.pt/trunk/CHANGES.txt
  U   five.pt/trunk/src/five/pt/pagetemplate.py

-=-
Modified: five.pt/trunk/CHANGES.txt
===================================================================
--- five.pt/trunk/CHANGES.txt	2009-02-18 20:08:17 UTC (rev 96707)
+++ five.pt/trunk/CHANGES.txt	2009-02-18 20:20:04 UTC (rev 96708)
@@ -1,6 +1,9 @@
 Changelog
 =========
 
+- Fixed edge-case (special case?) where the view of a
+  ViewPageTemplateFile is really only the view for a view. [malthe]
+
 - Added patch for ``Products.PageTemplates.PageTemplateFile``. [malthe]
 
 - Rework the "full namespace provided to path expression" change introduced

Modified: five.pt/trunk/src/five/pt/pagetemplate.py
===================================================================
--- five.pt/trunk/src/five/pt/pagetemplate.py	2009-02-18 20:08:17 UTC (rev 96707)
+++ five.pt/trunk/src/five/pt/pagetemplate.py	2009-02-18 20:20:04 UTC (rev 96708)
@@ -63,8 +63,18 @@
         if view is None:
             namespace = {}
         else:
-            context = aq_inner(view.context)
-            request = request or view.request
+            try:
+                request = request or view.request
+                context = aq_inner(view.context)
+            except AttributeError:
+                """This may happen with certain dynamically created
+                classes,
+                e.g. ``plone.app.form._named.GeneratedClass``.
+                """
+                view = view.context
+                request = view.request
+                context = aq_inner(view.context)
+                
             namespace = dict(
                 context=context,
                 request=request,



More information about the Checkins mailing list