Any thoughts on this one? To summarize
- using djangoAMF - want to login user through flex UI - flex UI method calls function authAndLoginVisitor(request,this_email,raw_password) - authAndLoginVisitor calls login(request,this_user) once this_user with this_email and raw_password is found in the DB - calculate(request) is called some time after authAndLoginVisitor completes. Assume it is in response to a button click in Flex. It checks to see whether request.user.is_authenticated() - calculate(request) always has request.user == AnonymousUser, even though the user was logged in through the earlier method - when I used a @login_required decorator, everything works fine -- but I don't want to redirect the user to an HTML page [login.html], I want them to do everything in Flex Any tips would be awesome... T.U. On 10/30/07, Tiger Uppercut <[EMAIL PROTECTED]> wrote: > > Hi, > > I wasn't sure whether this was a djangoAMF issue or django, so apologies > for the double posting. > > I'm having trouble using djangoAMF to communicate between my flex UI and > my django site, django_wrapper. > > - My django_wrapper is served at /main by mod_wsgi. > > * The django code base is in /usr/local/deploy/django_wrapper > * The wsgi script is in > /usr/local/deploy/django_wrapper/apache/django_wrapper.wsgi [as noted on > http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango] > > - My flex site is served at /main/flex by django. The swf is stored at > /var/www/mysite.com/static/myflex.swf > > - My djangoAMF gateway is set up at /main/gateway > > == urls.py == > > (r'^main/gateway/authService/authenticateVisitor', > > 'django_wrapper.views.authAndLoginVisitor'), > > (r'^main/gateway/calcService/calcSum', > > 'django_wrapper.views.calculate'), > > > > == views.py == > > def authAndLoginVisitor(request,this_email,raw_password): > > if request.user.is_authenticated() == True: > > return "Already authenticated!" > > > > this_user = auth.authenticate (email=this_email, > > password=raw_password) # modified from django.contrib.auth to use > > EmailBackend > > if this_user is None: # could not find the > > user > > > > return False > > else: # did find the user, now let's log him > > in > > > > auth.login(request,this_user) > > return True > > > > def calculate(request,arg1,arg2): > > if request.user is not None: > > print "In calculate, request.user is not none, it is = " + str( > > request.user) > > if request.user.is_authenticated() == True: > > return arg1 + arg2 > > else: > > return "Not authenticated!" > > > > The calculate function is called by the flex wrapper after > authAndLoginVisitor is successfully called. > > == mysite.mxml == > > > var gatewayUrl:String = " https://www.mysite.com/main/gateway/"; > > > > var serviceName:String = "calcService"; > > var serviceFactory:ServiceFactory = ServiceFactory.getInstance > > (gatewayUrl); > > var service:RemotingService = serviceFactory.getService (serviceName); > > > > var pc:PendingCall = service.calcSum(2, 3); > > pc.responder = new Responder(handleResult, handleError); > > > > > However, the calculate function keeps thinking that the request is issued > by an anonymous user. > > I added debugging code to the login() method of auth/__init__.py > > [Tue Oct 30 01:32:31 2007] [error] User status just set > [Tue Oct 30 01:32:31 2007] [error] request.session[_auth_user_id] = 11 > [Tue Oct 30 01:32:31 2007] [error] request.session[_auth_user_backend] = > django_wrapper.backends.EmailBackend > [Tue Oct 30 01:32:31 2007] [error] Set request.user = testuser > > So the request.user is set once login is called. When I look in my > auth_user table in the database, testuser's last_login is correctly set, as > well. > > However, now fast forward to the calculate call. Recall that I have a > flex UI, so the actual URL in the browser window > www.mysite.com/main/flexappears the same. > > When I call this function calculate request.user shows up as anonymous: > [Tue Oct 30 02:52:36 2007] [error] In calculate, request.user is not none, > it is = AnonymousUser > [Tue Oct 30 02:57:33 2007] [error] <WSGIRequest > [Tue Oct 30 02:57:33 2007] [error] GET:<QueryDict: {}>, > [Tue Oct 30 02:57:33 2007] [error] POST:<QueryDict: > {u'\\x00\\x03\\x00\\x00\\x00\\x01\\x00\\x13calcService.calcSum\\x00\\x02/[EMAIL > PROTECTED]@\\x08\\x00\\x00\\x00\\x00\\x00\\x00': > [u'']}>, > [Tue Oct 30 02:57:33 2007] [error] COOKIES:{'sessionid': > 'c9726aabf90079d7cb9bbf549b6fc8c4'}, > ... > [Tue Oct 30 02:57:33 2007] [error] 'HTTP_COOKIE': > 'sessionid=c9726aabf90079d7cb9bbf549b6fc8c4', > > > Any ideas why the request keeps showing up without the user credentials > set in the login method earlier? > > Note that, if I apply a decorator, login_required, to calcService, and > login through the standard django html form, the request has my correct > credentials. It's just when I try to do it "by hand", I'm running into this > problem. > > Thanks for any help! > > T.U. > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---