[ZPT] v2 of Path Prefixes in CVS
Fergal Daly
fergal at esatclear.ie
Mon Sep 1 02:46:50 EDT 2003
On Sunday 31 August 2003 23:12, Evan Simpson wrote:
> Fergal Daly wrote:
> The scope is global. Zope 3 will have facilities for defining prefixes
> in an entire site, or package, or whatever level is most appropriate.
> Zope 2 doesn't really have the machinery to do this right.
Fair enough. So for Zope 3 people won't need to define prefixes in their
templates but for Zope 2 people will either have to define the "dc:" prefix
in every template that uses it or have some sort of include templates.
> That example doesn't give a good feel for typical usage. In Zope 3, it
> will commonly be used to access Dublin Core properties, as in
> "here/myDocument/dc:title". Among the builtins in Zope 2 we have
> 'item:' for integer item access, as in "options/a_list/item:1". This
> does not fit well into your argument-passing form.
dc:title seems a better example as it feels like dc:title is a property of the
here/myDocument. It just seems that the feature is open to abuse as a way of
getting around the lack of arguments in method calls.
If all lists had an item method then options/a_list/item(1) would be perfectly
natural. Not being a python user I was a little surprised to find out that
lists don't have a named method for setting and getting items. What do you do
when you want to create an object that appears to be a list? Do you have to
resort to icky stuff similar to Perl's tie functionality?
In both these cases prefixes seem to be a way of calling a method that should
be available already but aren't for some reason, that is lists should have
accessor methods and documents should support Dublin core. That's useful and
it's a pity languages don't allow that as easily.
> > If you're going to do it, it would be better to use a different character
to
> > separate "foo/bar" and "my", space for instance.
>
> Spaces and parens are valid characters in Zope object names, and
> therefore in path segments. In any case, the syntax is not likely to
> change, given the existing Zope 3 implementation.
Space was chosen at random, I didn't look up the docs out of laziness. "/"
makes sense from the accessing a propertly point of view.
> Unless you use longish prefix names, it should be quite easy to get into
> the habit of visually parsing "/pname:arg/".
foo/bar/p:arg is not so bad when p:arg is a "property" of foor/bar, so
something like page/filename/file:owner wouldn't be so bad but things where
you calculate something from the argument like
foo/size/math:sqrt/other:mangle has the potential for lots of badness and
would be better written using a method calling syntax,
F
More information about the ZPT
mailing list