If I am not missing something, it looks like I have solved the
problem.

This is hack:

>>> from django.http import SimpleCookie
>>> from django.test.client import Client
>>> c = Client()
>>> cookies = SimpleCookie()
>>> cookies['sessionid'] = '8a3dd9235b8e718c3f7e890106180528'
>>> c.cookies = cookies
>>> c.get('/messages/')
<django.http.HttpResponse object at 0xb77aeb0c>


Thanks...




On 20 Ağustos, 13:52, omat <[EMAIL PROTECTED]> wrote:
> I am using the api via shell (i.e.: python manage.py shell) as
> follows:
>
> >>> from django.contrib.sessions.middleware import SessionWrapper
> >>> from django.test.client import Client
> >>> c = Client()
> >>> s = SessionWrapper('8a3dd9235b8e718c3f7e890106180528')
> >>> c.session = s._session
> >>> c.session
>
> {'_auth_user_id': 840, '_auth_user_backend':
> 'django.contrib.auth.backends.ModelBackend'}>>> c.get('/messages/')
>
> <django.http.HttpResponseForbidden object at 0xb775ffec>
>
> The last line says the request is not considered as being form an
> authenticated user because HttpResponseForbidden is returned when an
> anonymous user tries to access /messages/.
>
> I am supplying the data in the session, so I think it must be ok. Am I
> thinking wrong?
>
> Thanks,
> oMat
>
> On 20 Ağustos, 13:14, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
>
> > On Mon, 2007-08-20 at 09:57 +0000, omat wrote:
> > > Thanks for the reply...
>
> > > I used the existing database instead of the test database to hook to
> > > the user's session like this:
>
> > > from django.test.client import Client
> > > from django.contrib.sessions.models import Session
>
> > > client = Client()
> > > client.session = Session.objects.get(session_key = key_from_traceback)
>
> > > but did not work.
>
> > If you're using the test framework, it doesn't talk to the production
> > database. It creates it's own testing database (read the testing docs
> > for more information). So your above query is talking to an empty table
> > unless you have populated it yourself.
>
> > Regards,
> > Malcolm
>
> > --
> > No one is listening until you make a 
> > mistake.http://www.pointy-stick.com/blog/


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

Reply via email to