[Zope3-dev] Re: Better access to APIs in paths (was Re: needing viewsclues - template/title troubles)

Shane Hathaway shane@zope.com
Mon, 24 Feb 2003 11:51:34 -0500


Evan Simpson wrote:
> Shane Hathaway wrote:
> 
>>> <html tal:namespaces="dc http://purl.org/dc/elements/1.1/;
>>>                       zope http://namespaces.zope.org/zope">
>>
> 
>> "context/zope:services/events/dc:title" is allowed and probably common.
> 
> 
> I like this a lot.  Given what I've read earlier in this thread, doesn't 
> this (sort of) boil down to 'dc(zope(context).services.events).title', 
> where 'dc' and 'zope' are aliased to Interface Adapters?  The path form 
> actually "reads" better in this case, since you can scan it 
> left-to-right or right-to-left instead of inside-out.

Yes, that's one way to interpret it.  The way I interpret it is that the 
template author doesn't need to know about adapters and so on.  Template 
authors only need to know that dc:title "does the right thing". :-)

> I'm not sure whether I am stretching the concept too far, but consider 
> the following:
> 
> <html tal:namespaces="sf http://namespaces.zope.org/string-formats">
> ...
> <span tal:replace="item/total/sf:money">$1,000.00</span>
> 
> That is, 'sf(item.total).money()', where 'item.total' is a number, and 
> the 'string-formats' Adapter wraps it in an Interface capable of 
> converting it into a localized currency string, among many other formats.

That's not stretching it at all.  That would be wonderful!

I envision a "NamespaceResolution" service that, given an object and a 
namespace, returns a component.  It might use adapters under the covers.

Shane