Change in the views, extensions need to be updated!

Guido Wesdorp <[email protected]>
Newsgroups gmane.comp.web.zope.silva.devel
Message-ID <[email protected]>
Hi!

I have recently made a change to the way public views are registered and 
used in Silva that breaks existing extensions: to make it possible to 
view versions other than the current previewable and viewable ones I 
added a new 'view type' called 'preview', changed the registration of 
the 'public' and 'preview' view types so they get registered to Version 
objects rather then VersionedContent ones, and changed the setup of the 
public view directories so they have either a single script called 
'render' that renders both the public and preview versions, or a dir 
called 'view' that contains a 'render' script for the public view type, 
and one called 'preview' that contans a 'render' script for the 
'preview' view type.

In other words, to fix an existing extension to work with the current 
trunk version of Silva, you will need to:

- Change install.py so that instead of the versioned content metatype 
(e.g. 'Silva Document' for the SilvaDocument product) the version 
metatype (e.g. 'Silva Document Version' for SilvaDocument) is registered 
for the 'public' view type and add, if you want to have a seperate view 
for previewing a version, an additional line for the 'preview' view type.

Example:

# old install.py, the VersionedContent object is registered for 'public' 
view type only
reg.register('public', 'Silva Ghost', ['public', 'Ghost', 'view'])

# new install.py, the Version object is registered for both 'view' and 
'preview' view types
reg.register('public', 'Silva Ghost Version', ['public', 'Ghost', 'view'])
reg.register('preview', 'Silva Ghost Version', ['public', 'Ghost', 
'preview'])

Note that in this case we register both a 'public' and a 'preview' view 
type, you will only have to do that if you want a different view script 
for the public view and the preview of an object.

- Change the 'views/public/<meta_type>' directory: currently it contains 
2 scripts, one called 'render_view' and one called 'render_preview'. 
Those scripts will need to be replaced with either a single script 
called 'render' or with two directories called 'view' and 'preview', 
each containing a script called 'render'. The 'render' script(s) van get 
a reference to the version to be rendered from the attribute 'model' on 
request, so calls to e.g. 'model.get_previewable()' should not be made 
anymore, since model refers to a Version object rather then its 
VersionedContent 'container'.

I hope this is sort of clear, it's a pretty simple change but kind of 
hard to explain... For an example on how to perform the refactoring, see 
the Silva core's 'install.py' script and 'views/public' directory, if 
you have questions about this change, don't hesitate to send me an email.

Cheers,

Guido
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.