[Zope] Use of mapply for calling ZSQL method

Geoff Armstrong geofstro@monaco.mc
Mon, 22 Jul 2002 21:15:51 +0200


I need to call a ZSQL method from a product and after searching the 
archives it seems the best solution is to make use of mapply as 
directed in cduncans article which deals with this in zopeLabs: 

Unfortunately, due to my lack of experience with Python, I cannot get 
the syntax to work and would appreciate some advise.

Here's what I'm trying to do. Please don't laugh :-(

def __init__(self, sql_method_name):
	self.data_source_id =sql_method_name

def check_db(self, val1, val2, val3):
     	"""Check database to determine if item already exists"""
     	object = getattr(self.aq_parent, self.data_source_id)
     	res = mapply(object, (arg1=val1,arg2=val2, arg3=val3),
		 REQUEST, call_object,1, missing_name, 
dont_publish_class, REQUEST, bind=1)
	return len(res.dictionaries())

The ZSQL method I'm trying to call (sql_method_name) accepts 3 
optional arguments, represented here by arg1, arg2, arg3 and returns 
true or false depending on whether an item with the values supplied 
can be found within the DB.

I'm sure it's pretty obvious where I'm going wrong.




The most convenient news site on the net!