[Zope] Getting a specific object in Python from an id string (Was [Zope]: Python method for getting contents of a sub-folder)

complaw@hal-pc.org complaw@hal-pc.org
Tue, 21 Aug 2001 19:20:20 GMT


I have created a Python script, but I need to pass a parameter that is a string
of the id of the desired object.

python script "get_staff_info"
parameter list: oid # the id of the object that I want returned

The following code will get the (currently only) DTML document in the staff
folder:

return context.staff.objectValues('DTML Document')

The only question that I have is how do I get the object whose id=oid?

There ought to be a function that would return the object based the id (a string
that can be passed as a parameter that could/would be stored in another
object).  I know that there are objectItems(), objectIds, and objectValues(),
but I would have to iterate through the result and perform a comparison.  Is
that the only way to do it, or is there a handy API that will just cut to the
chase?

TIA,

Ron

> I want to (or simply think I should) use a python method to get information
> about an instance of one object in a first sub-folder from a DTML Method in a
> another sub-folder.  Graphically put,
> 
> Main_Folder
>   +-- Get_Contact_Info (Python method)
>   |
>   +-- First_Folder
>   |  +-- Contact_1 (DTML Document)
>   |
>   +-- Second_Folder
>      +-- index_html (DTML Method)
> 
> 
> >From index_html, I want to call the Get_Contact_Info method (through
acqusition)
> and have it return the absolute_url and title of the object(s) in the first
> folder (e.g., Contact_1).
> 
> The question I have is what little trick do I need to include in the
> Get_Contact_Info method to obtain the correct set of ObjectValues of the
objects
> in the First_Folder?
> 
> The nice thing about this methodology is that I don't have to worry how far
down
> the branches of the tree I am to get basic information from the "base" folder. 
> I simply use acqisition to call the method.
> 
> TIA,
> 
> Ron
> 
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> 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 )
>