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

Itai Tavor itai@optusnet.com.au
Thu, 14 Dec 2000 11:33:27 +1100


Steve Spicklemire wrote:

>Hi Itai,
>
>>>>>>  "Itai" == Itai Tavor <itai@optusnet.com.au> writes:
>
>     Itai> "OrderingEntities.getItem(some_id).current_order_id)"> shows
>     Itai> me the value of current_order_id of the Employee object
>     Itai> some_id. But I can't figure out how to change the property
>     Itai> so it get changed in the Employee object. <dtml-call
>     Itai> 
>"OrderingEntities.getItem(some_id).manage_changeProperties(current_order_id='123')">
>     Itai> does nothing, it doesn't even trigger the WHEN OBJECT
>     Itai> CHANGED line (not that I really expected it to work... this
>     Itai> object is virtual, how can I call changeProperties on it?)
>
>How about 
>'OrderingEntities.getItem(some_id).propertysheets.TheRightPropertysheet.manage_changeProperties(....)

Grrrrr.... now I'm really annoyed. Why didn't I try that? So obvious. Thanks.


>     Itai> Other than figuring out how to get the change to work, I two
>     Itai> more problems:
>
>     Itai> -Eventually the OrderingEntities Specialist will have
>     Itai> several Racks mapping to several other Specialists, so it
>     Itai> will end up returning different classes. Should I instead
>     Itai> create a new ZClass with just the current_order_id property
>     Itai> and use this class in all the virtual Racks?
>
>This is what I do in most cases... each rack has different SkinScript
>to map the attributes of different classes onto the common attribute
>set of the single Storage class used by all the racks.

Sounds like a good plan, think I'll adopt it.


>     Itai> - How do I add a property to the original object from the
>     Itai> virtual object (assuming I did not add it manually to the
>     Itai> Employee class)? Do I call
>     Itai> self.original_object.manage_addProperty(...) from the
>     Itai> SkinScript?
>
>I think this should work....  but it will only add the propertysheet
>to the instance.. not the class. If the property is completely missing
>from the original class then it seems to me either there is really no
>real need to save it there... or the class was incomplete somehow to
>begin with... and it should be added at the ZClass level..

Say I got several Participants, and some of those need to be able to 
place orders. I create the Specialist OrderingEntities to implement 
the role of 'someone who places orders'. From what I understand about 
using Specialists to extend a class behavior, this Specialist should 
add the properties it needs to track orders with to the Participant 
classes - I should not have to go in to every Participant class and 
add the property to it, because those classes don't know and don't 
care that they might be used in this role. Am I wrong in this? 
Otherwise, the only other way to track properties for this role would 
be to physically store a new object on the OrderingEntities Rack for 
every Participant class accessed, but what's the point in that, if I 
can simply add the property to the original class?


Making small steps up the ZPatterns mountain (and too many of them backwards),

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"