GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||
GeezerVison is showing wiki.wxpython.org — HelpOnSessions - wxPyWiki
How sessions work in MoinMoinContents Code using the session framework currently includes:
Session related configuration
Single wikiLikely the only interesting item is cookie_lifetime.
Multiple separate wikis under same domain, all using wikiconfig (not farmconfig)The default cookie_name = None creates a different cookie name and separate sessions for each wiki. If you want separate sessions for your wikis, you can't use cookie_name = 'siteidmagic' because that always would set the name to MOIN_SESSION_wikiconfig. So either explicitly set a unique cookie_name for each wiki or use cookie_name = None.
Wiki farm, host based farmingE.g. wiki1.example.org and wiki2.example.org. If you like shared sessions, shared user profiles, use this in your farmconfig:
Wiki farm, path based farmingE.g. example.org/wiki1 and example.org/wiki2. If you like shared sessions, shared user profiles, use this in your farmconfig:
Wiki farm, port based farmingE.g. example.org:8000 and example.org:8001. If you like shared sessions, shared user profiles, use this in your farmconfig:
Session example codeAs an extension programmer, in order to use session variables, you can use request.session like a dict, values stored there are automatically saved and restored if a session is available. Here's an example macro using the session code: 1 # -*- coding: iso-8859-1 -*-
2
3 """
4 Tests session state.
5 """
6
7 Dependencies = ['time']
8
9 def execute(macro, args):
10 if macro.request.session.is_new:
11 return macro.formatter.text('Not storing any state until you send a cookie.')
12 if 'test' in macro.request.session:
13 return macro.formatter.text("Loaded value %d" % macro.request.session['test'])
14 import random
15 value = random.randint(1, 100000)
16 macro.request.session['test'] = value
17 return macro.formatter.text("Set to value %d" % value)
| |||||||||
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |