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

Tim Hoffman THoffman@dpc.wa.gov.au
24 Feb 2003 09:59:08 +0800


Hi

I really like the  <h1 tal:content="dc:title"/> example.
It suggests to me a clean definition of the name spaces/apis.

For instance later when I want to extend the metadata and 
and AGLS extensions to DC, I can then refer to agls:jurisdiction
and be clear about what I am referring to in the code.

Continiuing on from Jims example, I think you would want to be able
to explicitly refer to a namespace. (ie. two different apis might define
title)

So as jim defined, you might instead

>  <api
>     name="title"
>     for="zope.app.interfaces.annotation.IAnnotatable"
>     factory="zope.app.dublincore.annotatableadapter.TitleAPI"
>     >
>       title meta-data attribute
>
>       The title API attribute provides access to the (unqualified)
>       Dublin-Core "Title" meta-data element.
>   </api.
>
>Then from Python, we could do:
>
>  api(ob).title


I am not sure how you would rewrite api

but probably more a long the line of 

<api
    namespace=dc
    for="zope.app.interfaces.annotation.IAnnotatable">
      <attr  
        name="title"
        factory="zope.app.dublincore.annotatableadapter.TitleAPI"   >
            title meta-data attribute

            The title API attribute provides access to the (unqualified)
            Dublin-Core "Title" meta-data element.
      </attr)
      <attr
        name=description
        factory=
      >more stuff </attr>
      <attr
        name=subject 
        etc ..../>
   </namespace>
</api>

etc so you could define multiple attributes/methods in a single
specification.  Imagine having to do the api definition above for all of
the dublincore elements.


api(ob).dc.title
api(ob).agls.jurisdiction

Hmm or should that be api.dc(ob).title ?

How would api(ob).title resolve the situation where to registered apis
both had title ? Or would you raise an exception on registration if you 
got two "title" attributes in the global api namespace?

Rgds

Tim


Rgds

Tim

On Mon, 2003-02-24 at 07:40, Stuart Bishop wrote:
> On Monday, February 24, 2003, at 01:23  AM, Jim Fulton wrote:
> 
> >   context/++view++foo
> >   context/@@foo
> >   context/++api++title
> >   context//title
> >   context/++/title
> >
> > Thoughts?
> 
> For ZPT (which I think deserves a special case because of its target 
> audience):
>      <h1 tal:content="dc:context/title"/>
> or for a shortcut to the most common case, just
>      <h1 tal:content="dc:title"/>
> 
> Will be more familiar and explainable. API -> prefix mappings specified 
> in the
> config files, and can be overridden by properties on the page template 
> object
> (or possibly with a new <html tal:ns="dc IZopeDublinCore"> TAL tag.
> 
> This approach could also be used to make access from Python Scripts more
> mnemonic using these prefixes, but I think IZopeDublinCore(ob).title is
> quite acceptable. dc(ob).title would probably be the best alternative.
> 
> This all doesn't match the subject of this thread, but I think using
> a 'generic-works-everywhere' path syntax (limited by what can go in a
> URL) in places where there is more flexibilty will lead to much 
> yuckyness
> and desires to stick with Zope 2. A good goal would be to make 
> understanding
> the magic Perlish syntax a requirement of as few Actors as possible 
> IMHO.
> Preferably none at all, with any '++@@' gibberish being generated by 
> Zope or
> helper methods. I know I'd be turned off if I saw this sort of thing in 
> a
> 'Hello World' equivalent.
> 
> -- 
> Stuart Bishop <zen@shangri-la.dropbear.id.au>
> http://shangri-la.dropbear.id.au/
> 
> 
> _______________________________________________
> Zope3-dev mailing list
> Zope3-dev@zope.org
> http://mail.zope.org/mailman/listinfo/zope3-dev