Re: Extracting json data for parsing from HTTP GET
Thank you so much, it worked:)...Now I just have to play with parsing json that I think I can manage. Thanks again:) Irum On Sep 2, 1:11 pm, Daniel Roseman wrote: > On Sep 2, 10:37 am, irum wrote: > > > > > Hi, > > Thanks for your prompt reply. > > I have tried both the things but I get the same error. > > With, > > x = json.loads(p.read()) > > print x > > > I get following error: 'HttpResponse' object has no attribute > > 'read' > > Also I get same error with, json.dumps(p.read()), and same when I use > > loads and dumps as load and dump without s. > > > Then, I tried the other option, > > > x = json.dump(p) > > print x > > > I get the following error: dump() takes at least 2 arguments (1 given) > > What would be the second argument, I googled on this but find no > > helpful tips as everything written is too complicated. > > > And with: > > x = json.load(p) > > print x > > > 'HttpResponse' object has no attribute 'read' > > > In all the examples, p is the HttpResponse object I get. > > > Looking forward, > > Irum > > Apologies for steering you wrong - that'll teach me to post without > checking. > > You're right that HttpResponse doesn't have a read() method, contrary > to what I thought. So neither of those methods will work. Instead, get > the content of the response and call loads() on that: > > json.loads(p.content) > > -- > DR. -- 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.
Re: Extracting json data for parsing from HTTP GET
Hi, Thanks for your prompt reply. I have tried both the things but I get the same error. With, x = json.loads(p.read()) print x I get following error: 'HttpResponse' object has no attribute 'read' Also I get same error with, json.dumps(p.read()), and same when I use loads and dumps as load and dump without s. Then, I tried the other option, x = json.dump(p) print x I get the following error: dump() takes at least 2 arguments (1 given) What would be the second argument, I googled on this but find no helpful tips as everything written is too complicated. And with: x = json.load(p) print x 'HttpResponse' object has no attribute 'read' In all the examples, p is the HttpResponse object I get. Looking forward, Irum On Sep 2, 12:09 pm, Daniel Roseman wrote: > On Sep 2, 9:57 am, irum wrote: > > > > > Hi, > > I am having problems with extracting json data for parsing from HTTP > > GET request. > > > What I am doing is that I am receiving json data over HTTP via GET. > > After debugging much, I have realized that the data also has HTTP > > headers and other information that serializer is not able to > > deserialize. How can I extract json data from the complete data > > (including HTTP information)? > > > This is the data I receive, i.e. p, and I want to extract json from it > > and deserialize it for parsing. > > > HTTP/1.0 200 OK Date: Thu, 02 Sep 2010 08:37:39 GMT Server: WSGIServer/ > > 0.1 Python/2.6.4 Content-Type: application/json [{"pk": 33, "model": > > "hbexample.payment", "fields": {"confirm": true, "pDate": "2010-08-31 > > 10:42:19", "waiting": false, "amount": 33.0, "p_try": 0, "booking": > > 34}}] > > > I have tried json.loads and json.dumps on this data. > > > With json.loads(p), I get the following error: expected string or > > buffer > > > With json.dumps(p), I get the following error: > > is not JSON > > serializable > > > How do I address this problem? Any help regarding this would be > > helpful. > > > Thanks and Looking forward, > > Irum > > json.loads() and dujmps() work on a string or string-like object. > HttpResponse is a file-like object, not a string, so you could either > do loads(p.read()), or - much better - use the load() and dump() > methods, without the s, directly on the HttpResponse. > -- > DR. -- 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.
Extracting json data for parsing from HTTP GET
Hi, I am having problems with extracting json data for parsing from HTTP GET request. What I am doing is that I am receiving json data over HTTP via GET. After debugging much, I have realized that the data also has HTTP headers and other information that serializer is not able to deserialize. How can I extract json data from the complete data (including HTTP information)? This is the data I receive, i.e. p, and I want to extract json from it and deserialize it for parsing. HTTP/1.0 200 OK Date: Thu, 02 Sep 2010 08:37:39 GMT Server: WSGIServer/ 0.1 Python/2.6.4 Content-Type: application/json [{"pk": 33, "model": "hbexample.payment", "fields": {"confirm": true, "pDate": "2010-08-31 10:42:19", "waiting": false, "amount": 33.0, "p_try": 0, "booking": 34}}] I have tried json.loads and json.dumps on this data. With json.loads(p), I get the following error: expected string or buffer With json.dumps(p), I get the following error: is not JSON serializable How do I address this problem? Any help regarding this would be helpful. Thanks and Looking forward, Irum -- 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.
Re: deserializing json
Hi, Sorry for late reply. I had to switch to another project so this work got delayed. Actually, what I am doing is that I am receiving json data over HTTP via GET. After debugging much, I have realized that the data also has HTTP headers and other information that serializer is not able to serialize. How can I extract json data from the complete data (including HTTP information)? This is the data I receive, i.e. p, and I want to extract json from it and deserialize it for parsing. HTTP/1.0 200 OK Date: Thu, 02 Sep 2010 08:37:39 GMT Server: WSGIServer/ 0.1 Python/2.6.4 Content-Type: application/json [{"pk": 33, "model": "hbexample.payment", "fields": {"confirm": true, "pDate": "2010-08-31 10:42:19", "waiting": false, "amount": 33.0, "p_try": 0, "booking": 34}}] I have tried json.loads and json.dumps on this data. With json.loads(p), I get the following error: expected string or buffer With json.dumps(p), I get the following error: is not JSON serializable How do I address this problem? Any help regarding this would be helpful. Thanks and Looking forward, Irum On Aug 20, 9:33 pm, Reinout van Rees wrote: > On 08/20/2010 02:16 PM,irumwrote: > > > Hi, > > I am trying to parse json, loop through it and access its data. > > At first I tried this: > > > for obj in serializers.deserialize("json", p): > > a=2 > > response = HttpResponse() > > response.status_code = 200 > > return response > > One small thing to try: > response = HttpResponse('') > instead of: > response = HttpResponse() > > So: feed it an empty string. > > As it complains about being unreadable, perhaps you should stuff > something into it. Just a pretty wild guess... > > Reinout > > -- > Reinout van Rees - rein...@vanrees.org -http://reinout.vanrees.org > Programmer athttp://www.nelen-schuurmans.nl > "Military engineers build missiles. Civil engineers build targets" -- 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.
deserializing json
Hi, I am trying to parse json, loop through it and access its data. At first I tried this: for obj in serializers.deserialize("json", p): a=2 response = HttpResponse() response.status_code = 200 return response Here 'p' has the json data returned to me by another view. I have validated it in http://www.jsonlint.com/ and it does not have any error. This gave attribute error. AttributeError at /bookings/52/cancel/ 'HttpResponse' object has no attribute 'read' The problem I am sure is not in HttpResponse object as it works fine when I comment out the line accessing object of deserialized data i.e for obj in serializers.deserialize("json", p) I then tried writing this: deserialized = serializers.deserialize("json", self.request.raw_post_data) d = list(deserialized)[0].object and also this: deserialized = serializers.deserialize("json", self.request.raw_post_data) d = list(deserialized).object I again get same error. It works fine if the second line: put_bookmark = list(deserialized)[0].object , is commented out. But, when I uncomment it to access object of deserialized data I get the same error. After many trial and errors, I am convinced the problem is when I try to access object of deserialized data. I also referred to this thread: http://groups.google.com/group/django-users/browse_thread/thread/87bd6951b4aebd00/d8e0a547be1583a8?lnk=gst&q=deserialize#d8e0a547be1583a8 in the discussion group. In this thread also the problem trickles down to access object of deserialzed data but no further solution is available. I don want to use simplejson. Can someone give me a solution to this problem and help me fix this. Thanks, Irum I get the attribute error: 'HttpResponse' object has no attribute 'read' -- 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.
urllib and writing web service clients
Hi, I am relatively new to working with django and web services. I am using django-piston and I posted this on that group as well but got no reply yet. Posting it here since its more active community and my problem is not related to Django-piston in particular but rather Django and web services in general. Hoping to get a reply from here:) I am trying to implement a small example of a RESTful web service i.e a hotel booking service. I have implemented my resources successfully with read, update and delete methods according to my specifications. I can invoke them successfully using 'curl' and get the desired status codes. The problem now I am stuck in implementing full behavior of my service that invokes a particular resource after performing a certain method on a resource. For example, after invoking successfully a POST method on 'booking' resource, I want to invoke a POST on 'payment' resource. My main problem is : - where do I implement all the specifications for my RESTful web service that invokes methods on these resources in a specific sequence as desired. Is it in the 'view.py' file that I create in the 'api' folder? Can someone give me any example on how to write web service clients in django / django-piston? I googled but found no good result. - Secondly, my main problem is how do I invoke these methods with in my code? I have tried urllib/ urllib2. When I invoke a remote address like 'http://www.example.com', it returns the html file but when I invoke local host, i.e. http://127.0.0.1:8000/api/hb/bookings/21/ , curl does not respond when I invoke that handler from curl on command prompt. My code is like this: class RoomHandler(BaseHandler): allowed_methods = ('GET', 'PUT', 'POST', 'DELETE') model = room fields = ('rType', 'floor') def read(self, request, id=0): . if b: b = booking.objects.get(id=id) response = room.objects.filter(id = b.room_id) req = urllib2.Request('http://127.0.0.1:8000/api/hb/ bookings/21/') #req = urllib2.Request('http://www.example.com') response = urllib2.urlopen(req) the_page = response.read() type(the_page) return the_page >From command prompt, I invoke. curl >http://127.0.0.1:8000/api/hb/bookings/21/rooms/ It does not respond anything, even if left for long time. However if I use remote url, i.e. : req = urllib2.Request('http://www.example.com') , it returns the html file. Where am I going wrong? Thirdly, how do I implement conditions in my client to invoke a certain method of a resource, i.e. before invoking POST on a 'payment' resource, I want to perform a GET on 'booking' and 'room' resource, only if I get response code of 200 (i.e. booking and room resource is created), I should be able to invoke POST on 'payment' resource else it should set a flag to false. I will be implementing an algorithm, but I was thinking can we put conditions on invoking methods of resource like we would do with JML for java interfaces? I have been stuck with these problems for almost two weeks, googling and trying different things but I am still stuck. Hoping to hear something from here. Thankyou for your time and looking forward, Irum -- 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.
problem deserialization
Hi, I am working on implementing a REST web service example of booking a hotel. It was supposed to be simple to start with but I am already badly stuck:) I am stuck with deserialization and serialization. I want to create a new resource when PUT is requested on booking. My GET method works perfectly fine but I am stuck with PUT. My code on method PUT is: def do_PUT(self): try: deserialized = serializers.deserialize("json", self.request.raw_post_data) put_book = list(deserialized) except (ValueError, TypeError, IndexError): response = HttpResponse() response.status_code = 400 return response for obj in put_book: b1 = guest( fName = "hello", phone = 21, email = "t...@email") b1.save() json = serializers.serialize("json", b1) response = HttpResponse(json, mimetype="application/json") response.status_code = 201 response["Location"] = "/bookings/%s" % (b1.id) return response Now when I send PUT request via curl, i.e.: curl -i -d "{'room_id': 21, 'payment_id': 21, 'guest_id': 21}" -X PUT http://127.0.0.1:8000/bookings/ It gives me 400 error, i.e. HTTP/1.0 400 BAD REQUEST This means it is raising and exception and not able to deserialize the data. I tried removing the statement: put_book = list(deserialized) in try block. ie, try: deserialized = serializers.deserialize("json", self.request.raw_post_data) # put_book = list(deserialized) except (ValueError, TypeError, IndexError): response = HttpResponse() response.status_code = 400 return response for obj in deserialized: b1 = guest( fName = "hello", phone = 21, email = "t...@email") b1.save() json = serializers.serialize("json", b1) response = HttpResponse(json, mimetype="application/json") response.status_code = 201 response["Location"] = "/bookings/%s" % (b1.id) return response It then doesnt raises and exception but gives 500 error: HTTP/1.0 500 INTERNAL SERVER ERROR . Exception Type: ValueError at /bookings/ Exception Value: Expecting property name: line 1 column 1 (char 1) ... In line 1 of my views.py, I am just importing : from django.http import HttpResponse, HttpResponseNotAllowed, HttpResponseForbidden And there is no problem in this line, since my rest of the views perfectly fine if its not for this problem. Any help and input would be appreciated. I am stuck in this for last 2 days and trying to fix it. I have googled extensively but still no clue. Thanks, Irum -- 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.
Re: problems with authentication of test client
'c' is written here by mistake, I was trying different things by and commented out the wrong statement while pasting. It was, r = self.client.post('/createauction/', post_data) Also, could the problem be with my Python version 2.6.5 and Django 1.1.1 as stated in this thread: http://groups.google.com/group/django-users/browse_thread/thread/617457f5d62366ae/e5d1436ac93aeb61?lnk=gst&q=baffled# I have also tried after updating my django-trunk but the problem persisits. Should I downgrade to Python 2.6.4 to fix this? Irum On May 28, 12:13 pm, Daniel Roseman wrote: > On May 28, 9:23 am, irum wrote: > > > > > > > > > import unittest > > from django.test.client import Client > > from django.test import Client, TestCase > > from django.contrib.auth import authenticate > > from django.contrib.auth.models import * > > from django.core import mail > > import datetime > > import time > > > class SimpleTest(TestCase): > > fixtures = ['f1.json'] > > > def setUp(self): # Every test needs a client > > self.client = Client() > > > def test_create(self): > > > response = self.client.get('/createauction/') > > # Check that it takes to login page if not logged n > > self.failUnlessEqual(response.status_code, 302) > > self.assertRedirects(response, '/login/?next=/createauction/') > > > # i have created a user here again as some threads suggested that I > > should make a user here. > > user = User.objects.create_user(username = 'myadmin2', email > > ='du...@dummy.com', password = 'testing2') > > uid = user.id > > user.is_staff = True > > user.save() > > > print "trying to login..." > > > login = self.client.login(username='myadmin2', > > password='testing2') > > self.failUnless(login, True) > > self.assertEqual( login, True) # this test does not fail, > > means user has logged in succefully and login is True > > > enddate = datetime.datetime(2010, 06, 04, 3, 45, 50) > > > post_data = { > > 'title' : 'Title1', > > 'desc' : 'description', > > 'start-date' : datetime.datetime.now() , > > 'end_date' : enddate, > > 'owner' : user.id, > > 'price' : 60, > > 'highbid' : 60, > > 'banned' : False, > > 'closed' : True, > > > } > > > r = c.post('/createauction/', post_data) > > self.failUnlessEqual(r.status_code, 200) # this test fails, as > > status_code returned is 302 > > > These tests are run successully, meaning the user is redirected to > > login page, implying that client never enters the else branch for > > authenticated user in the 'cauction' view. > > self.failUnlessEqual(r.status_code, 302) > > self.assertRedirects(response, '/login/?next=/createauction/') > > > I have put in more than a day in this problem, trying to figure out > > where I am going wrong. I have tried to explain clearly here. Any one > > has any idea? > > > Thanks, > > irum > > What is `c` in the second-last line of the test? Are you perhaps > instantiating a separate test client somewhere? Show the actual code > you're running. > > Also note you don't need to define self.client in setUp(), as TestCase > does that > already:http://docs.djangoproject.com/en/1.2/topics/testing/#default-test-client > -- > DR. -- 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.
problems with authentication of test client
Hi, I am trying to test my pages that need authentication. But, I am not able to test views that need authentication. I have tried following threads about logging in test client in this group and django documentation, but still cant figure out. This my view I am trying to test: def cauction(request) if not request.user.is_authenticated(): print "redirecting" # printing this to check which if branch is executing print request.user return HttpResponseRedirect('/login/?next=%s' % request.path) else: print "authenticated_branch" # printing this to check which if branch is executing errors = [] if not request.method == 'POST': form = createAuction() return render_to_response('createauction.html', {'form' : form} ) else: form = createAuction(request.POST) if form.is_valid(): cd = form.cleaned_data uname = request.user.username a_title = cd['title'] a_desc = cd['description'] a_minprice = cd['min_price'] a_end_date = cd['end_date'] a_start_date = datetime.datetime.now() if not a_end_date > a_start_date: e = _('End date should be greater than start date.') errors.append(e) else: dt = a_end_date - a_start_date day = dt.days total_secs=dt.seconds secs = total_secs % 60 total_mins = total_secs / 60 mins = total_mins % 60 hours = total_mins / 60 th = hours + (day * 24) if th > 72 or th == 72: uname = request.user.username form = confAuction() return render_to_response('wizardTest.html', {'form' : form, 'a_title' : a_title, 'a_desc' : a_desc,'a_start-date' : a_start_date, 'a_end_date' : a_end_date, 'a_minprice' : a_minprice, 'uname' : uname}) else: e = _('Auction duration should be at least 72 hours') errors.append(e) else: e = _('Enter Valid data') errors.append(e) return render_to_response('createauction.html', {'form' : form, 'errors' : errors}) This view is called by this pattern in urls.py urlpatterns = patterns('',('^$', yaas_homepage) , (r'^createauction/$', cauction), ...) This is my tests.py import unittest from django.test.client import Client from django.test import Client, TestCase from django.contrib.auth import authenticate from django.contrib.auth.models import * from django.core import mail import datetime import time class SimpleTest(TestCase): fixtures = ['f1.json'] def setUp(self): # Every test needs a client self.client = Client() def test_create(self): response = self.client.get('/createauction/') # Check that it takes to login page if not logged n self.failUnlessEqual(response.status_code, 302) self.assertRedirects(response, '/login/?next=/createauction/') # i have created a user here again as some threads suggested that I should make a user here. user = User.objects.create_user(username = 'myadmin2', email ='du...@dummy.com', password = 'testing2') uid = user.id user.is_staff = True user.save() print "trying to login..." login = self.client.login(username='myadmin2', password='testing2') self.failUnless(login, True) self.assertEqual( login, True) # this test does not fail, means user has logged in succefully and login is True enddate = datetime.datetime(2010, 06, 04, 3, 45, 50) post_data = { 'title' : 'Title1', 'desc' : 'description', 'start-date' : datetime.datetime.now() , 'end_date' : enddate, 'owner' : user.id, 'price' : 60, 'highbid' : 60, 'banned' : False, 'closed' : True, } r = c.post('/createauction/', post_data) self.failUnlessEqual(r.status_code, 200) # this test fails, as status_code returned is 302 These tests are run successully, meaning the user is redirected to login page, implying that client never enters the else branch for authenticated user in the 'ca
Re: problem with running test
Sorry, I fixed it. It was a small overlook so I thought I should post it here for newbies. After updating my django-trunk and including installed apps,I was missing application name after test, i.e., command should be: manage.py test [aapname] BR, Irum On May 26, 7:12 pm, irum wrote: > Hi, > I am working on django for a project and have to do some funcitonal > testing. > > However, whenever I run manage.py test, I get the error shown below. I > have tried searching threads in this group and they mention having > these applications installed in my settings file: > 'django.contrib.auth', 'django.contrib.sites', 'django.contrib.admin'. > I have them all. Secondly, they mention this > ticket:http://code.djangoproject.com/changeset/10674 > > I have dowloaded both the files remote_user.py and url.py and updated > them in my trunk folder at the path mentioned in this ticket, but even > then the problem did not resolve. I also tried subversion update of > the django-trunk folder, but still the problem persists. Can someone > kindly guide me where I am going wrong? I spent my whole day to fix > this but to no avail. > > Thanks in advance. > > Creating test database... > Creating table auth_permission > Creating table auth_group > Creating table auth_user > Creating table auth_message > Creating table django_content_type > Creating table django_session > Creating table django_site > Creating table yaas_auction > Creating table yaas_bid > Creating table yaas_userprofile > Creating table yaas_winner > Creating table django_admin_log > Installing index for auth.Permission model > Installing index for auth.Message model > Installing index for yaas.auction model > Installing index for yaas.Bid model > Installing index for yaas.winner model > Installing index for admin.LogEntry model > FFF.F...F..... > == > ERROR: test_known_user > (django.contrib.auth.tests.remote_user.RemoteUserCustomTest) > -- > Traceback (most recent call last): > File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ > lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py", > line 160, in test_known_user > super(RemoteUserCustomTest, self).test_known_user() > File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ > lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py", > line 72, in test_known_user > self.assertEqual(response.context['user'].username, 'knownuser2') > TypeError: 'NoneType' object is unsubscriptable > > == > ERROR: test_last_login > (django.contrib.auth.tests.remote_user.RemoteUserCustomTest) > -- > Traceback (most recent call last): > File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ > lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py", > line 87, in test_last_login > self.assertNotEqual(default_login, > response.context['user'].last_login) > TypeError: 'NoneType' object is unsubscriptable > > == > ERROR: test_no_remote_user > (django.contrib.auth.tests.remote_user.RemoteUserCustomTest) > -- > Traceback (most recent call last): > File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ > lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py", > line 33, in test_no_remote_user > self.assert_(isinstance(response.context['user'], AnonymousUser)) > TypeError: 'NoneType' object is unsubscriptable > > == > ERROR: test_unknown_user > (django.contrib.auth.tests.remote_user.RemoteUserCustomTest) > -- > Traceback (most recent call last): > File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ > lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py", > line 168, in test_unknown_user > super(RemoteUserCustomTest, self).test_unknown_user() > File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ > lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py", > line 51, in test_unknown_user > self.assertEqual(response.context['user'].username, 'newuser
problem with running test
Hi, I am working on django for a project and have to do some funcitonal testing. However, whenever I run manage.py test, I get the error shown below. I have tried searching threads in this group and they mention having these applications installed in my settings file: 'django.contrib.auth', 'django.contrib.sites', 'django.contrib.admin'. I have them all. Secondly, they mention this ticket: http://code.djangoproject.com/changeset/10674 I have dowloaded both the files remote_user.py and url.py and updated them in my trunk folder at the path mentioned in this ticket, but even then the problem did not resolve. I also tried subversion update of the django-trunk folder, but still the problem persists. Can someone kindly guide me where I am going wrong? I spent my whole day to fix this but to no avail. Thanks in advance. Creating test database... Creating table auth_permission Creating table auth_group Creating table auth_user Creating table auth_message Creating table django_content_type Creating table django_session Creating table django_site Creating table yaas_auction Creating table yaas_bid Creating table yaas_userprofile Creating table yaas_winner Creating table django_admin_log Installing index for auth.Permission model Installing index for auth.Message model Installing index for yaas.auction model Installing index for yaas.Bid model Installing index for yaas.winner model Installing index for admin.LogEntry model FFF.F...F..... == ERROR: test_known_user (django.contrib.auth.tests.remote_user.RemoteUserCustomTest) -- Traceback (most recent call last): File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py", line 160, in test_known_user super(RemoteUserCustomTest, self).test_known_user() File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py", line 72, in test_known_user self.assertEqual(response.context['user'].username, 'knownuser2') TypeError: 'NoneType' object is unsubscriptable == ERROR: test_last_login (django.contrib.auth.tests.remote_user.RemoteUserCustomTest) -- Traceback (most recent call last): File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py", line 87, in test_last_login self.assertNotEqual(default_login, response.context['user'].last_login) TypeError: 'NoneType' object is unsubscriptable == ERROR: test_no_remote_user (django.contrib.auth.tests.remote_user.RemoteUserCustomTest) -- Traceback (most recent call last): File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py", line 33, in test_no_remote_user self.assert_(isinstance(response.context['user'], AnonymousUser)) TypeError: 'NoneType' object is unsubscriptable == ERROR: test_unknown_user (django.contrib.auth.tests.remote_user.RemoteUserCustomTest) -- Traceback (most recent call last): File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py", line 168, in test_unknown_user super(RemoteUserCustomTest, self).test_unknown_user() File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py", line 51, in test_unknown_user self.assertEqual(response.context['user'].username, 'newuser') TypeError: 'NoneType' object is unsubscriptable == ERROR: test_known_user (django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest) -- Traceback (most recent call last): File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/django/contrib/auth/tests/remote_user.py", line 67, in test_known_user self.assertEqual(response.context['user'].username, 'knownuser') TypeError: 'NoneType' object is unsubscriptable == ERROR: test_last_login (django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest) -- Traceback (most recent call last): File "/opt/local/Library/Frameworks/Python.frame
Re: automatically performing an a task
Hi, Thanks:) However, sorry I am a newbie with this stuff. I have gotten some hands on Django during this project and have taken some understanding of cron by googling but I am still sort of lost with it. The problem is that if I fire manage.py script with cron, how do I run the specific task that I want to run that performs the computaion of checking the end date and resolving it(involving db operations, and sending mail to winner etc.) Lets suppose, I write all this funtionality as a view(e.g. resolveauction) in view.py and link a uri with this in urls.py (e.g. (r'^res_aucation/$', resolveauction)). Now how do I fire manage.py from cron to trigger this uri(e.g. /res_auction/) functionality? Thanks again and looking forward, Irum On May 23, 1:18 am, Daniel Roseman wrote: > On May 22, 4:17 pm, irum wrote: > > > > > Hi, > > > I am working on a sample auction site with Django for my course > > project. I have a requirement that system automatically resolves an > > auction after the end date of the auction and elect the winner. > > > I am not sure how to implement this functionality and which feature of > > Django should be used to automatically perform a task when the auction > > reaches its end date. > > > My search till now takes me to Django-corn (http://code.google.com/p/ > > django-cron/wiki/Install). Should I use this or am I following a wrong > > thread for solution to my problem? > > > Any prompt help and insights regarding this would be much appreciated > > as I am nearing my deadline this week:) > > > Thanks in advance, > > Irum > > No need for any external projects. Just have a normal cron job which > fires a custom manage.py script to carry out the task. > -- > DR. > > -- > 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 > athttp://groups.google.com/group/django-users?hl=en. -- 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.
automatically performing an a task
Hi, I am working on a sample auction site with Django for my course project. I have a requirement that system automatically resolves an auction after the end date of the auction and elect the winner. I am not sure how to implement this functionality and which feature of Django should be used to automatically perform a task when the auction reaches its end date. My search till now takes me to Django-corn (http://code.google.com/p/ django-cron/wiki/Install). Should I use this or am I following a wrong thread for solution to my problem? Any prompt help and insights regarding this would be much appreciated as I am nearing my deadline this week:) Thanks in advance, Irum -- 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.