[Zope] looking for an easier way

David Bear David.Bear at asu.edu
Wed Jan 2 18:10:12 EST 2008


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"


More information about the Zope mailing list