Problem with std. user folder Authentication dialog
How do I get rid of the Login dialog sent by 'user folder'? I have a product which I want to allow public access to (without compromising my site's security), but I can't get rid of the std. Login dialog. I tried to use the calls from the Security chapter in ZopeDevGuide, but without apparent effect: calls to security.declarePublic('myMethod') don't seem to work, as far as I can tell. Any hints would be appreciated. Vio
Hi All, One of the things I like about python is introspection. Zope does seem to support most features, but I run into some problems. I want to create a method that prints the items in a folder in tabular format. On each row, I want the title of the object in the folder and some properties. These properties should either be direct properties or methods. My code: 01 if context.hasProperty(propname): 02 return context.getProperty(propname) 03 else: 04 if hasattr(context,propname) and callable(getattr(context,propname)): 05 return context[propname]() 06 else: 07 return defaultvalue I first check whether context has the property requested, if so, I return it with getProperty. Than, if it has the property as attribute and the property is callable, there is a method and I call that (the kind of methods I look for do not require paramaters). If nothing of the kind can be found, I return the defaultvalue. Now, if I pass 'absolute_url' as propname, this works as a dream. But if I pass getParent, a method I created in the base class of the object where context was derived from, the thing crashes with 'Resource not found'. Debuging points out that line 04 goes okay, ie. it can find the property as attribute and determines that it is indeed callable, but the actual calling then fails with a resource not found. So, what am I doing wrong? Is there another way to call a method of a zope object if you only have the name of the method in a string variable? Any help is appreciated, Douwe
Douwe Osinga writes:
.... 05 return context[propname]() .... Now, if I pass 'absolute_url' as propname, this works as a dream. But if I pass getParent, a method I created in the base class of the object where context was derived from, the thing crashes with 'Resource not found'. You mix attribute access syntax and subscription syntax.
I do not know why it works for "absolute_url" but it is not a good idea in general. Try: "getattr(context,propname)()" Dieter
Thanks Dieter,
You mix attribute access syntax and subscription syntax. I must admit that I'm not so sure about the difference
I do not know why it works for "absolute_url" but it is not a good idea in general. Try: "getattr(context,propname)()" I did that too and it gives the same result. Resource not found. The strange thing is that
method = getattr(context,propname) in itself does not fail. But as soon as I try to do anything with method, I get the error. Any clues? Douwe
Douwe Osinga writes:
You mix attribute access syntax and subscription syntax. I must admit that I'm not so sure about the difference
I do not know why it works for "absolute_url" but it is not a good idea in general. Try: "getattr(context,propname)()" I did that too and it gives the same result. Resource not found. The strange thing is that
method = getattr(context,propname)
in itself does not fail. But as soon as I try to do anything with method, I get the error. That indicates, that your method call needs context that you do not provide!
If your method, e.g., would be a DTML method, then you must pass either a client object or (inclusive) a mapping object that gives the DTML method access to Zope objects (if it needs such access). For DTML objects, you may read "Calling DTML objects" in <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> to learn about the details. Dieter
participants (3)
-
Dieter Maurer -
Douwe Osinga -
vio