[Zope] ZSQLMethodFile?

Peter Bengtsson mail@peterbe.com
Wed, 11 Jun 2003 14:47:47 +0100


>>> I usually just create ZSQL Methods as attributes of my (product) class:
>>>
>>> import Acquisition
>>> from Products.ZSQLMethods.SQL import SQL
>>>
>>> class mySQLClass(Acquisition.Implicit):
>>>     # We need Acquisition in order to find our db connection
>>>
>>>     # a database connection with this id must exist!
>>>     dbconnection = "the_db_connection"
>>>
>>>     _sql_null = "select 1 as one"
>>>     zsql_null = SQL('null',
>>>                'A dumb zsql method for testing purposes',
>>>                dbconnection,
>>>                '',
>>>                _sql_null,
>>>                )
>>>
>>>
>>>
>>> An instance of "mySQLClass" then could call self.zsql_null just like 
>>> a standard ZSQL Method

I'm not sure I understand.
Suppose my sql query string looks like this:

sqlstatement='''<params>admin_login_name
admin_password</params>
SELECT
  *
FROM
  service_provider
WHERE
<dtml-let admin_login_name="_.string.upper(admin_login_name)">
  UPPER(admin_login_name) = <dtml-sqlvar admin_login_name type="string">
</dtml-let>
  AND
  admin_password = <dtml-sqlvar admin_password type="string">'''

How do I then pass the keyword arguments?


>>>

> 
>> If I do some os.listdir(...) on my files, I'll be able to hack-parse 
>> the parameters and create the methods on the fly with parameters. 
>> Added benefit is that I'll be able to use arguments instead of only 
>> keyword arguments.
> 
> 
> I THINK you still have to pass keyword args (but I could be mistaken)
> 
IF I wrap them are class methods, will it correctly look like this:

def Mysqlstuff(Aq...):
     def zsql_method(self, name, age):
         return SQL(..., ..., ...)(name=name, age=age)

Or do I need anything else?

Thanks again
>>
>> Thank you
>>
> 
> No problem!
>