[Zope-dev] Is there a function to get the object type?

Takahashi, Michael MTakahashi at oid.ucla.edu
Mon Apr 10 19:59:53 EDT 2006


Thank you to everyone who helped. I've found the answer. In my case, the
key was to use 'isPrincipiaFolderish'

So to run a check to see if something is a folder:

if context.isPrincipiaFolderish:
    print "It's a folder!"
else:
    print "Nope, it's not a folder."


Mike



-----Original Message-----
From: zope-dev-bounces+mtakahashi=oid.ucla.edu at zope.org
[mailto:zope-dev-bounces+mtakahashi=oid.ucla.edu at zope.org] On Behalf Of
Paul Winkler
Sent: Monday, April 10, 2006 4:43 PM
To: zope-dev at zope.org
Subject: Re: [Zope-dev] Is there a function to get the object type?

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
_______________________________________________
Zope-Dev maillist  -  Zope-Dev at zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


More information about the Zope-Dev mailing list