Anonymous avatar Anonymous committed 5a189a7

Comments (0)

Files changed (4)

piston/emitters.py

         ret = dict()
             
         for field in fields:
-            if field in has:
+            if field in has and callable(field):
                 ret[field] = getattr(data, field)
         
         return ret
                                     
                 else:
                     get_fields = set(fields)
-                
-                get_fields_copy = copy.deepcopy(get_fields)
 
-                for reserved_field in ['read','update','delete','create']:
-                    get_fields_copy.discard(reserved_field)
-
-                met_fields = self.method_fields(handler, get_fields_copy)
+                met_fields = self.method_fields(handler, get_fields)
                 
                 for f in data._meta.local_fields:
                     if f.serialize and not any([ p in met_fields for p in [ f.attname, f.name ]]):

tests/test_project/apps/testapp/handlers.py

     def create(self, request):
         if request.content_type:
             data = request.data
-            em = self.model(read=data['read'], create=data['create'])
+            em = self.model(read=data['read'], model=data['model'])
             em.save()
             return rc.CREATED
         else:

tests/test_project/apps/testapp/models.py

 
 class Issue58Model(models.Model):
     read = models.BooleanField(default=False)
-    create = models.CharField(max_length=1, blank=True, null=True)
+    model = models.CharField(max_length=1, blank=True, null=True)
+    

tests/test_project/apps/testapp/tests.py

     it make piston crash with a `TypeError`
     """
     def init_delegate(self):
-        m1 = Issue58Model(read=True,create='t') 
+        m1 = Issue58Model(read=True,model='t') 
         m1.save()
-        m2 = Issue58Model(read=False,create='f')
+        m2 = Issue58Model(read=False,model='f')
         m2.save()
 
     def test_incoming_json(self):
-        outgoing = simplejson.dumps({ 'read': True, 'create': 'T'})
+        outgoing = simplejson.dumps({ 'read': True, 'model': 'T'})
 
         expected = """[
     {
         "read": true, 
-        "create": "t"
+        "model": "t"
     }, 
     {
         "read": false, 
-        "create": "f"
+        "model": "f"
     }
 ]"""
 
         # test POST
         resp = self.client.post('/api/issue58.json', outgoing, content_type='application/json',
                                 HTTP_AUTHORIZATION=self.auth_string)
-            
+        print resp.__dict__
         self.assertEquals(resp.status_code, 201)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.