Hi Joachim, Here is a python method I've used to automate the creation of select queries. It uses ZPatterns to create an instance to get the field names etc... but the query object creation part should not depend on that. -steve import string newObj = context.newItem('foobie' + `container.idCount`) # create a bogus temp instance.. container.manage_changeProperties(idCount = container.idCount + 1) typeMap = {'string':'string', 'date':'float'} if not primaryKey: primaryKey = string.lower(context.id[:-1]) + 'ID' argumentList = ['%s=""' % primaryKey] itemList = [primaryKey] typeList = ['string'] templateString = '' for item_pair in newObj.propertysheets.items(): if item_pair[0] != 'webdav': name, ps_value = item_pair pm = ps_value.propertyMap() templateString = templateString + "\n select " for item in pm: itemList.append(item['id']) typeList.append(item['type']) argumentList.append('%s=""' % item['id']) templateString = templateString + string.join(itemList,', ') newObj.manage_delete() argumentString = string.join(argumentList,' ') whereClause = """ <dtml-sqlgroup where> %s </dtml-sqlgroup> """ simpleGroup = """ <dtml-sqlgroup> <dtml-if %s> <dtml-sqltest %s type=%s> </dtml-if> </dtml-sqlgroup> """ whereList = [] for i in range(len(itemList)): item = itemList[i] theType = typeMap.get(typeList[i],'string') whereList.append( simpleGroup % (item, item, theType)) whereTemplate = string.join(whereList,'<dtml-and>') templateString = templateString + " from %s_%s " % (context.id, name) templateString = templateString + whereClause % whereTemplate if not hasattr(context,sqlName): fc = context.manage_addProduct['ZSQLMethods'] fc.add.manage_addZSQLMethod(sqlName,'', connection_id=dbName, arguments=argumentString, template=templateString) else: theSQL = getattr(context, sqlName) theSQL.manage_edit( '', connection_id=dbName, arguments=argumentString, template=templateString) return "OK" On Tuesday, August 7, 2001, at 01:06 PM, Joachim Schmitz wrote:
http://www.myhost.de/manage_addZSQLMethod
I am quite sure, that the name is correct, so what's wrong here ?
Mit freundlichen Grüßen
Joachim Schmitz
AixtraWare, Ing. Büro für Internetanwendungen Hüsgenstr. 33a, D-52457 Aldenhoven Telefon: +49-2464-8851, FAX: +49-2464-905163
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )