Putting a list of objects into the current namespace (or something)
I am trying to create a "virtual" folder. It should get a list of objects from somewhere else ie. a Catalog query and then act as if the objects exists in that folder. If the objects existed in this structure: / Members/ member1/ doc1 doc2 member2/ doc3 doc4 I want to show the objects in a new context, like: / news/ doc1 doc3 articles/ doc2 doc4 So an url like "/news/doc1" should actually show doc1 from "/Members/member1/doc1" transparently. Has anybody got any pointers as to how I could do this best ? My idea is either to subclass ObjectManager and overwrite "__getitem__()", or to find a way to push my objectlist onto the request object. Any better ideas? Pointers to code that does something similar? regards Max M
Look for the PathHandler product on zope.org: http://www.zope.org/Members/NIP/PathHandler or the AccessRule symlink recipe in zopelabs.com: http://www.zopelabs.com/cookbook/1003844578 Also, if you acces an URL that 'walks thru' a PythonScript, say: http://example.com/path/to/MyPythonScript/some/extra/path the MyPythonScript PythonScript will be called and will possess a variable 'traverse_subpath' (depending on what you set on the 'Bindings' tab) with the list of path segments after it's own name (in this case ['some','extra','path'] On Tue, 2002-03-12 at 11:22, Max M wrote:
I am trying to create a "virtual" folder. It should get a list of objects from somewhere else ie. a Catalog query and then act as if the objects exists in that folder.
If the objects existed in this structure:
/ Members/ member1/ doc1 doc2 member2/ doc3 doc4
I want to show the objects in a new context, like:
/ news/ doc1 doc3 articles/ doc2 doc4
So an url like "/news/doc1" should actually show doc1 from "/Members/member1/doc1" transparently.
Has anybody got any pointers as to how I could do this best ? My idea is either to subclass ObjectManager and overwrite "__getitem__()", or to find a way to push my objectlist onto the request object.
Any better ideas? Pointers to code that does something similar?
regards Max M
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
-- Ideas don't stay in some minds very long because they don't like solitary confinement.
Leonardo Rochael Almeida wrote:
Look for the PathHandler product on zope.org: http://www.zope.org/Members/NIP/PathHandler
or the AccessRule symlink recipe in zopelabs.com: http://www.zopelabs.com/cookbook/1003844578
Also, if you acces an URL that 'walks thru' a PythonScript, say:
http://example.com/path/to/MyPythonScript/some/extra/path
the MyPythonScript PythonScript will be called and will possess a variable 'traverse_subpath' (depending on what you set on the 'Bindings' tab) with the list of path segments after it's own name (in this case ['some','extra','path']
Thanks, but I don't think my problem should be solved by manipulating paths. Rather I need to push a list of objects into the current namespace. Here is some sseudocode for how I believe it to be: def __getattr__(self, name): # build temp namespace objList = getObjectsFromAllOverTheSite() # ;-) for obj in objList: linkedObjects[obj.getId()] = obj if linkedObjects.has_key(name): return linkedObjects[name] else: return getattr(self, name) I am just pretty unshure about this approach though, so I am fishing for anything like it. The closest thing I have found was in the "Transparent Folder" product. regards Max M
From: "Max M" <maxm@mxm.dk>
I am just pretty unshure about this approach though, so I am fishing for anything like it. The closest thing I have found was in the "Transparent Folder" product.
The Alias element of my Virtual Host Folder does something similar as well. I can tell you that this kind of manipulation is very brittle, in my experience. If you can come up with a less"manipulative" approach then you'll probably be happier in the long run...acknowledging, of course, that this was a road I went down as well, so I didn't come up with anything better either. ;) Gary
participants (3)
-
Gary Poster -
Leonardo Rochael Almeida -
Max M