Well.. I've started down the long winding road of porting EMarket to
ZPatterns.  I'm sure I'll learn a lot. ;-) Every time I start
something I discover that my understanding is shakey.. but getting
less so as time goes on.. Here is a concrete problem. (I always
work better with concrete problems... even though I occasionally
aspire to an abstract thought or two... that usually comes later...)

I've got a class:

class Shopper(

As you can see this class now inherits from data skin. I've got a specialist that
manages the shopper objects. My previous constructor looked like this:

    def __init__(self, id, email, name, passwd, address='', city='', state='',
                 phone='', fax='', country='', zip='', company='' ):
        Create a new shopper instance.
        self.email = email
        self.name = name
        self.passwd = passwd
        self.address = address
        self.city = city
        self.state = state
        self.phone = phone
        self.fax = fax
        self.zip = zip
        self.company = company
        self.country = country
        self.transNum = 1
        self.transDict = {}
        self.basket = Basket(self)              # firm offers...
        self.pendingBasket = Basket(self)       # not yet firm offers....
        self.salesItems = SalesBooth(self)
        self.transID = self.createTransID()
        self.addTime = time.time()

and my addShopper method used to look (essentially) like this:

def addShopper(self, id, email, name, passwd, passwd2, address, city, state,
               phone, fax, country, zip, REQUEST=None, company = '', passExcept = 0, 
noCheck = 0):
    """Add an shopper to a folder

    The argument 'self' will be bound to a folder.

    The arguments, 'id', 'passwd', and 'passwd2' just get us started...
    # a bunch of code to validata passwords etc.... and then...
    newShopper = Shopper(id, email, name, passwd, address, city, state,
                    phone, fax, country, zip, company)
    self._setObject(id, newShopper )

    # get a 'result'  blah blah...

    return result

Moving this to ZPatterns brings up all sorts of questions.  First of all I no longer
know that the actual class stored my shopper specialist is a 'Shopper'. It could
be any class kept in the shopper manager's rack(s). Soo... my addShopper should 
probably become:

def addShopper(self, id, REQUEST):
    """ add a new shopper... self is now the shopperManager (Specialist) """

    newShopper = self.newItem( id )

    newShopper.propertysheets.methodToUpdatePropertySheetsFromMappingObject( REQUEST )

Looking through VirtualSheets and PropertySheets code I see __propsets__
so I was thinking something like:

    for prop in newShopper.propertysheets.__propsets__():
        setattr(newShopper, prop, REQUEST.get(prop,None))

but this doesn't seem to work.... (I get 'nameError 'client'') in the
debugger.... I have no clue where 'client' comes from, reminds me
of the 'DTML Method' argument called 'client'... but I don't see
a traceback in the debugger.. anyway.. I've come to something like
this, though it doesn't do what I need.... :

        newShopper = self.newItem(id)
        newShopper.passwd = passwd
        newShopper.propertysheets.manage_addPropertySheet(id='EMarketProps', ns='')
        emp = newShopper.propertysheets.get('EMarketProps')
        emp.manage_addProperty('email', '', 'string')
        # ... blah blah blah...
        self._setObject(id, newShopper)

I am hopeful that this will expose a glaring misconception of mine
about propertysheets. ;-) Someone please tell me how stupid I am
and what I'm missing here... This does me no good... since I have to
create the propertysheets and I want to allow for properties that
I *don't know about* (i.e., customizations that individual
applications need to make these 'shoppers' work as 'clients' or
'memebrs' or whatever else...)  Clearly I'm flailing here..  Any ideas
from the wizards of Z? How would you modify addShopper to make it
work with other applications and allow for multiple propertysheets
that need to be set up from the addShopperForm....

Also.. I'm hoping for some advice about the old 'Basket' object. Basically
the old basked object was a simple container, one for each shopper, that
held 'Basket Items' which were essentially references to MarketItems, 
that were on sale in the store, along with quantity, options, etc.. 
How should I work these in with ZPatterns? Should there be a BasketManager
for each shopper that is essentially a Specialist for BasketItems? Other
ideas welcome...


Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to