Get an object by name from a folder
Hi, This has bugged me for a while. I know I can get ALL the items in a folder by using objectValues() or objectIds(). But how can I get an object in a folder quickly without having to go through every single item? I have an object named debug_dtml, it can appear in any folder or subfolder. How do I check whether it exists? The <dtml-with ... only> tag does not help much, because it does not allow me to access other variables when I have to render the debug_dtml method. The _.hasattr() function is no good because it assumes acquisition. I would like to disable acquisition for this purpose. What I would like are folder methods like: hasObject('object_id') getObject('object_id') But apparently this is impossible without writing a Python external method. regards, Hung Jung ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
You can use this: <dtml-if "('debug_html' in Folder.objectIds())"> but i think that can be other 'elegant' way to resolve. Hung Jung Lu wrote:
Hi,
This has bugged me for a while. I know I can get ALL the items in a folder by using objectValues() or objectIds(). But how can I get an object in a folder quickly without having to go through every single item?
I have an object named debug_dtml, it can appear in any folder or subfolder. How do I check whether it exists? The <dtml-with ... only> tag does not help much, because it does not allow me to access other variables when I have to render the debug_dtml method.
The _.hasattr() function is no good because it assumes acquisition. I would like to disable acquisition for this purpose.
What I would like are folder methods like:
hasObject('object_id') getObject('object_id')
But apparently this is impossible without writing a Python external method.
regards,
Hung Jung
______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
_______________________________________________ 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 )
-- ---------------------- Mauricio - Hiperlógica Automação de Web Sites mauricio@hiper.com.br www.hiper.com.br ----------------------
Ops: not html, it's dtml. sorry Zopers... Mauricio Souza Lima wrote:
You can use this:
<dtml-if "('debug_html' in Folder.objectIds())">
but i think that can be other 'elegant' way to resolve.
Hung Jung Lu wrote:
Hi,
This has bugged me for a while. I know I can get ALL the items in a folder by using objectValues() or objectIds(). But how can I get an object in a folder quickly without having to go through every single item?
I have an object named debug_dtml, it can appear in any folder or subfolder. How do I check whether it exists? The <dtml-with ... only> tag does not help much, because it does not allow me to access other variables when I have to render the debug_dtml method.
The _.hasattr() function is no good because it assumes acquisition. I would like to disable acquisition for this purpose.
What I would like are folder methods like:
hasObject('object_id') getObject('object_id')
But apparently this is impossible without writing a Python external method.
regards,
Hung Jung
______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
_______________________________________________ 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 )
-- ---------------------- Mauricio - Hiperlógica Automação de Web Sites mauricio@hiper.com.br www.hiper.com.br ----------------------
_______________________________________________ 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 )
-- ---------------------- Mauricio - Hiperlógica Automação de Web Sites mauricio@hiper.com.br www.hiper.com.br ----------------------
participants (2)
-
Hung Jung Lu -
Mauricio Souza Lima