python - Custom views for ATDocuments created through GenericSetup -


i have folderish atdocument class create through generic setup, generic setup xml configuration file has following view variables defined:

<property name="immediate_view">templatefilename</property> <property name="default_view">templatefilename_view</property> <property name="view_methods">     <element value="templatefilename_view"/> </property> 

is possible replace view dispatcher, i.e. browserview class on __call__ dispatch actual viewpagettemplatefile() instance?

i tried replacing template file name method name of class doesn't seem work. followed inheritance tree of atdocument though atctcontent basecontent, didn't find definitions of views, i'm guessing views processed via 1 of inherited mix-ins.

the names in genericsetup xml file either view names or skin items; view names looked using same traversal mechanisms when direcly name view in url.

so, anything can reach url can used view method. includes views dispatch other views in __call__ method:

from zope.publisher.browser import browserview zope.component import getmultiadapter  class dispatchingview(browserview):     def __call__(self):         if somecondition:             newviewname = 'foo'         else:             newviewname = 'bar'          return getmultiadapter((self.context, self.request), name=newviewname)() 

this example view looks other views name, , renders them in place return result of dispatcher itself.

note generally, make sure if view being used make sure include @@ view namespace in front of it's name prevent skin item same name accidentally being used.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -