[Zope-dev] Adding and setting properties from a virtual Specialist

Itai Tavor itai@optusnet.com.au
Wed, 13 Dec 2000 19:27:21 +1100


Hi,

I have a Specialist ('OrderingEntities') which creates virtual 
objects, mapped to existing objects (using ZClass 'Employee') in 
another Specialist ('Employees'). I want OrderingEntities to add and 
modify a property 'current_order_id' on the Employee objects. I can 
get the virtual object to access properties from the real object, but 
I can't figure out how to implement the property add/change.

To make things simpler, I added the property current_order_id to the 
Employee class, so I can test just modifying this property, leaving 
creating it for later.

OrderingEntities has an employeeRack, set to use the Employee class 
and to load by accessing attribute current_order_id. The Rack has 
this SkinScript:

     WITH Employees.getItem(self.id) COMPUTE
     original_object=RESULT or NOT_FOUND

     WITH self.original_object COMPUTE
     current_order_id

     WHEN OBJECT ADDED,CHANGED STORE current_order_id USING
 
self.original_object.manage_changeProperties(current_order_id=self.current_order_id)

Doing <dtml-var 
"OrderingEntities.getItem(some_id).current_order_id)"> shows me the 
value of current_order_id of the Employee object some_id. But I can't 
figure out how to change the property so it get changed in the 
Employee object. <dtml-call 
"OrderingEntities.getItem(some_id).manage_changeProperties(current_order_id='123')"> 
does nothing, it doesn't even trigger the WHEN OBJECT CHANGED line 
(not that I really expected it to work... this object is virtual, how 
can I call changeProperties on it?)

Other than figuring out how to get the change to work, I two more problems:

-Eventually the OrderingEntities Specialist will have several Racks 
mapping to several other Specialists, so it will end up returning 
different classes. Should I instead create a new ZClass with just the 
current_order_id property and use this class in all the virtual Racks?

- How do I add a property to the original object from the virtual 
object (assuming I did not add it manually to the Employee class)? Do 
I call self.original_object.manage_addProperty(...) from the 
SkinScript?

TIA
-- 
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"