[Twisted-Python] can pb.Copyable objects be compared for equality after a round trip?

Robert Gravina robert at gravina.com
Sat Jun 24 22:21:48 EDT 2006


Ah sorry everyone... it seems I've misunderstood a very basic concept:

Copyables are copy-by-value
Referenceables are copy-by-reference

It says so here:
http://www.lothar.com/tech/papers/PyCon-2003/pb-pycon/pb.html

So basically I need to use either Referenceable or Viewable! OK now I  
can get back to work.

Robert

On 2006/06/25, at 9:18, Robert Gravina wrote:

>> Only thing I can think of is generate your own id. Doesn't have to  
>> be random, you can simply increament a counter every time you  
>> create a new instance. If you're worried about the id growing too  
>> long you can search the database for unused ids that are lower  
>> than the current value of the counter.
>>
>
> While I appreciate your suggestions, given that PB is really quite  
> powerful and pb.Referenceables can be identified after a round  
> trip, I figure there must be a better way of doing this. I don't  
> want to use pb.Referenceables because I need to access the objects  
> attributes and call methods on the remote end. I'm not 100% sure  
> that your method is bug-free, although I haven't had a good think  
> about it. Thanks anyhow.
>
>> Perhaps somebody else has a better idea.
>>
>
> I really hope so. I'm stuck for ideas, short of turning everything  
> into pb.Cacheables.
>
> Robert
>
>> On 24/06/06, Robert Gravina <robert at gravina.com> wrote: This is an  
>> old thread, but I am finally tackling the round trip
>> editing problem and unfortunately getting nowhere. Basically, I want
>> to be able to create some object on one machine, then send it off to
>> another (who edits some of the attributes) then when the other
>> machine calls a method on the original machine and passes it the
>> updated object, I can identify it simply by comparing for quality.
>> Think of your basic client/server database application.
>>
>> The Twisted howtos make the claim that " Copyable objects return
>> unchanged from a round trip", and can be compared for quality like
>> (obj == obj) but in all my attempts I can get this to work (they are
>> never equal). Does someone know of some sample code where this is
>> done successfully? It is done successfully with pb.Referenceables in
>> the howtos (look for the pb2client.py and pb2server.py listings).
>> http://twistedmatrix.com/projects/core/documentation/howto/pb- 
>> usage.html
>>
>> Since I'm using the ZODB, I've tried using ZODB's _p_oid attribute to
>> identify objects that come back to me but the _p_oid is  None even
>> after a transaction.commit() (since the object hasn't been persisted
>> yet probably).
>>
>> I could also create my own ID attribute and attempt to generate a
>> random ID and compare that, but this is most definately a hack.
>>
>> I am really having trouble progressing with my application because of
>> this problem. I'd really appreciate some insight on how to go about
>> solving this. Admittedly I'm not all that experienced with Twisted,
>> but I thought this kind of thing was supposed to be straightforward.
>> What am I doing wrong?
>>
>> Thanks,
>>
>> Robert
>>
>> On 2006/05/07, at 18:55, Micky Latowicki wrote:
>>
>> > It's possible to make each element in the set being edited a
>> > cacheable. If you think that would introduce too much overhead,  
>> then
>> > you can add a method to the "address book" object which updates  
>> one of
>> > the entries in this address book, and uses an id to identify the  
>> entry
>> > within the address book. So the address book is the dict. That's  
>> what
>> > I did in a similar case. I'm no expert though.
>> >
>> > HTH
>> >
>> > Micky
>> > _______________________________________________
>> > Twisted-Python mailing list
>> > Twisted-Python at twistedmatrix.com
>> > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>>
>>
>> _______________________________________________
>> Twisted-Python mailing list
>> Twisted-Python at twistedmatrix.com
>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>>
>> _______________________________________________
>> Twisted-Python mailing list
>> Twisted-Python at twistedmatrix.com
>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python





More information about the Twisted-Python mailing list