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

Shane Hathaway shane@zope.com
Mon, 24 Feb 2003 12:56:19 -0500


Barry Pederson wrote:
> Shane Hathaway wrote:
> 
>> Evan Simpson wrote:
>>
>>> 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.
> 
> 
> Is it really necessary to hide what's going on under pseudo-XML 
> namespace declarations, that people may confuse with real XML 
> namespaces?  How about something more upfront like:

They are intended to be real XML namespaces.

> <html tal:adapters="dc IZopeDublinCore; sf IStringFormats">
> ..
> 
> Perhaps by default, a "dc IZopeDublinCore" adapter could be predefined, 
> so template writers wouldn't have to explicitly declare it, although 
> they could perhaps override it for whatever reason.
> 
> I'd think the implementation would be much simpler, not having to map 
> those "namespaces" to real adapter names.

I don't want the indirection of mapping to adapter names, either.  I'd 
want to find an adapter by XML namespace.

However it works, I want to avoid too many Zope idioms in page 
templates.  You added two Zope idioms: "adapters" are currently specific 
to Zope, and so is the "IInterfaceName" convention (though it is used 
elsewhere).  If we use XML namespaces, we're not adding any baggage to 
page templates, since XML already carries this baggage.

Shane