[Product-Developers] Aquiring objects with TAL

Andreas Jung lists at zopyx.com
Tue May 5 02:47:13 UTC 2009

On 05.05.09 03:09, Joe C wrote:
> Thanks for the help.  I think I am getting underway.  I did decide to use a
> class to build the alert as I need to look at the dates and type to decide
> what to display.  Plus I only want to display the "alerts" viewlet if there
> are valid alerts present.
> Here is how I acquired the portal object:
> from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
> from plone.app.layout.viewlets.common import ViewletBase
> from Products.CMFCore.utils import getToolByName
> class AlertViewlet(ViewletBase):
>      render = ViewPageTemplateFile('templates/alert.pt')
>      def update(self):
>         portal_url = getToolByName(self.context, "portal_url")
>         portal = portal_url.getPortalObject()
>         # Get the IDs of the objects in the alert folder
>         alertItems = portal.alerts.objectIds()
Using objectIds() (Zope API!) in the context of Plone programming is usually
not appropriate. Use getFolderContents() or perform a catalog search
by 'path'.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: lists.vcf
Type: text/x-vcard
Size: 316 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20090505/9d8048e1/attachment.vcf>

More information about the Product-Developers mailing list