Simple (?) getattr question: ignore acquisition
Howdy... In a nutshell: I want to get some attribute of an object without it using acquisition - ie the attribute is returned if and only if the object has it _itself_. I'm trying to use _.getattr() but this is acquiring - I need something which doesn't acquire. In more detail: Folder "gimbo" contains two folders, "notes" and "queries". Queries has subdirectories, some of which have a "notes" property (a string). In "queries", I want to use something like: <dtml-in expr="objectValues('Folder')"> <dtml-let f = sequence-item> <dtml-try> <dtml-var expr="_.getattr(f, 'notes')"> <dtml-except> </dtml-try> </dtml-try> </dtml-in> to display the notes if they're present, and display a blank space if they're not. Unfortunately, for those folders which _don't_ have a notes property, the _.getattr() call in the above is picking up the "notes" folder from higher in the hierarchy - not what I want. I realise that by carefully choosing names I can avoid this, but I'd rather avoid that burden if possible. So, is there a way of doing this which doesn't attempt to acquire? Cheers, -Andy -- Andy Gimblett - Programmer - Frontier Internet Services Limited Tel: 029 20 820 044 Fax: 029 20 820 035 http://www.frontier.net.uk/ Statements made are at all times subject to Frontier's Terms and Conditions of Business, which are available upon request.
Folder "gimbo" contains two folders, "notes" and "queries". Queries has subdirectories, some of which have a "notes" property (a string).
If you're only dealing with properties, then a simple f.hasProperty('notes') or f.getProperty('notes') # returns None if not found will do the trick, as it doesn't acquire parent's properties. Otherwise with basic attributes it's usually more involved... Florent Guillaume Nuxeo
Andy Gimblett writes:
In a nutshell: I want to get some attribute of an object without it using acquisition - ie the attribute is returned if and only Search the mailing list archive for "aq_base".
Dieter
participants (3)
-
Andy Gimblett -
Dieter Maurer -
Florent Guillaume