[ZPT] v2 of Path Prefixes in CVS

Chris Withers chrisw at nipltd.com
Thu Sep 4 10:42:37 EDT 2003


Shane Hathaway wrote:
> def template_prefix_handler(obj, name):
>     while obj is not None:
>         if hasattr(aq_base(obj), name):
>             t = guarded_getattr(obj, name)
>             if isinstance(t, PageTemplate):
>                 return t
>         obj = aq_parent(aq_inner(obj))
>     raise AttributeError, "No PageTemplate named '%s' found" % name
> 
<snip>

> Here is another way to think of it: currently, Zope 2 doesn't let you 
> choose how to traverse or acquire things.  You get a big, unpredictable 
> namespace that changes with each folder.  Mid-path prefixes let you 
> define and use your own traversal policies, making acquisition a clean, 
> useful thing again.

Hmmm, okay, maybe kinda getting bits of this. The above looks like it needs to 
be written as trusted code. Could it be written in a python script?

Given the above and the following path:
root/folder/something/template:fish

How do I wire the method above to the prefix 'template'?
What does the method get as obj?
What does it get as name?

Now, also, since IIRC, you sparked off the discussion about adapters in TAL in 
the Zope 3 dev list some time ago, how does this 'new stuff' relate to that?
The adapters stfuf has been implemented in the Zope 3 TALES package, will this 
replace or augment it? If the anser is 'augment', then how will the two interact?

cheers,

Chris




More information about the ZPT mailing list