[Product-Developers] Aquiring objects with TAL
plonedev at chryst.net
Tue May 5 01:09:33 UTC 2009
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
render = ViewPageTemplateFile('templates/alert.pt')
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()
# Iterate over the alert object IDs and build the view
for alertItem in alertItems:
obj = getattr(portal.alerts, alertItem)
# Test the object for publish date/time, type, etc
# and build the HTML for the templete -> generatedText
self.alertText = generatedText
I don't know if this is the most efficient way to handle this, I am new to
both Plone and Python. This breaks the template paradigm used with TAL
since the template will be replaced by the generated HTML from the class.
Again thanks for pointing me in the right direction.
View this message in context: http://n2.nabble.com/Aquiring-objects-with-TAL-tp2771067p2790462.html
Sent from the Product Developers mailing list archive at Nabble.com.
More information about the Product-Developers