Hi I'm new to zope, and I can't figure out how to check if an object (with a spesific name) exists in the current folder. Any help? -- / hans - http://go.to/tusenfrydveien32 / http://www.spacetec.no/~hans/dfood.htm /--------------------------------------------- / HANS = High Availability No Superman
if anId in folder.objectIds():
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Hans Sandsdalen Sent: Wednesday, July 31, 2002 2:41 PM To: zope@zope.org Subject: [Zope] Test if an object exists in a folder
Hi
I'm new to zope, and I can't figure out how to check if an object (with a spesific name) exists in the current folder.
Any help?
-- / hans - http://go.to/tusenfrydveien32 / http://www.spacetec.no/~hans/dfood.htm /--------------------------------------------- / HANS = High Availability No Superman
_______________________________________________ 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 )
Hans Sandsdalen wrote:
I'm new to zope, and I can't figure out how to check if an object (with a spesific name) exists in the current folder.
It kind of depends on where you want to check from. dtml, Python Script, Python product/external method or what have you. dtml: <dtml-if someObj> <dtml-var showStuff> </dtml-if> Python: if self.someFolder.has_key('someObj'): showStuff() regards Max M -- "Sorry I would Really Like To Help More On This Project, But Am To Busy Doing Paid Work On A Tight Deadline" Max M
Hi I want to use dtml. I tried these to check if content_html exists: 1: <dtml-if expr="_.has_key('content_html')"> Action! <dtml-else> Does not exist </dtml-if> 2: <dtml-in expr="objectValues()"> <dtml-var getId><br> <dtml-if expr="getId() == 'content_html'"> Action! </dtml-if> </dtml-in> I'm not sure of the syntax of expr in the first example. The second one works, but it seems a like overkill to me. And how do I now later that I found it? The dtml code below is not what I want, because it returns true when a parent object has "content_html". On Wed, 2002-07-31 at 15:05, Max M wrote:
Hans Sandsdalen wrote:
I'm new to zope, and I can't figure out how to check if an object (with a spesific name) exists in the current folder.
It kind of depends on where you want to check from. dtml, Python Script, Python product/external method or what have you.
dtml: <dtml-if someObj> <dtml-var showStuff> </dtml-if>
Python: if self.someFolder.has_key('someObj'): showStuff()
regards Max M
--
"Sorry I would Really Like To Help More On This Project, But Am To Busy Doing Paid Work On A Tight Deadline" Max M
-- / hans - http://go.to/tusenfrydveien32 / http://www.spacetec.no/~hans/dfood.htm /--------------------------------------------- / HANS = High Availability No Superman
Hans Sandsdalen wrote:
I tried these to check if content_html exists:
1: <dtml-if expr="_.has_key('content_html')"> Action! <dtml-else> Does not exist </dtml-if>
2: <dtml-in expr="objectValues()"> <dtml-var getId><br> <dtml-if expr="getId() == 'content_html'"> Action! </dtml-if> </dtml-in>
I'm not sure of the syntax of expr in the first example.
The second one works, but it seems a like overkill to me. And how do I now later that I found it?
what about: <dtml-if content_html> Action! <dtml-else> Doews not exist </dtml-if> or if it is without aquisition. <dtml-if "aq_base.content_html()"> Action! <dtml-else> Doews not exist </dtml-if> regards Max M -- "Sorry I would Really Like To Help More On This Project, But Am To Busy Doing Paid Work On A Tight Deadline" Max M
Max M writes:
... <dtml-if "aq_base.content_html()"> This will not work:
"aq_base" is not available in TTW code. The code above would raise an exception, when "content_html" is not an attribute of "aq_base". You come near (but it may fail in some circumstances) with <dtml-if "_.hasattr(aq_explicit,'content_html')"> Dieter
Hans Sandsdalen writes:
I'm new to zope, and I can't figure out how to check if an object (with a spesific name) exists in the current folder. Search the mailing list archives for "aq_explicit" and "aq_base".
Dieter
participants (4)
-
Dieter Maurer -
douwe@oberon.nl -
Hans Sandsdalen -
Max M