Hi,
I believe the following might fix the following issues:
- pokersite should expire session when logout
- args2packets should convert utf-8 to ascii before calling eval
Feel free to review and apply hunks.
--
bou ^
Index: pokernetwork/pokersite.py
===================================================================
--- pokernetwork/pokersite.py (revision 4232)
+++ pokernetwork/pokersite.py (working copy)
@@ -55,8 +55,32 @@
maps.append(attributes)
return maps
+from types import *
+
+def walk(tree, convert):
+ if type(tree) is TupleType or type(tree) is ListType:
+ result = map(lambda x: walk(x, convert), tree)
+ if type(tree) is TupleType:
+ return tuple(result)
+ else:
+ return result
+ elif type(tree) is DictionaryType:
+ new_tree = {}
+ for (key, value) in tree.iteritems():
+ converted_key = convert(str(key))
+ new_tree[converted_key] = walk(value, convert)
+ return new_tree
+ elif ( type(tree) is UnicodeType or type(tree) is StringType ):
+ return convert(tree)
+ else:
+ return tree
+
+def fromutf8(tree, encoding):
+ return walk(tree, lambda x: x.encode(encoding))
+
def args2packets(args):
packets = []
+ args = fromutf8(args, 'ISO-8859-1')
for arg in args:
if re.match("^[a-zA-Z]+$", arg['type']):
try:
@@ -264,6 +288,7 @@
#
self.memcache.delete(str(session.memcache_serial))
self.memcache.replace(session.uid, '0')
+ session.expire()
elif serial != session.memcache_serial:
#
# if the user changed personality, delete old serial, add new one and
@@ -272,7 +297,7 @@
self.memcache.delete(str(session.memcache_serial))
self.memcache.add(str(serial), session.uid)
self.memcache.replace(session.uid, str(serial))
- if len(session.avatar.tables) == 0:
+ if not session.expired and len(session.avatar.tables) == 0:
session.expire()
return True
Index: tests/test-pokersite.py.in
===================================================================
--- tests/test-pokersite.py.in (revision 4232)
+++ tests/test-pokersite.py.in (working copy)
@@ -375,7 +375,7 @@
self.site.updateSession(session)
self.assertEquals(0, int(self.site.memcache.get(session.uid)))
self.assertEquals(None, self.site.memcache.get(str(serial)))
- session.expire()
+ self.assertEquals(True, session.expired)
def test04_06_updateSession(self):
"""
_______________________________________________
Pokersource-users mailing list
[email protected]
https://mail.gna.org/listinfo/pokersource-users