Phill Hugo wrote:
If there a simple way to get at the kw dict passed to a DTML callable?
I need to be able to determine if a variable was passed specifically from something like...
container.DTMLMethod(context, context.REQUEST, variable='Hello World')
In the DTML Method I can use <dtml-var variable> but if this variable was also the name of an id in the ZODB then it'll find it there.
Basically I need the equiv of <dtml-with kw only><dtml-var variable></dtml-with> ideally available as something like <dtml-var "this().kw"> or something
Thanks
Phill
Looking at the source lends no obvious way. (As an exercise for the reader, starting with OFS/DTMLMethod.py try to locate the actual python source of the base class HTML...As my 3 year old son would say psghetti!). Anyhow, I digress... A method that comes to mind would be to check for the existence of an equivilant value in the acquisition parent. If it either does not exist or is a different value, then check for a property of that value (for DTML docs). Again check if it exists or has a different value. Then do the same for request. If all fail to give the value, it must have come from a kw argument. I think you could write a python script like so: arguments: name, value if getattr(context.aq_parent, name, None) == value: return None if hasattr(context.aq_explicit, 'propertysheets'): if context.getProperty(name, None) == value: return None if context.REQUEST.get(name, None) == value: return None return value Of course this is not infallible, if you pass a name and value as a keyword that happens to match the name and value of something else in the namespace, it would return None. Another alternative would be to write a custom dtml-tag that strips the namespace down to the topmost one only for the code inside it. From what I read, the kw dict is always the last thing pushed onto the namespace. This assumes you haven't pushed anything yourself via dtml-let or dtml-with. A third option might be to wrap the method in a python script that pushed kw onto the namespace. maybe call it kw_call: arguments: DTMLMethod, **kw kw['kw_args'] = kw return DTMLMethod(_.None, context, kw=kw) Then you would have a variable called kw_args available within the method. I'm not entirely sure that this would work, but its worth a try! -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>