Re: [Zope-dev] to __of__ or not to __of__ ?

2002-08-15 Thread Joachim Schmitz

Hi Casey,

--On Mittwoch, August 14, 2002 23:38:52 -0400 Casey Duncan [EMAIL PROTECTED] 
wrote:

 The Item class mixes in Traversable, which is probably responsible for
 making  this work TTW. It also gives you a bunch of other stuff that many
 Zope  classes need, like DAV support, copy support, ZMI tab support and
 security.  It doen't mix-in acquisition tho.

 If you need support for acquistion machinery (including __of__ which
 creates  wrappers), then you need to mix-in Acquisition.Implicit. The
 SimpleItem class  mixes this and Persistence in for you (along with
 Item), so many Zope classes  derive form SimpleItem. You need Persistence
 to store instances of your class  in the ZODB, and implicit acquisition
 is the standard for Zope objects.

I actually don't know, if I need acquisition. The items are stored in the 
btree of
the table, and I experienced no problems till now. I can copy and 
export/import AixtraTable instances and the data is preserved.


 In short I would recommend mixing in SimpleItem or you may find that your
 objects are not stored properly in the ZODB.

Is that also true, if I store them in a btree ?


 -Casey

 BTW: People will take you a lot more seriously on this list if you loose
 the
# {{{ ... #}}} crutches ;^)

I use a folding editor (jed) and these are the folding marks. Folding makes 
your
editing live much easier. ;-))


Mit freundlichen Grüßen  Joachim Schmitz

AixtraWare Ingenieurbüro für Internetanwendungen
Hüsgenstr. 33a, D-52457 Aldenhoven
Telefon: +49-2464-8851, FAX: +49-2464-905163

Key fingerprint = DA10 CC82 62F8 1DBB 39A1  1EDC 725B 3317 A8D7 C3A6
Keyserver: http://www.keyserver.net/en/

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] to __of__ or not to __of__ ?

2002-08-15 Thread Johan Carlsson [Torped]


At 23:38 2002-08-14 -0400, Casey Duncan said:
The Item class mixes in Traversable, which is probably responsible for 
making
this work TTW. It also gives you a bunch of other stuff that many Zope
classes need, like DAV support, copy support, ZMI tab support and security.
It doen't mix-in acquisition tho.

If you need support for acquistion machinery (including __of__ which creates
wrappers), then you need to mix-in Acquisition.Implicit. The SimpleItem 
class
mixes this and Persistence in for you (along with Item), so many Zope 
classes
derive form SimpleItem. You need Persistence to store instances of your 
class
in the ZODB, and implicit acquisition is the standard for Zope objects.

In short I would recommend mixing in SimpleItem or you may find that your
objects are not stored properly in the ZODB.

-Casey


You also might want to wrap the object before returning them,
because the are stored in _item and not in the AixtraTableProduct.

 def getItem(self,key): #{{{
 returns item
 data = self._items
 if data.has_key(key):
 item = self._items[key]
 if not hasattr(item,'key'):
 setattr(item,'key',key)
 return item.__of__(self)  --- wrap the item before returned

Regards,
Johan Carlsson




-- 
Torped Strategi och Kommunikation AB
Johan Carlsson
[EMAIL PROTECTED]

Mail:
Birkagatan 9
SE-113 36  Stockholm
Sweden

Visit:
Västmannagatan 67, Stockholm, Sweden

Phone +46-(0)8-32 31 23
Fax +46-(0)8-32 31 83
Mobil +46-(0)70-558 25 24
http://www.torped.se
http://www.easypublisher.com


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] to __of__ or not to __of__ ?

2002-08-14 Thread Casey Duncan

The Item class mixes in Traversable, which is probably responsible for making 
this work TTW. It also gives you a bunch of other stuff that many Zope 
classes need, like DAV support, copy support, ZMI tab support and security. 
It doen't mix-in acquisition tho.

If you need support for acquistion machinery (including __of__ which creates 
wrappers), then you need to mix-in Acquisition.Implicit. The SimpleItem class 
mixes this and Persistence in for you (along with Item), so many Zope classes 
derive form SimpleItem. You need Persistence to store instances of your class 
in the ZODB, and implicit acquisition is the standard for Zope objects.

In short I would recommend mixing in SimpleItem or you may find that your 
objects are not stored properly in the ZODB.

-Casey

BTW: People will take you a lot more seriously on this list if you loose the 
#{{{ ... #}}} crutches ;^)

On Wednesday 14 August 2002 05:29 pm, Joachim Schmitz wrote:
 Hi,
 
 in my AixtraTable product the newItem method is defined like this:
 
 def newItem(self,key): #{{{
   returns item
   data = self._items
   if data.has_key(key):
   return None
   else:
   item = makeItem(key,self.FieldList)
   data[key] = item
   self.catalog_object(item)
   return data[key]
 #}}}
 
 where self._items is:
 
   self._items = OOBTree()
 
 
 and the makeItem-Class is:
 
 class makeItem(Item): #{{{
 
 AixtraTable Item class
 
 
 def __init__(self, key, fieldlist):
   self.id = key
   for f in fieldlist:
   setattr(self,f,)
 
 #}}}
 
 it only worked, when I inherited from Item, otherwise I could not access 
 the items from the web, my guess is, cause they had no acquisition 
 wrappers. Can I achieve the same with the __of__ magic and how ?
 
 you can download the product from 
 http://www.zope.org/Members/perry/AixtraTable
 
 
 
 
 Mit freundlichen Grüßen  Joachim Schmitz
 
 AixtraWare Ingenieurbüro für Internetanwendungen
 Hüsgenstr. 33a, D-52457 Aldenhoven
 Telefon: +49-2464-8851, FAX: +49-2464-905163
 
 Key fingerprint = DA10 CC82 62F8 1DBB 39A1  1EDC 725B 3317 A8D7 C3A6
 Keyserver: http://www.keyserver.net/en/
 
 ___
 Zope-Dev maillist  -  [EMAIL PROTECTED]
 http://lists.zope.org/mailman/listinfo/zope-dev
 **  No cross posts or HTML encoding!  **
 (Related lists -
  http://lists.zope.org/mailman/listinfo/zope-announce
  http://lists.zope.org/mailman/listinfo/zope )
 


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )