I have a Customer and Address ZClasses based on Dataskin as well as a CustomerManager specialist. The Customer ZClass has a external method setAddress: def setAddress(self, Address) self.Address = Address CustomerManager has a defaultRack and addressRack. The methods that adds the instance contains this: <dtml-let newCustomer="newItem(name)"> <dtml-call "newCustomer.propertysheets.Basic.manage_changeProperties(test=test)"> <dtml-let address="addressRack.newItem(id)"> <dtml-call "address.propertysheets.basic.manage_changeProperties(test=test)"> <dtml-call "newCustomer.setAddress(address)"> </dtml-let> </dtml-let> and it seems to work fine. Then to retrieve the Customer addresses I call: <addressRack.getPersistentItemIDs()"> but there seems to be a problem with permissions because Zope prompts me for username and password although i'm already working in the management interface. Roché
Hi Roche, This is a known problem. Use: <dtml-let itemIDs="[]"> <dtml-in "addressRack.getPersistentItemIDs()" sort> <dmtl-call "itemIDs.append(_['sequence-item'])"> </dtml-in> Now you have the required itemIDs in itemIDs. </dtml-in> -steve
"Roch'e" == Roch'e Compaan <roche@ybm.co.za> writes:
Roch'e> I have a Customer and Address ZClasses based on Dataskin Roch'e> as well as a CustomerManager specialist. Roch'e> The Customer ZClass has a external method setAddress: Roch'e> def setAddress(self, Address) self.Address = Address Roch'e> CustomerManager has a defaultRack and addressRack. The Roch'e> methods that adds the instance contains this: Roch'e> <dtml-let newCustomer="newItem(name)"> <dtml-call Roch'e> "newCustomer.propertysheets.Basic.manage_changeProperties(test=test)"> Roch'e> <dtml-let address="addressRack.newItem(id)"> <dtml-call Roch'e> "address.propertysheets.basic.manage_changeProperties(test=test)"> Roch'e> <dtml-call "newCustomer.setAddress(address)"> </dtml-let> Roch'e> </dtml-let> Roch'e> and it seems to work fine. Roch'e> Then to retrieve the Customer addresses I call: Roch'e> <addressRack.getPersistentItemIDs()"> Roch'e> but there seems to be a problem with permissions because Roch'e> Zope prompts me for username and password although i'm Roch'e> already working in the management interface. Roch'e> Roché Roch'e> _______________________________________________ Zope-Dev Roch'e> maillist - Zope-Dev@zope.org Roch'e> http://lists.zope.org/mailman/listinfo/zope-dev ** No Roch'e> cross posts or HTML encoding! ** (Related lists - Roch'e> http://lists.zope.org/mailman/listinfo/zope-announce Roch'e> http://lists.zope.org/mailman/listinfo/zope )
This is a known problem. Use:
<dtml-let itemIDs="[]"> <dtml-in "addressRack.getPersistentItemIDs()" sort> <dmtl-call "itemIDs.append(_['sequence-item'])"> </dtml-in>
Now you have the required itemIDs in itemIDs.
</dtml-in>
Thanks Steve and thank you Phillip for ZPatterns. I've managed to create a very basic framework storing attributes in the ZODB and in a SQL RDBMS. I'm elated. This is the way to write applications, IMHO. A couple of things are still unclear but I at least feel that I can create now. Roché
Steve Spicklemire wrote:
This is a known problem. Use:
<dtml-let itemIDs="[]"> <dtml-in "addressRack.getPersistentItemIDs()" sort> <dmtl-call "itemIDs.append(_['sequence-item'])"> </dtml-in>
Hmmm... that's not very nice, has the bug in getPersistentItemIDs() been fixed? cheers, Chris
Hi Chris, It looks like it's a non-bug, more just an annoyance. Here's my current feeling. In most 'real' situations you'll end up with a ZCatalog, or possibly a totally virtual ZClass with some sort of dynamic (SQL? LDAP? etc.. ) data source where the ids you're after will be queried for. My own practice at this point is to define methods at the rack level like: getAllItemIds, getRejectedItemIds, getCurrentItemIds and so on. These can then be implemented in a way that matches the actual data storage. *If* the data is stored persistently, and *if* you are implementing 'getAllItemsIds' and *if* you don't have a handy ZCatalog around to query, then you can use the hack I sent Roche. ;-) Otherwise there are better ways to do it anyway. The reason it's a probem is that getPersistentItemIDs() returns a BTree object, that isn't allowed to be exposed directly by the security machinery. However, 'sort' short-curcuits the machinery so that you can 'handle' them (in this hack, you store them in a simple python list....). Anyway.. it's not clear it's a bug worth fixing... if it's a bug at all. -steve
"Chris" == Chris Withers <chrisw@nipltd.com> writes:
Chris> Steve Spicklemire wrote: >> This is a known problem. Use: >> >> <dtml-let itemIDs="[]"> <dtml-in >> "addressRack.getPersistentItemIDs()" sort> <dmtl-call >> "itemIDs.append(_['sequence-item'])"> </dtml-in> Chris> Hmmm... that's not very nice, has the bug in Chris> getPersistentItemIDs() been fixed? Chris> cheers, Chris> Chris
participants (3)
-
Chris Withers -
Roch'e Compaan -
Steve Spicklemire