Re: [Zope] Getting an object from it's id

2001-01-23 Thread Geoff Armstrong

on 1/23/01 1:39 PM, Max Møller Rasmussen at [EMAIL PROTECTED] wrote:

Thanks. That's great; but you do need to know the objects immediate
container right? I have one situation where the container could be one of
many.


Geoff

> From: Geoff Armstrong [mailto:[EMAIL PROTECTED]]
> 
>> In DTML there doesn't seem to be a way of saying, "I have this string with
>> the name of an object, now fetch me the object."
> 
> Shure there is:
> 
> 
> 
> As far as I remember.
> 
> regards Max M
> 
> A snippet I use somewhere:
> 
> 
> 
> 
> 


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




Re: [Zope] Getting an object from it's id

2001-01-23 Thread Geoff Armstrong

on 1/23/01 1:20 PM, Ivan Cornell at [EMAIL PROTECTED] wrote:


Hi Ivan,

Thanks. The "_.getitem(myId)" works well. I've made a note of the "hasattr"
trick as well for future reference.


Geoff
> Geoff Armstrong wrote:
> 
>> What I'm trying to do here is avoid using > put the object in the namespace it has to iterate over all of them (there
>> could be any number).
>> 
>> All I have at the beginning is the name of the object in the REQUEST part of
>> the namespace as picked up from a form. My method is the action to that
>> form.
>> 
>> In DTML there doesn't seem to be a way of saying, "I have this string with
>> the name of an object, now fetch me the object."
>> 
> 
> Hi Geoff,
> 
> Try using _.getitem(), as in:
> 
> ...  ...
> 
> or probably:
> 
> 
> If you aren't sure of the existance of the object, wrap the above in:
> 
> 
> 
> Ivan
> 
> 
> ___
> Zope maillist  -  [EMAIL PROTECTED]
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )


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




Re: [Zope] Getting an object from it's id

2001-01-23 Thread Geoff Armstrong

on 1/23/01 1:12 PM, Erik Enge at [EMAIL PROTECTED] wrote:

Thanks; but being new to this could you help me a bit more by providing an
example of how to use 'getOb' within  [[EMAIL PROTECTED]]
> 
> | Is there a Zope API method that will allow me to get an object from
> | it's id, or can I write a simple Python method to do it, or am I
> | missing something even more obvious?
> 
> Well, sometimes objectItems or objectValues can be the right ones to
> use.  Other times, (in Python Products at least) you use _getOb() to
> fetch the object for you.
> 
> Let's say you have this object structure:
> 
> /Folder1
> /Folder2
> 
> If you (in Python code) have Folder1 in the namespace, as self for
> example, you can say object=self._getOb('Folder2'), and vòila. :)
> Don't know how you would do that in DTML, though.
> 
> ___
> Zope maillist  -  [EMAIL PROTECTED]
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )


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




Re: [Zope] Getting an object from it's id

2001-01-23 Thread Geoff Armstrong

on 1/23/01 12:34 PM, Oleg Broytmann at [EMAIL PROTECTED] wrote:

> On Tue, 23 Jan 2001, Gale wrote:
>> 
>> 

What I'm trying to do here is avoid using  
> You don't need to "get" the object, as the object is already on top of
> the namespace stack (dtml-in put the object there on every iteration). Just
> use the object's attributes (id, after all, is just yet another attribute).
> 
> Oleg.
> 
> Oleg Broytmann http://www.zope.org/Members/phd/ [EMAIL PROTECTED]
> Programmers don't die, they just GOSUB without RETURN.


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