[z3-five] BrowserView and AttributeError on getPhysicalPath

Philipp von Weitershausen philipp at weitershausen.de
Thu Jul 13 22:57:54 CEST 2006


Tim Hicks wrote:
> Tim Hicks wrote:
>> Hi,
>>
>> I have a view.py module that looks like:
>>
>>    # Five imports
>>    from Products.Five import BrowserView
>>    from Products.Five.browser.pagetemplatefile \
>>        import ZopeTwoPageTemplateFile as PageTemplateFile
>>
>>
>>    class TopicView(BrowserView):
>>        """
>>        """
>>
>>        topic_listing  = PageTemplateFile('./topic_listing.pt')
>>        author_listing = PageTemplateFile('./author_listing.pt')
>>        topic_view     = PageTemplateFile('./topic_view.pt')
>>
>>
>> I have a ZCML snippet that looks like:
>>
>>    <browser:page
>>        for=".interfaces.IWeblog"
>>        class=".browser.view.TopicView"
>>        attribute="topic_listing"
>>        permission="zope2.View"
>>        name="topics" />
>>
>>
>> When I visit a URL like .../[my_IWeblog_instance]/topics/ I get:
>>
>>    Traceback (innermost last):
>>      Module ZPublisher.Publish, line 107, in publish
>>      Module Zope2.App.startup, line 227, in recordMetaData
>>      Module OFS.SimpleItem, line 380, in getPhysicalPath
>>    AttributeError: getPhysicalPath
>>
>>
>> I'm trying to use the PageTemplateFiles with the Plone UI/macros.
>>
>> Does anyone have any idea why this isn't working?
> 
> I should have said, I see this on Zope 2.8.4 with Five 1.2.5 and Zope 
> 2.9.3 (so whatever Five that is).
> 
> Also, I did *not* see this issue when I just directly declared the 
> template in ZCML a la:
> 
>     <browser:page
>        for=".interfaces.IWeblog"
>        template="browser/topic_lists.pt"
>        permission="zope2.View"
>        name="topics" />
> 
> I guess this means that SimpleViewClass somehow behaves differently to 
> my BrowserView-based class, but I can't figure out where SimpleViewClass 
> comes from, or what it looks like, so I'm having trouble following that 
> line of enquiry.

Oh boy :). You're down in the sewers of Zope 3, meaning its magic class
creation. I should really pick up my pet project of removing this magic
in Zope 3.4/2.12.

Anyways, that magic "SimpleViewClass" thing indeed behaves differently
when you have a template and when you don't. It shouldn't matter,
though. Your case should work. By the way, if you're interested in
tracking down this issue, take a look at Five/browser/metaconfigure.py.
Put on your asbestus underwear, though.

Perhaps you can create a patch for Five that demonstrates this issue
with a failing test? Take a look at Five/browser/tests/pages.txt (and
corresponding pages.zcml, pages.py, test_pages.py). There should be
enough infrastructure (sample templates, etc.) there to produce a test
case with small effort.

Of course, you're also most welcome to fix the issue as well :).

Philipp


More information about the z3-five mailing list