Commit cb7a90a5 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_rss_style: Use cache on Ticket_getLastEvent

   This script is widely used accross the listboxes, this makes things quite slow.

   Set 5min cache also prevent abuse of call the feed
parent c53add92
from Products.ERP5Type.Cache import CachingMethod
portal = context.getPortalObject()
def getLastEventRelativeUrl(uid):
portal = context.getPortalObject()
last_event = portal.portal_catalog.getResultValue(
follow_up_uid=context.getUid(),
portal_type=portal.getPortalEventTypeList(),
simulation_state=["confirmed", "started", "stopped", "delivered"],
sort_on=(("modification_date", 'DESC'),))
if last_event is not None:
return last_event.getRelativeUrl()
else:
return last_event
last_event_url = CachingMethod(getLastEventRelativeUrl,
id='Ticket_getLatestEventRelativeUrl',
cache_factory='erp5_content_short')(context.getUid())
if last_event_url is not None:
return portal.restrictedTraverse(last_event_url)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Ticket_getLatestEvent</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject() event = context.Ticket_getLastEvent()
event = portal.portal_catalog.getResultValue(
follow_up_uid=context.getUid(),
sort_on=[('modification_date', 'DESC')],
)
if event: if event:
return event.getModificationDate() return event.getModificationDate()
......
portal = context.getPortalObject() event = context.Ticket_getLastEvent()
event = portal.portal_catalog.getResultValue(
follow_up_uid=context.getUid(),
sort_on=[('modification_date', 'DESC')],
)
if event: if event:
return event.getTextContent() return event.getTextContent()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment