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

Steve Spicklemire steve@spvi.com
Wed, 13 Dec 2000 13:48:34 -0500 (EST)


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(....)

or you could create an external method to set the property you want... 

YourExternalMethod( OrderingEntities.getItem(some_id), theValue)

where

def YourExternalMethod( theObject, theValue):
    setattr(theObject, 'current_order_id', theValue)

I think these could/should work...

    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.

    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..

Just random thoughts... 

;-)

-steve


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

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


    Itai> _______________________________________________ Zope-Dev
    Itai> maillist - Zope-Dev@zope.org
    Itai> http://lists.zope.org/mailman/listinfo/zope-dev ** No cross
    Itai> posts or HTML encoding!  ** (Related lists -
    Itai> http://lists.zope.org/mailman/listinfo/zope-announce
    Itai> http://lists.zope.org/mailman/listinfo/zope )