[Zope3-Users] Output the template of a view class
Sven Schomaker
Sven.Schomaker at linie-m.de
Wed Jun 22 03:55:38 EDT 2005
Hi Florian,
AFAIK there is actually no need to manually return
the pagetemplate if you've registered your page via
zcml, since the page directive creates a new
SimpleViewClass with your class definition and
template as a mix-in.
Nevertheless the SimpleViewClass created exposes the
template provided by the zcml as an attribute
called 'index' and returns it in the __call__ method
itself.
Look at the code in zope.app.pagetemplate.simpleviewclass
to see how it works.
So if your willing to return the template yourself, just
define the __call__ method in your view class like this:
def __call__(self):
return self.index()
This should do the trick (Tried it myself to assure
not being mistaken, but if so please don't let me die
untaught!). But you definetly should not have to do it,
since it's supposed to work right out of the box.
Regards,
Sven
Florian Lindner wrote:
>Am Dienstag, 21. Juni 2005 18:41 schrieb Jim Fulton:
>
>
>>Florian Lindner wrote:
>>
>>
>>>Hello,
>>>sine I suspect my last email to have drowned on the list, I try to ask
>>>again.
>>>
>>>How can I ouput the template from the associated view class?
>>>
>>>class view:
>>> def __call__(self):
>>> return template
>>>
>>>How to do that?
>>>
>>>
>>Assuming that the template was defines via ViewPageTemplateFile, then:
>>
>>
>
>It is defined with ZCML:
>
> <page
> name="usersettings.html"
> for="CS.centershock.interfaces.ICentershock"
> template="usersettings.pt"
> [...]
> class=".views.UserSettings" />
>
>
>
>> return self.template()
>>
>>
>
> File
>"/home/florian/Desktop/zope/lib/python/CS/centershock/browser/skin/views.py",
>line 24, in __call__
> return self.template()
>AttributeError: 'SimpleViewClass from /home/florian/Desktop/zope/li' object
>has no attribute 'template'
>
>I wonder why the last path is truncated... However, it does not work.
>
>Thanks,
>
>Florian
>_______________________________________________
>Zope3-users mailing list
>Zope3-users at zope.org
>http://mail.zope.org/mailman/listinfo/zope3-users
>
>
--
__________________Addressed by:_________________
Sven Cochise Schomaker
Dipl.-Inf. (FH)
Linie M - Metall Form Farbe - GmbH
Industriestraße 8
63674 Altenstadt (Hessen)
Germany
Tel.: +49 6047 97 121
+49 179 14 79 309
Mail: Sven.Schomaker at linie-m.de
Sven.Schomaker at gmx.de
Public Key: hkp://blackhole.pca.dfn.de
hkp://pgp.mit.edu
Key ID: D581185EFF60FEA0
Key fingerprint: 28FB 599C 4591 D200 BC69
EB88 D581 185E FF60 FEA0
_______________________________________________
More information about the Zope3-users
mailing list