mercurial/hgweb/webutil.py
changeset 7345 55651328dfcc
parent 7311 de9c87fe1620
child 7361 9fe97eea5510
--- a/mercurial/hgweb/webutil.py	Fri Oct 31 15:28:06 2008 +0100
+++ b/mercurial/hgweb/webutil.py	Fri Nov 07 23:31:12 2008 +0100
@@ -6,7 +6,7 @@
 # This software may be used and distributed according to the terms
 # of the GNU General Public License, incorporated herein by reference.
 
-import os
+import os, copy
 from mercurial import match, patch
 from mercurial.node import hex, nullid
 from mercurial.repo import RepoError
@@ -196,3 +196,19 @@
         block.append(chunk)
     yield tmpl('diffblock', parity=parity.next(),
                lines=prettyprintlines(''.join(block)))
+
+class sessionvars(object):
+    def __init__(self, vars, start='?'):
+        self.start = start
+        self.vars = vars
+    def __getitem__(self, key):
+        return self.vars[key]
+    def __setitem__(self, key, value):
+        self.vars[key] = value
+    def __copy__(self):
+        return sessionvars(copy.copy(self.vars), self.start)
+    def __iter__(self):
+        separator = self.start
+        for key, value in self.vars.iteritems():
+            yield {'name': key, 'value': str(value), 'separator': separator}
+            separator = '&'