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

Barry Pederson bp@barryp.org
Mon, 24 Feb 2003 11:22:37 -0600


Evan Simpson wrote:
> Shane Hathaway wrote:
> 
>> "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.
> 
> 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 beautiful - I really like the combination of simplicity and power 
that gives.  I think adapter-writing would take on a whole new 
significance, if it can be so easily used in presentation formatting.

	Barry