[Zope-dev] python scripts

Tom Deprez Tom Deprez" <tom.deprez@uz.kuleuven.ac.be
Mon, 14 May 2001 14:46:49 +0200


Hi,

This weekend I did some work on python scripts and found some things which
suprised me, can someone enlighten me on this why these 'strange' things are
needed? :

1. When calling a method from a python script you've to do this :

    (assume x is the value to pass  and name is a parameter of mymethod)

      context.mymethod(name=x)

   The following doesn't works :

     context.mymethod(x) (this gives an error)

   Why????

2. Assume you've an sqlmethod which expects 2 parametes, but one is optional
:

    eg
    select *
    from invoice
    <dtml-sqlgroup where required>
       <dtml-sqlgroup>
                <dtml-sqltest customersid column=customers_id op=eq
type=int>
            <dtml-and>
                 <dtml-sqltest productsid column=products_id op=eq type=int
optional>
       </dtml-sqlgroup>
    </dtml-sqlgroup>

   So, you could run this sql with or without the productsid

  No, calling from python script doesn't works since it

  expects: context.mymethod(customerid=..., productsid=...)

  while context.mymethod(customerid=...) doesn't work..

Now, this implies that I've to write 2 sqlmethods (one with 2 parameters and
one with 1),
which is pretty stupid, since sqlmethods perfect allow to ignore a parameter
when not passed...


Can somebody tell me more on this? Why this is the case and perhaps a
solution for (2)

Thanks in advance,

Tom Deprez