Commits

Anonymous committed 89fa5aa

pep8 and request is now required arg for GridPylons

  • Participants
  • Parent commits 67499c8

Comments (0)

Files changed (1)

webhelpers/pylonslib/grid.py

 
 class GridPylons(grid.Grid):
     
+    def __init__(self, request, *args, **kw):
+        self.request = request
+        super(GridPylons, self).__init__(*args, **kw)
+    
     def generate_header_link(self, column_number, column, label_text):
         from pylons import url
         # this will handle possible URL generation
-        if not hasattr(self, "request"):
-            raise NoRequestError(
-                "Could not find self.request for this grid")
         request_copy = self.request.copy().GET
         if "order_col" in request_copy and "order_dir" in request_copy:
             self.order_column = request_copy.pop("order_col")
         else:
             new_order_dir = "asc"
         
-        url_href = url.current(order_col=column, order_dir=new_order_dir, **request_copy)        
+        url_href = url.current(order_col=column, order_dir=new_order_dir,
+                               **request_copy)
         label_text = HTML.tag("a", href=url_href, c=label_text)
         # Is the current column the one we're ordering on?
         if (column == self.order_column):
-            return self.default_header_ordered_column_format(column_number, self.order_dir,
+            return self.default_header_ordered_column_format(column_number,
+                                                             self.order_dir,
                                                              column, label_text)
         else:
-            return self.default_header_column_format(column_number, column, label_text)
+            return self.default_header_column_format(column_number, column,
+                                                     label_text)