Commits

Mads Sülau Valstorp Jørgensen committed 93809bb

Moved has_model check to get_queryset. All CRUD methods use it anyway.

Comments (0)

Files changed (1)

piston/handler.py

         Can be used to limit the access to objects and other such 
         things.
         """
+        if not self.has_model():
+            raise NotImplementedError
+        
         return self.model.objects
     
     def exists(self, **kwargs):
-        if not self.has_model():
-            raise NotImplementedError
-        
         try:
             self.get_queryset(*args, **kwargs).get(**kwargs)
             return True
             return False
     
     def read(self, request, *args, **kwargs):
-        if not self.has_model():
-            raise NotImplementedError
-        
         return self.get_queryset(*args, **kwargs).filter(*args, **kwargs)
     
     def create(self, request, *args, **kwargs):
-        if not self.has_model():
-            raise NotImplementedError
-        
         attrs = self.flatten_dict(request.POST)
         
         try:
             return inst
     
     def update(self, request, *args, **kwargs):
-        if not self.has_model():
-            raise NotImplementedError
-        
         inst = self.get_queryset(*args, **kwargs).get(*args, **kwargs)
         print "must update instance", inst, "with", request.PUT
         
         return "I can't do this yet."
     
     def delete(self, request, *args, **kwargs):
-        if not self.has_model():
-            raise NotImplementedError
-        
         return "I can't do this yet."