annotate MoinMoin/auth/_PHPsessionParser.py @ 5829:a744f573fe30

advancedsearch: fix problem with non-ascii chars breaking up words for OR and NOT terms
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 04 Feb 2012 16:52:24 +0100
parents 01f05e74aa9c
children
rev   line source
301
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
1 """
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
2 MoinMoin - Parsing of PHP session files
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
3
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1419
diff changeset
4 @copyright: 2005 MoinMoin:AlexanderSchremmer (Thanks to Spreadshirt)
301
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
5 @license: GNU GPL, see COPYING for details.
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
6 """
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
7
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
8 #Known minor bugs/questions/ideas:
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
9 #How does object demarshalling work?
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
10 #The order of the python dictionaries is not stable compared to the PHP arrays
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
11 #The loader does not check the owner of the files, so be aware of faked session
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
12 #files.
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
13
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
14 import os
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
15 from MoinMoin import wikiutil
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
16
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
17 s_prefix = "sess_"
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
18 s_path = "/tmp"
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
19
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
20 class UnknownObject(object):
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
21 """ Used in the return value if the input data could not be parsed. """
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
22 def __init__(self, pos):
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
23 self.pos = pos
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
24
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
25 def __repr__(self):
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
26 return "<Unknown object at pos %i>" % self.pos
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
27
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
28 def transformList(items):
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
29 """ Transforms a list [1, 2, 3, 4, ...] into a
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
30 [(1, 2), (3, 4), ...] generator. """
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
31 for i in xrange(0, len(items), 2):
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
32 yield (items[i], items[i+1])
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
33 raise StopIteration
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
34
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
35 def parseValue(string, start=0):
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
36 """ Parses the inner structure. """
1419
f7f415cc1332 replace most find() calls by in/index()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 948
diff changeset
37 # TODO: replace "string" by something else
301
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
38 #print "Parsing %r" % (string[start:], )
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
39
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
40 val_type = string[start]
1419
f7f415cc1332 replace most find() calls by in/index()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 948
diff changeset
41 try:
f7f415cc1332 replace most find() calls by in/index()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 948
diff changeset
42 header_end = string.index(':', 3+start)
301
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
43 first_data = string[start+2:header_end]
1419
f7f415cc1332 replace most find() calls by in/index()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 948
diff changeset
44 except ValueError:
301
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
45 first_data = None
948
28ea5b3802b1 whitespace-only cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 752
diff changeset
46
301
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
47 #print "Saw type %r, first_data is %r." % (val_type, first_data)
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
48 if val_type == 'a': # array (in Python rather a mixture of a list and a dict)
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
49 i = 0
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
50 items = []
948
28ea5b3802b1 whitespace-only cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 752
diff changeset
51
301
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
52 current_pos = header_end+2
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
53 data = string
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
54 while i != (int(first_data) * 2):
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
55 item, current_pos = parseValue(data, current_pos)
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
56 items.append(item)
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
57 i += 1
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
58 current_pos += 1
948
28ea5b3802b1 whitespace-only cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 752
diff changeset
59
301
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
60 t_list = list(transformList(items))
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
61 try:
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
62 result = dict(t_list) # note that dict does not retain the order
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
63 except TypeError:
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
64 result = list(t_list)
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
65 #print "Warning, could not convert to dict: %r" % (result, )
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
66 return result, current_pos
948
28ea5b3802b1 whitespace-only cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 752
diff changeset
67
301
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
68 if val_type == 's': # string
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
69 current_pos = header_end+2
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
70 end = current_pos + int(first_data)
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
71 data = string[current_pos:end]
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
72 current_pos = end+1
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
73 if data.startswith("a:"): #Sometimes, arrays are marshalled as strings.
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
74 try:
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
75 data = parseValue(data, 0)[0]
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
76 except ValueError: #Hmm, wrongly guessed. Just an ordinary string
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
77 pass
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
78 return data, current_pos
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
79
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
80 if val_type in ('i', 'b'): # integer or boolean
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
81 current_pos = start+2
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
82 str_buffer = ""
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
83 while current_pos != len(string):
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
84 cur_char = string[current_pos]
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
85 if cur_char.isdigit() or cur_char == "-":
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
86 str_buffer += cur_char
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
87 else:
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
88 cast = (val_type == 'i') and int or (lambda x: bool(int(x)))
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
89 return cast(str_buffer), current_pos
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
90 current_pos += 1
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
91
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
92 if val_type == "N": # Null, called None in Python
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
93 return None, start+1
948
28ea5b3802b1 whitespace-only cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 752
diff changeset
94
301
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
95 return UnknownObject(start), start+1
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
96
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
97 def parseSession(boxed):
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
98 """ Parses the outer structure that is similar to a dict. """
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
99 current_pos = 0
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
100 session_dict = {}
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
101 while current_pos < len(boxed):
1419
f7f415cc1332 replace most find() calls by in/index()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 948
diff changeset
102 name_end = boxed.find("|", current_pos) # TODO: replace by .index()?
301
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
103 name = boxed[current_pos:name_end]
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
104 current_pos = name_end+1
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
105 data, current_pos = parseValue(boxed, current_pos)
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
106 current_pos += 1
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
107 session_dict[name] = data
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
108
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
109 return session_dict
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
110
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
111 def loadSession(key, path=s_path, prefix=s_prefix):
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
112 """ Loads a particular session from the directory. The key needs to be the
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
113 session id. """
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
114 key = key.lower()
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
115 filename = os.path.join(path, prefix + wikiutil.taintfilename(key))
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
116
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
117 try:
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
118 f = open(filename, "rb")
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
119 except IOError, e:
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
120 if e.errno == 2:
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
121 return None # session does not exist
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
122 else:
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
123 raise
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
124
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
125 blob = f.read()
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
126 f.close()
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
127 return parseSession(blob)
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
128
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
129 def listSessions(path=s_path, prefix=s_prefix):
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
130 """ Lists all sessions in a particular directory. """
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
131 return [os.path.basename(x).replace(s_prefix, '') for x in os.listdir(s_path)
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
132 if x.startswith(s_prefix)]
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
133
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
134 if __name__ == '__main__':
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
135 # testing code
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
136 import time
948
28ea5b3802b1 whitespace-only cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 752
diff changeset
137 a = time.clock()
28ea5b3802b1 whitespace-only cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 752
diff changeset
138
301
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
139 #print s
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
140 p_s = loadSession("...")
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
141 import pprint
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
142 pprint.pprint(p_s)
301
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
143 print time.clock() - a
6b02d608c5f4 Added SSO support/auth module for PHP based applications.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents:
diff changeset
144 print listSessions()
948
28ea5b3802b1 whitespace-only cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 752
diff changeset
145