getSecurityManager.getUser() in __getitem__ Was: [Zope] Method with Dot in the name
Thomas Guettler
Thomas Guettler <thomas@thomas-guettler.de>
Mon, 25 Nov 2002 19:42:45 +0100
>
> The next thing is working, but it is not nice: the call to
> __getitem__() returns the content of a file to the browser. But Zope
> misses the docstring of the string. I solved by adding the content to
> the request object and returning a function which returns this, but a
> nicer solution would be better:
>
> request._return_file=self.download(key, REQUEST=request)
> def return_wrapper_with_docstring(REQUEST):
> "docstring"
> return REQUEST._return_file
> return return_wrapper_with_docstring
I found a better solution, maybe someone likes urls like this
"..../foo.myextension", too:
>>>
def __getitem__(self, key):
print "Document.__getitem__: key=%s" % (
key)
if hasattr(self, 'REQUEST'):
request=self.REQUEST
else:
request=None
...
request["file"]=key
return self.download
def download(self, file, REQUEST=None):
<<<
This way /foo.txt will be wrapped to /download?file=foo.txt
thomas
--
Thomas Guettler <guettli@thomas-guettler.de>
http://www.thomas-guettler.de