durusmail: quixote-users: legal py & uri names don't overlap...
legal py & uri names don't overlap...
2004-04-05
2004-04-05
2004-04-05
2004-04-05
legal py & uri names don't overlap...
A.M. Kuchling
2004-04-05
On Mon, Apr 05, 2004 at 12:47:44PM -0400, Kendall Clark wrote:
> What is the general trick to having URI path components with "-" and
> other illegal Python variable characters mapped to Python bits in
> Quixote? I'd prefer a solution other than doing a dynamic lookup; that
> will work in some cases, but not in others (I guess it will *work* in
> all cases, but ugh!).

Dynamic lookup should work in all cases.  If you don't want to run the
lookup code for every access, _q_resolve() is similar to _q_lookup() except
that it's called exactly once; whatever it returns is stored on the object.

def _q_resolve (component):
    if component == 'rdf-model':
        return rdf_model

def rdf_model (...):
    pass

The first time _q_resolve is run, the publisher will do setattr(module,
'rdf-model', ) and _q_resolve won't be called again.

--amk


reply