Is there a function to get the object type?
Hi guys, I'm trying to write a function that checks to see if the current object is a 'Folder'. I am using this tutorial as a reference: http://plone.org/documentation/how-to/pre-populated-folder To create a new content object, the following command is used: parent.invokeFactory(id=id, type_name='Folder') Is there a function that can check what type this newly created object is? Obviously its 'Folder' in this example, but I'd like to be able to get the type_name of an object returned anywhere in my site to see if it is a 'Folder'. Thanks, Mike
On Mon, Apr 10, 2006 at 03:46:41PM -0700, Takahashi, Michael wrote:
Hi guys,
I'm trying to write a function that checks to see if the current object is a 'Folder'.
I am using this tutorial as a reference:
http://plone.org/documentation/how-to/pre-populated-folder
To create a new content object, the following command is used:
parent.invokeFactory(id=id, type_name='Folder')
Is there a function that can check what type this newly created object is? Obviously its 'Folder' in this example, but I'd like to be able to get the type_name of an object returned anywhere in my site to see if it is a 'Folder'.
This is really a CMF question and belongs on the zope-cmf mailing list; invokeFactory() is a method of CMFCore.PortalFolder. But to answer your question: someobject.portal_type -PW -- Paul Winkler http://www.slinkp.com
On 4/11/06, Takahashi, Michael <MTakahashi@oid.ucla.edu> wrote:
I'm trying to write a function that checks to see if the current object is a 'Folder'.
several ways: isinstance(object, Folder) # does not work in python scripts or object.meta_type == "Folder" # does work in python scripts or object.portal_type == "Folder" # if it's a CMF object. or also: if getattr(object, 'objectIds', None) is not None: This doesn't check if it is a Folder, but if it implements an object manager type interface, which may or may not be what you want. :) Oh, and zope-dev is for development of Zope, not with zope. You should ask in zope@zope.org. -- Lennart Regebro, Nuxeo http://www.nuxeo.com/ CPS Content Management http://www.cps-project.org/
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Lennart Regebro wrote:
On 4/11/06, Takahashi, Michael <MTakahashi@oid.ucla.edu> wrote:
I'm trying to write a function that checks to see if the current object is a 'Folder'.
several ways:
isinstance(object, Folder) # does not work in python scripts\
Don't forget 'sametype' inside PythonScripts: sametype(object, another_object) Tres. - -- =================================================================== Tres Seaver +1 202-558-7113 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFEPU53+gerLs4ltQ4RAvv2AJ9w0rChvG53Kx3SuUPAl7kArPOZwACgkJ6Z EMIfMgEoFlDF6WJXGgeR9Lk= =XOO2 -----END PGP SIGNATURE-----
Tres Seaver wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Lennart Regebro wrote:
On 4/11/06, Takahashi, Michael <MTakahashi@oid.ucla.edu> wrote:
I'm trying to write a function that checks to see if the current object is a 'Folder'.
several ways:
isinstance(object, Folder) # does not work in python scripts\
Don't forget 'sametype' inside PythonScripts:
sametype(object, another_object)
You mean same_type ;) -- Thank you and Cheers, Suresh V. CTO, ParTecs, Bangalore http://www.partecs.com Plone-Zope-Python Consulting
participants (5)
-
Lennart Regebro -
Paul Winkler -
suresh -
Takahashi, Michael -
Tres Seaver