mozilla / django-piston Goto Github PK
View Code? Open in Web Editor NEWFork of Django Piston
Home Page: http://bitbucket.org/jespern/django-piston/
Fork of Django Piston
Home Page: http://bitbucket.org/jespern/django-piston/
When returning the challenge response and the 401 status, an exception is triggered.
Exception is triggered because HttpBasicAuthentication::challenge() is called with two params instead of one.
This small patch solved the issue
diff --git a/piston/authentication.py b/piston/authentication.py index a11e260..f1b814a 100644 --- a/piston/authentication.py +++ b/piston/authentication.py @@ -63,7 +63,7 @@ class HttpBasicAuthentication(object): return not request.user in (False, None, AnonymousUser()) - def challenge(self): + def challenge(self, request=None): resp = HttpResponse("Authorization Required") resp['WWW-Authenticate'] = 'Basic realm="%s"' % self.realm resp.status_code = 401
method signature has been copied from OAuthAuthentication class..
When i run my application with api, my comment model is giving error (from piston/emitters.py in _model, line 174), says that :
AttributeError at /api/comments/
'GenericForeignKey' object has no attribute 'attname'
my model is like this:
from django.db import models
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.generic import GenericForeignKey
class CommentManager(models.Manager):
def get_by_natural_key(self, username):
return self.get(username)
class Comment(models.Model):
owner = models.ForeignKey(User)
comment = models.CharField(max_length=2000)
target_object = GenericForeignKey('ctype', 'oid')
created_at = models.DateTimeField(auto_now_add=True)
ctype = models.ForeignKey(ContentType)
oid = models.PositiveIntegerField()
and my handler is like this :
class CommentHandler(BaseHandler):
allowed_methods = ("GET",)
model = Comment
def read(self, request):
return Comment.objects.all()
if you want, i can give additional information. Thanks for your response...
FYI: The following changes were made to this repository's wiki:
defacing spam has been removed
Restricting write access to contributors is strongly encouraged. Please make that change (documentation).
These were made as the result of a recent automated defacement of publically writeable wikis.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.