On Monday 29 January 2001 10:19, Fred Yankowski wrote:
I missed the original message, but I'm trying to do something similar -- use Python Methods rather than DTML -- and I found one critical difference just today. Here's an example:
I've got an SQL Method called 'select_item' that takes 'item_id' as its only input parameter.
I've got a DTML Method 'form_action' that has 'item_id' in its namespace by virtue of being posted from an HTTP form.
When I would invoke the SQL method from DTML I could do just <dtml-call select_item> and the SQL method would get the item_id from the DTML method.
But when using a new 'action_script' Python Method (PythonMethod 0.1.7) I have to pass that item_id explicitly from the DTML <dtml-call "action_script(item_id)"> and action_script itself has to call the SQL method like so self.select_item(item_id=item_id)
I don't know why the explicit parameter passing is needed in the latter case (DTML to Python Method to SQL Method) but not in the former (DTML to SQL Method). I'm sure I'm missing some trick.
In fact, this aspect of Zope -- when values are passed explicitly and when not -- is a major confusion for me. (And anyone who responds about "Zen" deserves to have the size 12 boot applied.)
The way it appears to work is this: DTML will pass it's namespace on implicitly. Python will not. The exact details of what are passed are somewhat of a mystery, true. Rember, of course that <dtml-var "method_name()"> is a Python expression. As I understand it, the equivalent of: <dtml-var method_name> as a Python expression is: <dtml-var "method_name(_.None, _)"> When it comes to Python scripts, yes, you must pass all parameters explicitly. IMHO, this is a good thing in many cases, as it forces you to make sure you are passing the correct values. But I can see how implied values could make life easier... oh well... Have a better one, Curtis Maloney P.S. I'm now moving my application to Zope 2.3 in the vague hope that PythonScripts will handle this problem better.