You would have to have an object bar.a1.a2.a3.an
defined within your foo.py
module. Basically, the publisher handler replaces the slashes in the URL with dots, and tries to find some Python object with that name.
Here's something wacky you could try: in foo.py
:
class _barclass(object): def __init__(self, parent, name): if parent and name: self.path = parent.path +'/'+ name setattr(parent, name, self) else: self.path = '' def __getattr__(self, name): return _barclass(self, name) def __call__(self): # do your processing here # url path is contained in self.pathbar = _barclass(None, None)
Although this is kind of straining the bounds of what the publisher is meant to do - you might be better off writing your own handlers from scratch. (Or using something like Django.)