[albatross-users] Re: Albatross-users digest, Vol 1 #181 - 12 msgs
Cameron Blackwood
korg at darkqueen.org
Thu Jul 3 14:12:10 EST 2003
From: Matt Goodall <matt at pollenation.net>:
| Date: Wed, 02 Jul 2003 14:55:03 +0100
| From: Matt Goodall <matt at pollenation.net>
| To: "Albatross User's List" <albatross-users at object-craft.com.au>
| Subject: Re: [albatross-users] multiple session support
|
[...]
|
| Sheila King wrote:
| >The question was:
| >
| >"Multiple sessions/browser windows open is something to keep in mind. Does
| >the Albatross framework allow multiple sessions for 1 account / from 1
| >computer?"
| Does he mean multiple sessions or multiple browser windows sharing a
| single session?
Err, I dont think so.
Say we have an chess game server which has a number of users, and each
user can be playing multiple chess games against other people.
I read that question as does albatross allow me to start my browser,
create two tabs/windows, login (as a different and/or the same user)
in each and play two different games.
The are two issues here:
1) can albatross manage seperate sessions in a single browser
instance?
Answer: YES. See the code below seems to illustrate it.
2) can albatross deal with the issues of multiple streams of input
without getting foobar'ed (ie, locks etc)
EG, (assume in the chess example that chess was a realtime game
and not turnbased) what happens if two people are trying to move
the same piece?
Answer: That isnt albatrosses job, that's the code you write :).
(If anyone has any examples of (2) or knows how to make albatross
do that, then please tell me :) :) :)
Oh, and if he did mean....
| Does he mean multiple sessions or multiple browser windows sharing a
| single session?
then I guess the answer to that is that your application would have to
be smart enough to deal with that. (and that isnt simple).
--
/ `Rev Dr' cam at darkqueen.org Roleplaying, virtual goth \
< http://darkqueen.org Poly, *nix, Python, C/C++, genetics, ATM >
\ [+61 3] 9809 1523[h] skeptic, Evil GM(tm). Sysadmin for hire /
---------- Random Quote ----------
Now is the time for drinking; now the time to beat the earth with
unfettered foot.
-- Quintus Horatius Flaccus (Horace)
-------------- 8< cut ------------
#!/usr/bin/python
from albatross import SimpleApp as AlbatrossApp
from albatross import SimpleAppContext as AlbatrossContext
from albatross.cgiapp import Request
def DEBUG(msg,*rest):
fd=open("/tmp/debug",'a')
fd.write('DEBUG: '+msg)
if rest: fd.write('%s'%(rest))
fd.write('\n')
fd.close()
class StartPage:
def page_enter(self, ctx):
ctx.locals.number=0
ctx.locals.op=0
ctx.add_session_vars('number')
def page_process(self, ctx):
DEBUG('num==%s op==%s'%(ctx.locals.number,ctx.locals.op))
if ctx.locals.op:
DEBUG(' INSIDE op==%s'%(ctx.locals.op))
if ctx.locals.op=='+': ctx.locals.number=ctx.locals.number+1
if ctx.locals.op=='-': ctx.locals.number=ctx.locals.number-1
if ctx.locals.op=='0': ctx.locals.number=0
def page_display(self, ctx):
ctx.run_template('foo.html')
class App(AlbatrossApp):
def __init__(self):
AlbatrossApp.__init__(self,
base_url = 'whocares.py',
template_path = 'template',
start_page = 'StartPage',
secret = '-=-secret-=-',
# session_appid = 'popview3'
)
for page in (StartPage(),):
self.register_page(page.__class__.__name__, page)
def create_context(self):
return AlbatrossContext(self)
if __name__ == '__main__':
app = App()
app.run(Request())
-------------- 8< cut ------------
<html><head><title>albatross-foo</title></head>
<body>
<h1>hello</h1>
<al-form method="post">
Number is: <al-value expr="number"><br>
<al-input type="submit" name="op" value="+">
<al-input type="submit" name="op" value="-">
<al-input type="submit" name="op" value="0">
</al-form>
<hr>
Writen in: <em>Python</em> and <em>Albatross</em>
</body></html>
More information about the Albatross-users
mailing list