web/views/basetemplates.py
changeset 9378 4a668dcfa0a0
parent 9176 8139f82c8bbe
child 9709 d60dc7e03a45
--- a/web/views/basetemplates.py	Wed Jan 08 14:00:31 2014 +0100
+++ b/web/views/basetemplates.py	Mon Nov 04 16:06:06 2013 +0100
@@ -86,6 +86,11 @@
 
 
 @objectify_predicate
+def modal_view(cls, req, rset, *args, **kwargs):
+    if req.form.get('__modal', None):
+        return 1
+
+@objectify_predicate
 def templatable_view(cls, req, rset, *args, **kwargs):
     view = kwargs.pop('view', None)
     if view is None:
@@ -118,6 +123,17 @@
         self._stream = view._stream
 
 
+class ModalMainTemplate(MainTemplate):
+    """ a no-decoration main template for standard views
+    that typically live in a modal context """
+    __regid__ = 'main-template'
+    __select__ = templatable_view() & modal_view()
+
+    def call(self, view):
+        view.set_request_content_type()
+        view.render(w=self.w)
+
+
 class TheMainTemplate(MainTemplate):
     """default main template :