[Zope] Help needed with External Script

Chris Bruce chrisabruce@webslate.com
Thu, 16 Aug 2001 20:12:37 -0000


Please Help,

I have the following python code as an external script.  But when I 
run it, I get:

Error Type: AttributeError
Error Value: aq_base


But if I comment out the line:

obj.propertysheets.ppProperty.manage_editProperties(REQUEST)

It works, but of course I have no properties set.  Any ideas what the 
problems are??

Here is the dtml method:

<dtml-var standard_html_header>
<h2><dtml-var title_or_id> <dtml-var document_title></h2>
<p>
<dtml-var expr="consultants.ImportData
('PersonalProfile','ppEntry','importData',REQUEST)"></p>
<dtml-var standard_html_footer>

Here is external python code:

import string
import csv
import Globals
from Globals import HTMLFile
from AccessControl.User import BasicUserFolder
from OFS.ObjectManager import ObjectManager
from OFS.PropertyManager import PropertyManager
from OFS.SimpleItem import Item
from AccessControl.Role import RoleManager
from Acquisition import aq_base

def importData(self, productName, className, fileName, REQUEST):
    zfile = getattr( aq_base( self ), fileName, None )
    data = "%s"%zfile
    lines = string.split(data, '\n')
    p = csv.parser()
    results =""
    for line in lines:
        r = p.parse(line)
        if len(r) > 0:
            results = results + r[0] + ' added.<br>'
            REQUEST.set('id', r[0])
            REQUEST.set('name', r[1] + ' ' + r[2])
            REQUEST.set('title', r[1] + ' ' + r[2])
            REQUEST.set('expires', '1/21/2002')
#            REQUEST.set('title', r[3])
            REQUEST.set('company', r[4])
            REQUEST.set('address', r[5] + ' ' + r[6])
            REQUEST.set('city', r[7])
            REQUEST.set('state', r[8])
            REQUEST.set('zip', r[9])
            REQUEST.set('email', r[10])
            REQUEST.set('website', r[11])
            REQUEST.set('isConsultant', r[12])
            intuitcert = []
            if r[13]:
                intuitcert.append('Intuit Pro Advisor')
            if r[14]:
                intuitcert.append('Intuit Certified')
            if r[20]:
                intuitcert.append('Intuit Certified')
            REQUEST.set('intuitcert', intuitcert)
            REQUEST.set('phone', r[15])
            REQUEST.set('fax', r[17])
            if len(r[22]) > 0:
                REQUEST.set('expires', r[22])
            else:
                REQUEST.set('expires', '01/01/1970')
            REQUEST.set('isAssociate', r[23])
            REQUEST.set('isCertified', r[24])
            product=self.manage_addProduct[productName]
            zclass=eval('product.'+className)
            obj=apply(zclass, [])
            obj._setId(r[0])
            obj.propertysheets.ppProperty.manage_editProperties
(REQUEST)
            self._setObject(r[0],obj,set_owner=0)
            
    return results


Any help would be greatly appreciated.

Thanks.