Late, but maybe still useful...

I just thought about a similar setup: Providing apis in multiple versions,
routing and so on.

The solution I came up with is to use some kind of "VirtualRoot" objects in
pyramid traversal
and register views with containment predicates.
Something like:


class VirtualRoot(object):
    """ add a named 'virtual' root object in traversal tree for url
generation """
    __parent__ = None
    __name__ = u""

    def __init__(self, name, original_root):
        original_root.__name__ = name
        original_root.__parent__ = self
        self.original_root = original_root

    def __getitem__(self, name):
        if name != self.original_root.__name__:
            raise KeyError, name
        return self.original_root


Inserted as the traversal root and passed a name and the original root
object this
approach is 100% pyramid compatible. A subclass Api1, Api2 or ApiDoc can be
used in view registrations register_view(..., containment=Api1, ...) to do
the rest
for you.

Arndt.


2013/1/1 Thomas G. Willis <tom.wil...@gmail.com>

>   I'm maintaining a json api with pyramid. And one of the request I
>   get on occasion is some way to provide help docs on demand for a
>   given endpoint. Something like.....
>
>
>
>

-- 
Arndt Droullier / Nive cms cms.nive.co

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.

Reply via email to