[Zope-dev] Putting a list of objects into the current namespace (or something)

Max M maxm@mxm.dk
Tue, 12 Mar 2002 16:18:02 +0000


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