Commits

Anonymous committed 27e26e2

modify the emmitters to not recycle request

Comments (0)

Files changed (2)

piston/emitters.py

                             'delete', 'model', 'anonymous',
                             'allowed_methods', 'fields', 'exclude' ])
 
-    def __init__(self, payload, typemapper, handler, fields=(), anonymous=True, request=None):
+    def __init__(self, payload, typemapper, handler, fields=(), anonymous=True):
         self.typemapper = typemapper
         self.data = payload
         self.handler = handler
         self.fields = fields
         self.anonymous = anonymous
-        self.request = request
 
         if isinstance(self.data, Exception):
             raise
 
         return ret
 
-    def construct(self):
+    def construct(self, request):
         """
         Recursively serialize a lot of types, and
         in cases where it doesn't recognize the type,
                                 if len(inspect.getargspec(inst)[0]) == 1:
                                     ret[model] = _any(inst(), fields)
                                 else:
-                                    ret[model] = _any(inst(data, self.request), fields)
+                                    ret[model] = _any(inst(data, request), fields)
                             else:
                                 ret[model] = _model(inst, fields)
 
                         
                         # support legacy classmethods (don't ask for request)
                         if len(inspect.getargspec(met_fields[maybe_field])[0]) > 2:
-                            args.append(self.request)
+                            args.append(request)
                         
                         ret[maybe_field] = _any(met_fields[maybe_field](*args))
 
                                 if len(inspect.getargspec(maybe)[0]) <= 1:
                                     ret[maybe_field] = _any(maybe())
                                 else:
-                                    ret[maybe_field] = _any(maybe(self.request))
+                                    ret[maybe_field] = _any(maybe(request))
                             else:
                                 ret[maybe_field] = _any(maybe)
 
     """
     def render(self, request):
         cb = request.GET.get('callback', None)
-        seria = simplejson.dumps(self.construct(), cls=DateTimeAwareJSONEncoder, ensure_ascii=False, indent=4)
+        seria = simplejson.dumps(self.construct(request), cls=DateTimeAwareJSONEncoder, ensure_ascii=False, indent=4)
 
         # Callback
         if cb and is_valid_jsonp_callback_value(cb):
 
 setup(
     name = "django-piston",
-    version = "0.2.3rc1.1.2",
+    version = "0.2.3rc1.1.3",
     url = 'http://bitbucket.org/jespern/django-piston/wiki/Home',
     download_url = 'http://bitbucket.org/jespern/django-piston/downloads/',
     license = 'BSD',