Added method to extract viewlets
authorThierry Florac <thierry.florac@onf.fr>
Fri, 20 Mar 2015 17:17:20 +0100
changeset 1 1cbcb33e54a4
parent 0 b3d96ac70a99
child 2 842ab9ef3982
Added method to extract viewlets
src/pyams_viewlet/manager.py
--- a/src/pyams_viewlet/manager.py	Thu Feb 19 10:27:51 2015 +0100
+++ b/src/pyams_viewlet/manager.py	Fri Mar 20 17:17:20 2015 +0100
@@ -103,12 +103,7 @@
         if self.permission and not self.request.has_permission(self.permission):
             return
         # Find all content providers for the region
-        registry = self.request.registry
-        viewlets = registry.getAdapters((self.context, self.request, self.__parent__, self),
-                                        IViewlet)
-
-        viewlets = self.filter(viewlets)
-        viewlets = self.sort(viewlets)
+        viewlets = self._get_viewlets()
         # Just use the viewlets from now on
         self.viewlets = []
         for name, viewlet in viewlets:
@@ -117,6 +112,15 @@
             self.viewlets.append(viewlet)
         self._update_viewlets()
 
+    def _get_viewlets(self):
+        """Find all content providers for the region"""
+        registry = self.request.registry
+        viewlets = registry.getAdapters((self.context, self.request, self.__parent__, self),
+                                        IViewlet)
+        viewlets = self.filter(viewlets)
+        viewlets = self.sort(viewlets)
+        return viewlets
+
     def _update_viewlets(self):
         """Calls update on all viewlets and fires events"""
         registry = self.request.registry