At 02:46 AM 6/19/2009 +0300, Sergey Schetinin wrote:
but wouldn't it be nice if we could finally just do
things like

from somebody_else.forum import ForumApp
urlmap['/forum'] = ForumApp(db_config=...)

The Folder example in the bobo docs does basically that, actually.

I think perhaps you've misunderstood what Bobo does; it not only provides a framework for fixed mappings, it also provides the basis for doing flexible mappings. In fact, that's what subroute parameters are for.

So you could implement your urlmap above more or less like this:

@bobo.scan_class
class UrlMap(dict):

    @bobo.subroute('/:name')
    def subitem(self, name):
        try:
            return self[name]
        except KeyError:
            ...

Although you'd probably need a __setitem__ that split on '/' and created sub-UrlMap instances if they don't already exist, but you get the idea I hope.

Bobo's basic design, IOW, allows you to make pretty much any other design you like, but is very simple for relatively straightforward subtrees.

Also, AFAICT, *all* bobo paths are relative paths treating the enclosing module or instance as a mount point, and there is nothing stopping you from mounting such objects at whatever locations you like.

What bobo lacks (that would be nice) is a way to figure out what URL to address a specified object by, since the very flexibility that allows objects to have more than one name, also means that there is no obvious way to find what name to use for an object.

_______________________________________________
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com

Reply via email to