I'm writing an exteranl method to store data into a sql data base. In my first attempts to do this I just had an external method dump whatever zope gave it to a text file, then looked. I came up with the following to split up the data the zope handed the external method and store it an sql. This works. However, I'm thinking there must be an easier way to capture what zope hands and external method. Here's what I'm using now: def ddmapper(data): ''' maps dictionary keys and vals handed from zope to dictionary keys and vals which are attribute names of the table use to store the data puts a pickle of all data into a zo -- zopeobject nonce is a uniquifier ''' now = DT.now() pbuf = sio.StringIO() pickle.dump(data, pbuf) nonce = '%s:%s:%s:%s' % (now.year, now.month, now.day, now.second) attribs = dict(fname=data['first-name'], lname=data['last-name'], email=data['email-address'], studentid=data['student-id-number'], accomodations=data['will-special-assistance-be-required'], describe=data['describe-special-accomodations-needed'], degree=data['degree'][0], number=data['number-attending'], key=nonce, zo=pbuf.getvalue() ) del(pbuf) del(now) return attribs There must be an easier way to 'know' what zope is giving me and grab the correct dictionary that has the form data in it. anyone have any pointers? -- David Bear phone: 602-496-0424 fax: 602-496-0955 College of Public Programs/ASU University Center Rm 622 411 N Central Phoenix, AZ 85007-0685 "Beware the IP portfolio, everyone will be suspect of trespassing"
----- Original Message ----- From: "David Bear" <David.Bear@asu.edu> To: "zope" <Zope@zope.org> Sent: Wednesday, January 02, 2008 6:10 PM Subject: [Zope] looking for an easier way
There must be an easier way to 'know' what zope is giving me and grab the correct dictionary that has the form data in it. anyone have any pointers?
A couple of ideas: (i) use Zope marshalling to store all fields from an html form into a record (dictionary) (ii) get all form fields via: REQUEST.form.keys() hth Jonathan
participants (2)
-
David Bear -
Jonathan