get a object using its id inside a pythong script
retObjs = [] """ this is very inefficient, but works ;( for award in context.assignedAwards: for objId in context.marketingAwards.objectIds(): if award==objId: retObjs.append(objId) """ for award in context.assignedAwards: if award in context.marketingAwards.objectIds(): retObjs.append(context.marketingAwards.award) #get a award Attribute Error.. how do i do this? #appears in DTML you would use teh _.getitem(objId) hack, where is getitem? return retObjs Question 1: how can i please do this efficiently? Question 2: why doesnt ObjectManager have a getObject(self, objectId) method on it? or am i overlooking something? Question 3: abit off topic-- are people generally happy w/ data centric ZClasses? some people scare me with their experiences, but it seems that purely data centric ZClasses (although can be brittle) -- are nonviolatile things. I am pushing ZOPE as a solution and am selling ZClasses very heavy -- nonprogrammers will be maintaing the system after its done. (service oriented objects - I would do in Python) thanks in advance, ~runyaga
On Sun, 13 May 2001, alan runyan wrote:
for award in context.assignedAwards: if award in context.marketingAwards.objectIds(): retObjs.append(context.marketingAwards.award) #get a award Attribute Error.. how do i do this? #appears in DTML you would use teh _.getitem(objId) hack, where is getitem?
Error beacuse retObjs.append(context.marketingAwards.award) is equivalent to retObjs.append(getattr(context.marketingAwards, "award")) and there is no "award" in Awards! So use <untested> retObjs.append(getattr(context.marketingAwards, award)) </untested>
Question 1: how can i please do this efficiently?
I suppose: awards = context.marketingAwards.objectIds() for award in context.assignedAwards: if award in awards: retObjs.append(getattr(context.marketingAwards, award))
Question 2: why doesnt ObjectManager have a getObject(self, objectId) method on it? or am i overlooking something?
I think you can just use getattr or context.marketingAwards[award]. Oleg. ---- Oleg Broytmann http://www.zope.org/Members/phd/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
participants (2)
-
alan runyan -
Oleg Broytmann