List Info

Thread: session from a differnet application such as yahoomail api




session from a differnet application such as yahoomail api
user name
2006-12-20 09:07:25
Hi guys

One app i m developing needs integrating with the client
site and get
their users, so I need to use their login to log the users
in and once
they are in they should use my application sort of like
Microsoft
Passport...

Here is the problem the example usage is in Django

and they are talking about a request object
    if 'session_key' in request.session and 'uid' in
request.session:
        fb.session_key = request.session['session_key']

Anyone can tell me how I can access this in pylons
Isnt flup something that is set from pylons how do we use
sessions that
are set by a different Application

This question has a wide range of implications for eg., this
can be
used to apply to newly opened yahoo mail api etc., So please
help me
out

Thanks

Krypton

# -----------------------
# Web application example
# -----------------------

def simple_web_app(request, api_key, secret_key):
    fb = WebAppWidget(api_key, secret_key,
request.GET['auth_token'])
    fb.auth_getSession()

    friend_ids = fb.friends_get()
    info = fb.users_getInfo(friend_ids, ['name', 'pic'])

    print '<html><body>'
    for friend in info:
        print '<a
href="%(pic)s">%(name)s</a>' % friend
    print '</body></html>'

def web_app(request):
    """Get the user's friends and their
pictures. This example uses
       the Django web framework, but should be adaptable to
others."""

    # Get api_key and secret_key from a file
    fb_file = open('facebook_keys.txt').readlines()
    api_key = fb_file[0].strip()
    secret_key = fb_file[1].strip()
    fb = WebAppWidget(api_key, secret_key)

    # Use the data from the cookie if present
    if 'session_key' in request.session and 'uid' in
request.session:
        fb.session_key = request.session['session_key']
        fb.uid = request.session['uid']
    else:

        try:
            fb.auth_token = request.GET['auth_token']
        except KeyError:
            # Send user to the WebAppWidget to login
            return HttpResponseRedirect(fb.get_login_url())

        # getSession sets the session_key and uid
        # Store these in the cookie so we don't have to get
them again
        fb.auth_getSession()
        request.session['session_key'] = fb.session_key
        request.session['uid'] = fb.uid

    try:
        friend_ids = fb.friends_get()
    except WebAppWidgetError, e:
        # Error 102 means the session has expired.
        # Delete the cookie and send the user to
WebAppWidget to login
        if e.info['code'] == u'102':
            del request.session['session_key']
            del request.session['uid']
            return HttpResponseRedirect(fb.get_login_url())
        else:
            # Other WebAppWidget errors are possible too.
Don't ignore
them.
            raise

    info = fb.users_getInfo(friend_ids, ['name', 'pic'])
    # info is a list of dictionaries

    # you would never do this in an actual Django
application,
    # it's just an example of accessing the results.
    links = []
    for friend in info:
        html = '<a
href="%(pic)s">%(name)s</a>' % friend
        links.append(html)

    return render_to_response('template.html', {'links':
links})


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en

-~----------~----~----~----~------~----~------~--~---

volunteering to help
user name
2006-12-20 09:17:28
Hi,
I would like to help with Sabayon development.
I have already started to go through bugzilla (I just
attached a
partial fix for issue 320589).

I also added an entry for Sabayon at the
ModuleMaintainenceWorkspace
at live.gnome.org (initial entry at http://live.gnome.org/S
abayon)

Please let me know if there is any other high priority task
that needs
to be done, I'll be glad to help.

Warm regards,
Sayamindu
_______________________________________________
sabayon-list mailing list
sabayon-listgnome.org
h
ttp://mail.gnome.org/mailman/listinfo/sabayon-list
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )