[Zope] adding Link objects to Plone folders programmatically
J Cameron Cooper
jccooper at jcameroncooper.com
Tue Aug 19 21:20:52 EDT 2003
> Hi folks, I'm fairly new to Zope and Python so this is probably a
> completely obvious one for most of you but I'd really appreciate any
> help you can give me on how to do this. I'm trying to add CMF Link
> instances to Plone folders using a script. The intention is to
> provide crosslinking of articles at several places through out the
> site to be determined at their creation time.
>
> Attempts to call the addLink method directly without importing the
> Link Class produces complaints about attempting to use an undefined
> global so I attempted to import the Link class using
>
> from Products.CMFDefault import Link
>
> but it produces an error of
>
> Error Type : ImportError
> Error Value : import of "Link" from "Products.CMFDefault" is
> unauthorized. You are not allowed to access Link in this context
>
>
> Does the Link class need to be imported to create a Link instance in a
> Python script? Is addLink even the appropriate method to be calling
> to do this or am I barking up the wrong tree here? Am I just a lost
> Java programmer falling on his face making the jump to the Python wagon?
CMF provides a factory mechanism for creation of content types. On a
PortalFolder (or descendants, like PloneFolder) you can use
'invokeFactory' instead of trying to do it all yourself. (Plus you can
interact with the type machinery, which is good.)
--jcc
More information about the Zope
mailing list