[Zope-dev] ZPetterns implementation qustions

Itai Tavor itai@optusnet.com.au
Wed, 29 Nov 2000 18:19:21 +1100


Hi,

I'm trying to figure out the right way to implement a set of classes 
and roles in ZPatterns. I asked some questions about this a while 
ago, and then went away and did some learning, but I'm stuck again 
and I'm afraid I need to ask more questions.

I have two types of actors - Person (with properties name, phone, 
email, password) and Organization (with properties name, phone, fax, 
business_number).

I also have two participants - Customer and Reseller. Each 
participant can be either a Person or an Organization.

The participants can fill several roles, like OrderingEntities, 
BillableEntities, etc.

Starting from the bottom, I create a Specialist for each role, each 
one with two virtual Racks - customerRack and ResellerRack, so I can 
refer to an OrderingEntity without caring if it's a Reseller or 
Customer.

My problem is in implementing the Participant Specialists and storing 
Participant and Actor classes. Do I create Specialists for the 
Actors? It seems to me that since there is either one Person or one 
Organization per Customer, then the actor object should be created in 
the Customers Specialist. So Customers will have 3 Racks - 
defaultRack (using Customer object), personRack (using Person object) 
and organizationRack (using Organization object). Does this make 
sense?

If this is a good way to do it, how do I handle creating and 
accessing the Person and Organization objects? Do I call 
personRack.newItem(newCustomerId) in the script that creates the 
customer? Or do I somehow do it in a SkinScript in defaultRack? And 
how do I get to the Person data? With an attribute provider? Or in 
the SkinScript:

    WITH personRack.getItem(self.id) COMPUTE name=name, phone=phone, 
email=email, password=password, personObject=RESULT)

Also, if Actors are stored in the Specialists that implement the 
roles they participate as, there is no place to store methods that 
are common to an Actor regardless of role - for example, a method 
that checks if a password is secure enough and called when adding a 
Person object. So I either duplicate these methods in every 
Participant Specialist, or create more Specialists - which seems like 
a waste either way.

Another problem is how to edit these objects - if I have a form which 
includes fields for a Customer properties and for the properties of 
the Person object linked to that Customer, can I change the Person 
object from the Customer SkinScript? I don't think I can do this:

   WHEN OBJECT CHANGED STORE name, password USING
 
personObject.propertysheets.manage_changeProperties(name=self.name, 
password=self.password)

Right? Because name and password are not properties on the Customer 
DataSkin. So I have to call person.manage_changeProperties(...) in 
the method that changes Customer... it seems to me that I always end 
up doing object connections work in methods and the SkinScript can't 
help with anything :(


Hope this is not too convoluted...I'd really appreciate any help 
anyone can offer. The existing ZPatterns examples
all deal with fairly straightforward situations, but it's the more 
complex class relationships where the bears and tigers are hiding :)

Itai
-- 
Itai Tavor                    "Je sautille, donc je suis."
C3Works    itai@c3works.com              - Kermit the Frog

"If you haven't got your health, you haven't got anything"