I've made some progress... but I always get an error 401 at the server.

This is my code, please help me!!! I've lost some hours trying to do it
work:

urls.py
-------
*from django.conf.urls.defaults import **
*from piston.resource import Resource*
*from piston.authentication import HttpBasicAuthentication*
*from piston.doc import documentation_view*
*
*
*from test.api.handlers import NetworkingHandler*
*
*
*auth = HttpBasicAuthentication(realm='Lukkom API')*
*
*
*networking = Resource(handler=NetworkingHandler, authentication=auth)*
*
*
*urlpatterns = patterns('',*
*    url(r'^users/$', networking),*
*    url(r'^users/(?P<emitter_format>.+)/$', networking),*
*    url(r'^users\.(?P<emitter_format>.+)', networking, name='networking'),*
*
*
*    # automated documentation*
*    url(r'^$', documentation_view),*
*)*

handler.py
----------
*from piston.handler import BaseHandler, AnonymousBaseHandler*
*from piston.utils import rc, require_mime, require_extended*
*from django.contrib.auth.models import User*
*
*
*class NetworkingHandler(BaseHandler):*
*    model = User*
*    fields = ('id', 'email')*
*
*
*    @classmethod*
*    def resource_uri(cls, networking):*
*        return ('networking', ['json', ])*
*
*
*    def test(self, id):*
*        if id:*
*            return User.objects.get(pk=id)*
*        return User.objects.all()*

test.html
---------
*<script type="text/javascript" src="
http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js";></script>*
*
*
*<script type="text/javascript">*
*var key = "cm9vdDp0b29y";*
*
*
*$(function() {*
*    var dict = {*
*        url: "http://127.0.0.1:1024/api/users.json",*
*        beforeSend: function(request) {*
*            request.setRequestHeader('Authorization', 'Base ' + key);*
*        },*
*        sucess: function(json, textStatus) { $.each(json, sucess_callback)
},*
*        dataType: "json"*
*    };*
*
*
*    $.ajax(dict);*
*});*
*
*
*function test() {*
*    send_dict = {*
*        url: "http://127.0.0.1:1024/api/users.json",*
*        type: "GET",*
*        data: "id=1",*
*        processData: false,*
*        dataType: "json",*
*        beforeSend: function(request) {*
*            request.setRequestHeader('Authorization', 'Base ' + key);*
*        },*
*        success: function(json, textStatus) {
document.getElementById("body").innerHTML = json.title },*
*        error: function() { document.getElementById("body").innerHTML =
"error" }*
*    };*
*    $.ajax(send_dict);*
*
*
*    return false;*
*};*
*
*
*</script>*
*
*
*<body id="body" onload="return test()">*
*</body>*

2010/5/24 Alexandre González <a...@mirblu.com>

> I'm reading the piston sample, and it appears to be my necessary app, but
> the documentation is very few I think :_(
>
> As I say I'm newbie and I can't make the simplest documentation_view works,
> when I port to my app, I get a TemplateDoesNotExist documentation.html
> WTF!? if no file called "documentation.html" is in the python example, and
> why my test doesn't generate it?
>
> I don't know how test with the template called test_js.html I tried to open
> directly with file://.....test_js.html but it doesn't works either.
>
> Thanks for your help!
>
> On Mon, May 24, 2010 at 11:35, Simone Dalla <simoda...@gmail.com> wrote:
>
>>
>>
>> 2010/5/24 Alexandre González <a...@mirblu.com>
>>
>>> Hi!
>>>
>>> I must develop a django app that receives XML and returns XML.
>>>
>>> What's the best way to do this? Create a view that receive the XML and
>>> parse it to return a template with the XML resultant?
>>>
>>> I'm newbie in django and need your tips :)
>>>
>>
>>
>>
>> http://docs.djangoproject.com/en/1.1/topics/serialization/#topics-serialization
>>
>>
>> --
>> Simo
>>
>> - Registered Linux User #395060
>>
>> - Software is like sex, it is better when it is free  --> Linus B.
>> Torvalds
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
> and/or .pptx
> http://mirblu.com
>



-- 
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
and/or .pptx
http://mirblu.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to