Hi there, The subject says it all. Do I have to try to call objectValues within a try clause, or is there an other way. Robert
Try this: if object.isFolderish(): return "object is a folderish thang" If it doesn't work, I'm sure I saw a method with a name kindof like that, somewhere, once... urm... Chris
+-------[ Chris Withers ]---------------------- | Try this: | | if object.isFolderish(): | return "object is a folderish thang" | | If it doesn't work, I'm sure I saw a method with a name kindof like that, | somewhere, once... urm... if hasattr(object, isPrincipiaFolderish) and object.isPrincipiaFolderish: print "object is Folderish." -- Totally Holistic Enterprises Internet| | Andrew Milton The Internet (Aust) Pty Ltd | | ACN: 082 081 472 ABN: 83 082 081 472 | M:+61 416 022 411 | Carpe Daemon PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|
Andrew Kenneth Milton wrote:
if hasattr(object, isPrincipiaFolderish) and object.isPrincipiaFolderish: print "object is Folderish."
...or, more neatly: if getattr(object,'isPrincipiaFolderish',None): print "I'm folderish"
Thanks Chris, it seams to work also in the most primitive form: objectList = f.objectValues() for o in objectList: if (o.isFolderish()): print o.getId() , ' is folderish' else: .... ----- Original Message ----- From: "Chris Withers" <chrisw@nipltd.com> To: "Andrew Kenneth Milton" <akm@theinternet.com.au> Cc: "Robert Rottermann" <robert@redcor.ch>; <zope@zope.org> Sent: Wednesday, October 10, 2001 12:39 PM Subject: Re: [Zope] how can I ask an object whether it is folderish?
Andrew Kenneth Milton wrote:
if hasattr(object, isPrincipiaFolderish) and
object.isPrincipiaFolderish:
print "object is Folderish."
...or, more neatly:
if getattr(object,'isPrincipiaFolderish',None): print "I'm folderish"
_______________________________________________ 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 )
+-------[ Andrew Kenneth Milton ]---------------------- | +-------[ Chris Withers ]---------------------- | | Try this: | | | | if object.isFolderish(): | | return "object is a folderish thang" | | | | If it doesn't work, I'm sure I saw a method with a name kindof like that, | | somewhere, once... urm... | | if hasattr(object, isPrincipiaFolderish) and object.isPrincipiaFolderish: | print "object is Folderish." oops... if hasattr(object, 'isPrincipiaFolderish') and object.isPrincipiaFolderish: I'm not sure how this differs from using getattr() when Acquisition comes in though, but, this is the way it's done inside ObjectManager. I'm pretty sure getattr will trigger the Acquisition machinery, I don't know if hasattr does. Might be better to unwrap the object first before checking. -- Totally Holistic Enterprises Internet| | Andrew Milton The Internet (Aust) Pty Ltd | | ACN: 082 081 472 ABN: 83 082 081 472 | M:+61 416 022 411 | Carpe Daemon PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|
Andrew Kenneth Milton wrote:
I'm pretty sure getattr will trigger the Acquisition machinery, I don't know if hasattr does. Might be better to unwrap the object first before checking.
they both do :-S If you want to be very hostile, you could always do: if object.__dict__.get('isPrincipiaFolderish'): ...no acquisition there ;-) Probably slightly mroe friendly (adn possible in a PythonScript?) if getattr(aq_explicit(object),'isPrincipiaFolderish',None): cheers, Chris
Robert Rottermann wrote:
Hi there, The subject says it all. Do I have to try to call objectValues within a try clause, or is there an other way.
Most folderish things (particularly if they are descended from Folder) have a property of isPrincipiaFolderish. Used like: if objectname.isPrincipiaFolderish: #object is folderish Works for me... -- Jim Washington
Hi, You can use isPrincipiaFolderish. Ex.: <dtml-if isPrincipiaFolderish> ... <dtml-else> ... </dtml-if> Cheers. Robert Rottermann wrote:
Hi there, The subject says it all. Do I have to try to call objectValues within a try clause, or is there an other way.
Robert
_______________________________________________ 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 )
-- ------------------------------------------- João Neves joao@fabricadeideias.com Fabrica de Ideias SBS - Ed. Empire Center - bl. S - sala 508 cep 70070-904 - Brasilia - DF - Brazil tel: (61) 321 1357 fax: (61) 223 1712 -------------------------------------------
print object.isPrincipiaFolderish --- Robert Rottermann <robert@redcor.ch> wrote: > Hi there,
The subject says it all. Do I have to try to call objectValues within a try clause, or is there an other way.
Robert
_______________________________________________ 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 )
===== peter_bengtsson_temporary@yahoo.co.uk is a temporary address that I use to send until I get my email stuff together. You can always continue to send to my real address which is mail@peterbe.com ____________________________________________________________ Do You Yahoo!? Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk or your free @yahoo.ie address at http://mail.yahoo.ie
participants (6)
-
Andrew Kenneth Milton -
Chris Withers -
Jim Washington -
João Neves -
Peter Bengtsson -
Robert Rottermann