cooperation between applications

15 views
Skip to first unread message

leone

unread,
Sep 25, 2009, 2:21:46 PM9/25/09
to web2py-users
Someone knows what is the better way to resolve this scenario with
web2py?
1) I have an application populated with useful pages linked and used
from other application. These utility-pages must be inizialized with
some values. What is the better way to pass values between the two
applications (not by GET, please)? The utility page not knows who is
the caller.
2) each utility-page must have the layout of the caller page.
I have read about exec-environment and sessions but I am confused
about the cleaner approach and I need some examples.
Thanks on advance
-leone

mdipierro

unread,
Sep 25, 2009, 2:46:57 PM9/25/09
to web2py-users


On Sep 25, 1:21 pm, leone <handja...@gmail.com> wrote:
> Someone knows what is the better way to resolve this scenario with
> web2py?
> 1) I have an application populated with useful pages linked and used
> from other application. These utility-pages must be inizialized with
> some values. What is the better way to pass values between the two
> applications (not by GET, please)? The utility page not knows who is
> the caller.

It really depends on the type of information. Applications can share
database and sessions.

> 2) each utility-page must have the layout of the caller page.
> I have read about exec-environment and sessions but I am confused
> about the cleaner approach and I need some examples.

in {{extend layout}} layout can be a string or a variable. If it is a
variable it can be a string pointing to a layout in another app
layout='../../otherapp/views/layout.html'

This works assuming the two apps are not bytecode compiled and
assuming the otherapp/views/layout finds the variables it needs to
render.

Anyway, perhaps if you tell is what is the bigger picture there is a
better way.


> Thanks on advance
> -leone

leone

unread,
Sep 25, 2009, 3:14:01 PM9/25/09
to web2py-users
If I understand the more effective way is to use session that store
info about master app
so that util-app can access layout and other static resources and so
on, returning some result.
The only shared information is the database position or address, and
this can be a constant for the two applications.
Well, i will try it.
Thanks for your kindness
-leone

mdipierro

unread,
Sep 25, 2009, 4:12:48 PM9/25/09
to web2py-users
wait. By default applications do not share sessions.

you must do

from gluon.fileutils import get_session
other_session=get_session(request,'otherappname')

to get the app for the same user but another app.

mdipierro

unread,
Sep 25, 2009, 4:14:24 PM9/25/09
to web2py-users
You need to use

gluon.contrib.get_session

to access another app session. This is undocumented because I do not
promise it will stay backward compatible.

On Sep 25, 2:14 pm, leone <handja...@gmail.com> wrote:

John Heenan

unread,
Sep 26, 2009, 8:47:40 PM9/26/09
to web2py-users
On Sep 26, 4:46 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> in {{extendlayout}} layout can be a string or a variable. If it is a
> variable it can be a string pointing to a layout in another app
> layout='../../otherapp/views/layout.html'
>
> This works assuming the two apps are not bytecode compiled and
> assuming the otherapp/views/layout finds the variables it needs to
> render.
>

Regretably layout as a variable in ((extend layout)) also does not
work if a single application is bytecode compiled, since view
compilation requires the extend variable to be known. Still it is a
small price to pay for being able to compile views.

John Heenan
Reply all
Reply to author
Forward
0 new messages