[Zope-dev] SVN: five.pt/trunk/src/five/pt/ The container should be the Acquisition.aq_parent.

Tres Seaver tseaver at palladion.com
Sun Oct 24 08:29:45 EDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/23/2010 07:13 PM, Ross Patterson wrote:
> Log message for revision 117827:
>   The container should be the Acquisition.aq_parent.
>   
>   Many templates expect this.  Without Chameleon, a
>   Products.CMFCore.FSPageTemplate inherits from
>   Products.PageTemplates whose classes which set the container using
>   self.aq_inner.aq_parent or self._getContainer() which in turn comes
>   from Shared.DC.Scripts.Bindings.Bindings.  With cmf.pt, the
>   FSPageTemplate no longer inherits from Products.PageTemplates or the
>   mro is changed such that this no longer takes effect.
>   
>   What's more confusing is that it seems like
>   Products.Five.browser.pagetemplate should be doing this anyways, since
>   in a Zope2 app, container really should be the aq_parent of the
>   context.

'container' is supposed to be the folder which holds the script /
template, not the context.  In a CMF site, that will typically be the
site root, given the way items in skin layers appear to be direct
attributes of the portal object.  For purposes of Five views, the "view
object" seemss like the right object to be the 'container' for the
template:  if that is the case here (hard to see from just the diff), great.

>  So I'm not entirely sure what the right answer is but I know
>   this fixes the CMFPlacefulWorkflow placeful_workflow_configuration
>   redirect loop I encountered and there's no place in cmf.pt to affect
>   the locals definition of "container" so I'm doing it here.
>   
> 
> Changed:
>   U   five.pt/trunk/src/five/pt/pagetemplate.py
>   U   five.pt/trunk/src/five/pt/tests/locals.pt
>   A   five.pt/trunk/src/five/pt/tests/locals_base.pt
>   U   five.pt/trunk/src/five/pt/tests/test_viewpagetemplatefile.py
> 
> -=-
> Modified: five.pt/trunk/src/five/pt/pagetemplate.py
> ===================================================================
> --- five.pt/trunk/src/five/pt/pagetemplate.py	2010-10-23 20:31:56 UTC (rev 117826)
> +++ five.pt/trunk/src/five/pt/pagetemplate.py	2010-10-23 23:13:52 UTC (rev 117827)
> @@ -60,7 +60,7 @@
>                  request=request or aq_get(instance, 'REQUEST', None),
>                  template=self,
>                  here=context,
> -                container=context,
> +                container=aq_parent(aq_inner(context)),
>                  nothing=None,
>                  same_type=same_type,
>                  test=test,
> @@ -108,7 +108,7 @@
>                  view=view,
>                  template=self,
>                  here=context,
> -                container=context,
> +                container=aq_parent(aq_inner(context)),
>                  nothing=None,
>                  path=pagetemplate.evaluate_path,
>                  exists=pagetemplate.evaluate_exists,
> 
> Modified: five.pt/trunk/src/five/pt/tests/locals.pt
> ===================================================================
> --- five.pt/trunk/src/five/pt/tests/locals.pt	2010-10-23 20:31:56 UTC (rev 117826)
> +++ five.pt/trunk/src/five/pt/tests/locals.pt	2010-10-23 23:13:52 UTC (rev 117827)
> @@ -2,7 +2,7 @@
>       xmlns:tal="http://xml.zope.org/namespaces/tal">
>      <div tal:replace="string:view:${view/available}" />
>      <div tal:replace="python:'here==context:'+str(here==context)" />
> -    <div tal:replace="python:'here==container:'+str(here==container)" />
> +    <div tal:replace="python:'parent==container:'+str(here.aq_parent==container)" />
>      <div tal:replace="string:root:${root/getPhysicalPath}" />
>      <div tal:replace="string:nothing:${nothing}" />
>      <div tal:define="cgi python:modules['cgi']">
> 
> Added: five.pt/trunk/src/five/pt/tests/locals_base.pt
> ===================================================================
> --- five.pt/trunk/src/five/pt/tests/locals_base.pt	                        (rev 0)
> +++ five.pt/trunk/src/five/pt/tests/locals_base.pt	2010-10-23 23:13:52 UTC (rev 117827)
> @@ -0,0 +1,6 @@
> +<div xmlns="http://www.w3.org/1999/xhtml"
> +     xmlns:tal="http://xml.zope.org/namespaces/tal">
> +    <div tal:replace="python:'here==context:'+str(here==context)" />
> +    <div tal:replace="python:'container==None:'+str(None==container)" />
> +    <div tal:replace="string:nothing:${nothing}" />
> +</div>
> 
> Modified: five.pt/trunk/src/five/pt/tests/test_viewpagetemplatefile.py
> ===================================================================
> --- five.pt/trunk/src/five/pt/tests/test_viewpagetemplatefile.py	2010-10-23 20:31:56 UTC (rev 117826)
> +++ five.pt/trunk/src/five/pt/tests/test_viewpagetemplatefile.py	2010-10-23 23:13:52 UTC (rev 117827)
> @@ -4,6 +4,7 @@
>  from Testing.ZopeTestCase import ZopeTestCase
>  
>  from five.pt.pagetemplate import ViewPageTemplateFile
> +from five.pt.pagetemplate import BaseTemplateFile
>  
>  
>  class SimpleView(BrowserView):
> @@ -20,6 +21,11 @@
>      index = ViewPageTemplateFile('locals.pt')
>  
>  
> +class LocalsBaseView(BrowserView):
> +
> +    index = BaseTemplateFile('locals_base.pt')
> +
> +
>  class OptionsView(BrowserView):
>      index = ViewPageTemplateFile('options.pt')
>  
> @@ -50,11 +56,18 @@
>          #self.failUnless('Folder at test_folder_1_' in result)
>          #self.failUnless('http://nohost' in result)
>          self.failUnless('here==context:True' in result)
> -        self.failUnless('here==container:True' in result)
> +        self.failUnless('parent==container:True' in result)
>          self.failUnless("root:(\'\',)" in result)
>          self.failUnless("nothing:None" in result)
>          self.failUnless("modules:&lt;foo&gt;" in result)
>  
> +    def test_locals_base(self):
> +        view = LocalsBaseView(self.folder, self.folder.REQUEST)
> +        result = view.index()
> +        self.failUnless('here==context:True' in result)
> +        self.failUnless('container==None:True' in result)
> +        self.failUnless("nothing:None" in result)
> +
>      def test_options(self):
>          view = OptionsView(self.folder, self.folder.REQUEST)
>          options = dict(


- -- 
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkzEJrkACgkQ+gerLs4ltQ4y5wCfWQnHNrzWca8WA0/i95e7IVPb
OmgAoIRN4sQziWPAB3GrPlTyJxYDwByg
=aytz
-----END PGP SIGNATURE-----



More information about the Zope-Dev mailing list