mod_python : Session #3

handler:

 

def table(req,assoc):
    req.write(‘<table border="1px" >\n’);
    for  x in assoc:
        if assoc[x] != None and  len(assoc[x])  > 0:
            req.write("<tr><td>%s</td><td>%s</td></tr>\n" % (str(x),
                            cgi.escape(assoc[x])))

    req.write("</table>\n");

def handler(req):
    session = Session.Session(req)
    try:
        session[‘counter’] += 1
    except:
        session[‘counter’] = 1

    session.save()

    req.write("<html>\n");
    req.write("<body>\n");
    req.write("<h1>\n");
    req.write("Hello.%d\n" % session[‘counter’]);
    req.write("</h1>\n");

    out={}
    for x in dir(session):
        try:
             out[x] = str(eval(‘session.’+x))
        except:
            pass

    table(req,out)
    req.write("</body>\n");
    req.write("</html>\n");
    return apache.OK

_invalid 0
invalidate <bound method DbmSession.invalidate of {’counter’: 2}>
__module__ mod_python.Session
copy <built-in method copy of DbmSession object at 0xb6eda92c>
_sid dcda921182256ec1aaf83a8c7c38136a
__str__ <method-wrapper object at 0xb68556cc>
iteritems <built-in method iteritems of DbmSession object at 0xb6eda92c>
__getattribute__ <method-wrapper object at 0xb685566c>
_req <mp_request object at 0xb6e9ccc4>
make_cookie <bound method DbmSession.make_cookie of {’counter’: 2}>
unlock <bound method DbmSession.unlock of {’counter’: 2}>
has_key <built-in method has_key of DbmSession object at 0xb6eda92c>
do_cleanup <bound method DbmSession.do_cleanup of {’counter’: 2}>
_locked 1
__dict__ {’_invalid’: 0, ‘_dbmfile’: ‘/tmp/mp_sess.dbm’, ‘_new’: 0, ‘_sid’: ‘dcda921182256ec1aaf83a8c7c38136a’, ‘_lock’: 1, ‘_req’: <mp_request object at 0xb6e9ccc4>, ‘_dbmtype’: <module ‘dbhash’ from ‘/usr/lib/python2.4/dbhash.pyc’>, ‘_accessed’: 1214240372.5281031, ‘_secret’: None, ‘_locked’: 1, ‘_timeout’: 1800, ‘_created’: 1214240356.4873681}
__lt__ <method-wrapper object at 0xb685596c>
_accessed 1214240372.53
__weakref__ None
id <bound method DbmSession.id of {’counter’: 2}>
__init__ <bound method DbmSession.__init__ of {’counter’: 2}>
__setattr__ <method-wrapper object at 0xb68556cc>
__reduce_ex__ <built-in method __reduce_ex__ of DbmSession object at 0xb6eda92c>
__new__ <built-in method __new__ of type object at 0xb76aa660>
do_delete <bound method DbmSession.do_delete of {’counter’: 2}>
__contains__ <built-in method __contains__ of DbmSession object at 0xb6eda92c>
init_lock <bound method DbmSession.init_lock of {’counter’: 2}>
_lock 1
__class__ <class ‘mod_python.Session.DbmSession’>
load <bound method DbmSession.load of {’counter’: 2}>
__cmp__ <method-wrapper object at 0xb6919a4c>
keys <built-in method keys of DbmSession object at 0xb6eda92c>
cleanup <bound method DbmSession.cleanup of {’counter’: 2}>
itervalues <built-in method itervalues of DbmSession object at 0xb6eda92c>
do_load <bound method DbmSession.do_load of {’counter’: 2}>
get <built-in method get of DbmSession object at 0xb6eda92c>
save <bound method DbmSession.save of {’counter’: 2}>
__doc__ None
__len__ <method-wrapper object at 0xb68556cc>
__ne__ <method-wrapper object at 0xb685596c>
__getitem__ <built-in method __getitem__ of DbmSession object at 0xb6eda92c>
_new 0
__del__ <bound method DbmSession.__del__ of {’counter’: 2}>
__reduce__ <built-in method __reduce__ of DbmSession object at 0xb6eda92c>
last_accessed <bound method DbmSession.last_accessed of {’counter’: 2}>
update <built-in method update of DbmSession object at 0xb6eda92c>
is_new <bound method DbmSession.is_new of {’counter’: 2}>
_timeout 1800
__iter__ <method-wrapper object at 0xb68556cc>
_secret None
pop <built-in method pop of DbmSession object at 0xb6eda92c>
__gt__ <method-wrapper object at 0xb685566c>
fromkeys <built-in method fromkeys of type object at 0x83fbd34>
popitem <built-in method popitem of DbmSession object at 0xb6eda92c>
_set_dbm_type <bound method DbmSession._set_dbm_type of {’counter’: 2}>
__eq__ <method-wrapper object at 0xb685566c>
iterkeys <built-in method iterkeys of DbmSession object at 0xb6eda92c>
lock <bound method DbmSession.lock of {’counter’: 2}>
__delitem__ <method-wrapper object at 0xb685566c>
_dbmfile /tmp/mp_sess.dbm
setdefault <built-in method setdefault of DbmSession object at 0xb6eda92c>
created <bound method DbmSession.created of {’counter’: 2}>
items <built-in method items of DbmSession object at 0xb6eda92c>
clear <built-in method clear of DbmSession object at 0xb6eda92c>
__setitem__ <method-wrapper object at 0xb685596c>
_dbmtype <module ‘dbhash’ from ‘/usr/lib/python2.4/dbhash.pyc’>
_get_dbm <bound method DbmSession._get_dbm of {’counter’: 2}>
__delattr__ <method-wrapper object at 0xb6919a4c>
__le__ <method-wrapper object at 0xb685596c>
values <built-in method values of DbmSession object at 0xb6eda92c>
__repr__ <method-wrapper object at 0xb685596c>
timeout <bound method DbmSession.timeout of {’counter’: 2}>
__hash__ <method-wrapper object at 0xb68556cc>
_created 1214240356.49
do_save <bound method DbmSession.do_save of {’counter’: 2}>
set_timeout <bound method DbmSession.set_timeout of {’counter’: 2}>
__ge__ <method-wrapper object at 0xb685596c>
delete <bound method DbmSession.delete of {’counter’: 2}>
カテゴリー: 未分類 パーマリンク

コメントを残す

以下に詳細を記入するか、アイコンをクリックしてログインしてください。

WordPress.com ロゴ

WordPress.com アカウントを使ってコメントしています。 ログアウト / 変更 )

Twitter 画像

Twitter アカウントを使ってコメントしています。 ログアウト / 変更 )

Facebook の写真

Facebook アカウントを使ってコメントしています。 ログアウト / 変更 )

Google+ フォト

Google+ アカウントを使ってコメントしています。 ログアウト / 変更 )

%s と連携中