Skip to content

Commit

Permalink
hold a reference to generated TTW view subclasses, to make sure they …
Browse files Browse the repository at this point in the history
…are not generated once per request. a workaround to mitigate http://dev.plone.org/plone/ticket/9218
  • Loading branch information
davisagli committed Apr 30, 2010
1 parent 94dfe3d commit cac0fdb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ CHANGES
1.0b1 - Unreleased
------------------

Fixed a memory leak by making sure that TTW view subclasses are only
generated once, rather than once per request.

Make sure TTW viewlet and portlet classes get the containing view as the
view parameter on initialization, rather than getting themselves.

Expand Down
24 changes: 18 additions & 6 deletions src/five/customerize/zpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ def _getView(self):
# that for TTW templates (which are trusted code) by
# creating a subclass with unrestricted access to all
# subobjects.
class TTWView(view_class):
__allow_access_to_unprotected_subobjects__ = 1
if hasattr(view_class, '_five_customerize_ttw_class'):
TTWView = view_class._five_customerize_ttw_class
else:
class TTWView(view_class):
__allow_access_to_unprotected_subobjects__ = 1
view_class._five_customerize_ttw_class = TTWView
self.view = TTWView(self.context, self.request)
return self.view

Expand Down Expand Up @@ -149,8 +153,12 @@ def _getViewlet(self):
# that for TTW templates (which are trusted code) by
# creating a subclass with unrestricted access to all
# subobjects.
class TTWViewlet(view_class, ViewletBase):
__allow_access_to_unprotected_subobjects__ = 1
if hasattr(view_class, '_five_customerize_ttw_class'):
TTWViewlet = view_class._five_customerize_ttw_class
else:
class TTWViewlet(view_class, ViewletBase):
__allow_access_to_unprotected_subobjects__ = 1
view_class._five_customerize_ttw_class = TTWViewlet
self.viewlet = TTWViewlet(self.context, self.request, self.view, self.manager)
return self.viewlet

Expand Down Expand Up @@ -206,8 +214,12 @@ def _getRenderer(self):
# that for TTW templates (which are trusted code) by
# creating a subclass with unrestricted access to all
# subobjects.
class TTWPortlet(view_class):
__allow_access_to_unprotected_subobjects__ = 1
if hasattr(view_class, '_five_customerize_ttw_class'):
TTWPortlet = view_class._five_customerize_ttw_class
else:
class TTWPortlet(view_class):
__allow_access_to_unprotected_subobjects__ = 1
view_class._five_customerize_ttw_class = TTWPortlet
self.renderer = TTWPortlet(self.context, self.request, self.view, self.manager, self.data)
return self.renderer

Expand Down

0 comments on commit cac0fdb

Please sign in to comment.