web2py and ruby together

8 views
Skip to first unread message

weheh

unread,
Mar 28, 2009, 5:01:42 PM3/28/09
to web2py Web Framework
I'm working in web2py with a team using ruby. I want to get our two
apps to interact smoothly. Our apps share a user table in common. The
user table is defined in the ruby app. I would like to use the auth
routines, but I'm not sure I know how I would do it under these
circumstances.

In the absence of an auth, I figured I would check a session ID passed
to me by the ruby app. The ruby app would be, in effect, saying this
user with id x has this unique session ID. As long as the session ID
is active, the user is logged in.

So, assuming ruby gives me a user id and a session number, is this as
simple as me declaring:

session.id='<some unique ruby session identifier>'

or do I have to do something more?

The other alternative is that I hook up to the ruby app's MySQL
database and get the user's ID directly from the database. This is
even more desireable since I could then directly update the user's
profile with information from my app. How would this be done?

weheh

unread,
Mar 28, 2009, 11:52:14 PM3/28/09
to web2py Web Framework
Sorry for being long-winded above. The questions, simply stated:

1) How does one get web2py to point to and run directly off an
existing db made and updated by a Ruby app?
2) How does one get a web2py app to share authentication and session
information with a Ruby app?

I imagine no magic is needed to do this, but I'd like to hear from the
more experienced users how they would approach this.

Vidul Petrov

unread,
Mar 29, 2009, 12:20:26 AM3/29/09
to web2py Web Framework
Hi weheh ,

1) You should "initialize" (in the term of Ruby) a SQLTable object
with "migrate" flag set to False (see db.define_table), thus WEB2PY
will assume that you already has this table and will use it without
trying to create it.
2) All WEB2PY needs in order to store the sessions data in a
database:
session.connect(request,response,db)
This will create a table, following web2py_session_applicationname
naming convention, with the following structure:
`id` int(11) NOT NULL auto_increment,
`locked` char(1) default NULL,
`client_ip` varchar(64) default NULL,
`created_datetime` datetime default NULL,
`modified_datetime` datetime default NULL,
`unique_key` varchar(64) default NULL,
`session_data` longblob

weheh

unread,
Mar 29, 2009, 1:04:27 AM3/29/09
to web2py Web Framework
Thanks, Vidul. Do I need to store the session data in the db? Why
can't I just keep it session based?

Vidul Petrov

unread,
Mar 29, 2009, 1:12:28 AM3/29/09
to web2py Web Framework
The db storage of the sessions data is optional.
By default it is stored in "app_name/sessions" directory.
Reply all
Reply to author
Forward
0 new messages