aboutsummaryrefslogtreecommitdiffstats
path: root/flywheel
diff options
context:
space:
mode:
Diffstat (limited to 'flywheel')
-rw-r--r--flywheel/emitters.py5
-rw-r--r--flywheel/modelresource.py15
-rw-r--r--flywheel/templates/emitter.html2
-rw-r--r--flywheel/utils.py1
4 files changed, 15 insertions, 8 deletions
diff --git a/flywheel/emitters.py b/flywheel/emitters.py
index 57e95ec2..f548e1d9 100644
--- a/flywheel/emitters.py
+++ b/flywheel/emitters.py
@@ -83,16 +83,15 @@ class DocumentingTemplateEmitter(BaseEmitter):
provide a form that can be used to submit arbitrary content."""
# Get the form instance if we have one bound to the input
form_instance = resource.form_instance
- print form_instance
# Otherwise if this isn't an error response
# then attempt to get a form bound to the response object
if not form_instance and resource.response.has_content_body:
try:
form_instance = resource.get_form(resource.response.raw_content)
+ if form_instance:
+ form_instance.is_valid()
except:
- pass
- if form_instance and not form_instance.is_valid():
form_instance = None
# If we still don't have a form instance then try to get an unbound form
diff --git a/flywheel/modelresource.py b/flywheel/modelresource.py
index 7e9c5655..d68ec79e 100644
--- a/flywheel/modelresource.py
+++ b/flywheel/modelresource.py
@@ -1,5 +1,3 @@
-"""TODO: docs
-"""
from django.forms import ModelForm
from django.db.models.query import QuerySet
from django.db.models import Model
@@ -379,9 +377,20 @@ class ModelResource(Resource):
return
+class RootModelResource(ModelResource):
+ """A Resource which provides default operations for list and create."""
+ allowed_methods = ('GET', 'POST')
+ queryset = None
+
+ def get(self, request, *args, **kwargs):
+ queryset = self.queryset if self.queryset else self.model.objects.all()
+ return queryset
+
class QueryModelResource(ModelResource):
- allowed_methods = ('read',)
+ """Resource with default operations for list.
+ TODO: provide filter/order/num_results/paging, and a create operation to create queries."""
+ allowed_methods = ('GET',)
queryset = None
def get_form(self, data=None):
diff --git a/flywheel/templates/emitter.html b/flywheel/templates/emitter.html
index 4b0a7ce9..d21350cd 100644
--- a/flywheel/templates/emitter.html
+++ b/flywheel/templates/emitter.html
@@ -23,7 +23,7 @@
</head>
<body>
<div class='header'>
- <span class='api'><a href='http://www.thewebhaswon.com/flywheel/'>FlyWheel API</a></span>
+ <span class='api'><a href='http://django-rest-framework.org'>Django REST framework</a></span>
<span class='auth'>{% if user.is_active %}Welcome, {{ user }}.{% if logout_url %} <a href='{{ logout_url }}'>Log out</a>{% endif %}{% else %}Not logged in {% if login_url %}<a href='{{ login_url }}'>Log in</a>{% endif %}{% endif %}</span>
</div>
<div class='content'>
diff --git a/flywheel/utils.py b/flywheel/utils.py
index c0386871..f9bbc0fe 100644
--- a/flywheel/utils.py
+++ b/flywheel/utils.py
@@ -125,7 +125,6 @@ class XML2Dict(object):
"""
result = re.compile("\{(.*)\}(.*)").search(tag)
if result:
- print tag
value.namespace, tag = result.groups()
return (tag, value)