Commits

Andriy Kornatskyy committed 0f1f22c

Dropped widgets support, use html widgets preprocessors instead.

  • Participants
  • Parent commits 984aa67

Comments (0)

Files changed (2)

File src/wheezy/web/handlers/base.py

     # region: routing
 
     def path_for(self, name, **kwargs):
-        route_args = dict(self.route_args)
-        route_args.update(kwargs)
         return self.request.root_path + self.options['path_for'](
-                name, **route_args)
+                name, **dict(self.route_args, **kwargs))
 
     def absolute_url_for(self, name, **kwargs):
         parts = self.request.urlparts
                 model, values or self.request.form, self.errors,
                 self.translations['validation'])
 
-    # region: widgets
-
-    def widgets(self, **kwargs):
-        errors = self.errors
-        return [(name, widget(kwargs[name], errors))
-                    for name in kwargs]
-
     # region: templates
 
     @attribute
             'xsrf': self.xsrf_widget
         }
 
-    def render_template(self, template_name, widgets=None, **kwargs):
-        data = self.helpers
-        if kwargs:
-            data.update(kwargs)
-        if widgets:
-            data.update(widgets)
-        return self.options['render_template'](template_name, **data)
+    def render_template(self, template_name, **kwargs):
+        return self.options['render_template'](
+                template_name, dict(self.helpers, **kwargs))
 
-    def render_response(self, template_name, widgets=None, **kwargs):
+    def render_response(self, template_name, **kwargs):
         options = self.options
         response = HTTPResponse(options['CONTENT_TYPE'], options['ENCODING'])
-        response.write(self.render_template(
-            template_name,
-            widgets,
-            **kwargs))
+        response.write(options['render_template'](
+                template_name, dict(self.helpers, **kwargs)))
         return response
 
     # region: json

File src/wheezy/web/handlers/tests/test_base.py

     def test_render_template_with_kwargs(self):
         """ render_template with optional data arguments.
         """
-        def render_template(template_name, **data):
+        def render_template(template_name, data):
             assert 'signin.html' == template_name
             assert 10 == data['test']
             return 'html'
         assert 'html' == self.handler.render_template(
                 'signin.html', test=10)
 
-    def test_render_template_with_widgets(self):
-        """ render_template with optional widget argument.
-        """
-        def render_template(template_name, **data):
-            from wheezy.html.factory import WidgetFactory
-            assert 'signin.html' == template_name
-            widget = data['test']
-            assert isinstance(widget, WidgetFactory)
-            assert 10 == widget.model
-            return 'html'
-        self.options['render_template'] = render_template
-        assert 'html' == self.handler.render_template(
-                'signin.html', widgets=self.handler.widgets(test=10))
-
     def test_render_response(self):
         """ render_response.
         """