[Zope] confused about optional args to ZSQL methods

Skip Montanaro skip@pobox.com
Wed, 4 Dec 2002 23:10:41 -0600


I think I may have encountered this problem before and asked about it.  If
so, any solutions offered at that time escape me now.  I have this ZSQL
method (get_workorder):

    <params>id
    worker_id
    end_date</params>
    select * from work_order
      <dtml-sqlgroup where>
        <dtml-sqltest name=id op=eq type=int optional>
      <dtml-and>
        <dtml-sqltest name=worker_id op=eq type=int optional>
      <dtml-and>
        <dtml-sqltest name=end_date op=ge type=string optional>
      </dtml-sqlgroup>
    ;

In a Python script I want to call it like so:

    workorders = context.sql.get_workorder(worker_id=worker_id,
                                           end_date='2003-04-23')

that is, omit the presumably optional id parameter.  However, when the
Python script is run, the ZSQL method complains "Invalid integer value for
id".  I also tried these forms:

    workorders = context.sql.get_workorder(**{'worker_id': worker_id,
                                              'end_date': '2003-04-23'})

    workorders = context.sql.get_workorder(**{'id': None,
                                              'worker_id': worker_id,
                                              'end_date': '2003-04-23'})

    workorders = context.sql.get_workorder(id=None,
                                           worker_id=worker_id,
                                           end_date='2003-04-23')


without success.  The first form gave the same error as above.  The other
two gave "object can't be converted to int".

How do I arrange things so I can call get_workorder without passing
the id parameter?

Thx,

-- 
Skip Montanaro - skip@pobox.com
http://www.mojam.com/
http://www.musi-cal.com/