diff MoinMoin/user.py @ 1923:eefebea247a0

user profiles: store lists with key[]=val1\tval2... (thanks to Johannes Berg)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 01 Apr 2007 14:43:08 +0200
parents b06ef2a53efa
children 740d9939ffe9
line wrap: on
line diff
--- a/MoinMoin/user.py	Sun Apr 01 00:17:15 2007 +0200
+++ b/MoinMoin/user.py	Sun Apr 01 14:43:08 2007 +0200
@@ -362,7 +362,12 @@
                 key, val = line.strip().split('=', 1)
                 if key not in self._cfg.user_transient_fields and key[0] != '_':
                     # Decode list values
-                    if key in ['quicklinks', 'subscribed_pages']:
+                    if key.endswith('[]'):
+                        key = key[:-2]
+                        val = decodeList(val)
+                    # for compatibility reading old files, keep these explicit
+                    # we will store them with [] appended
+                    elif key in ['quicklinks', 'subscribed_pages']:
                         val = decodeList(val)
                     user_data[key] = val
             except ValueError:
@@ -522,7 +527,8 @@
         for key, value in attrs:
             if key not in self._cfg.user_transient_fields and key[0] != '_':
                 # Encode list values
-                if key in ['quicklinks', 'subscribed_pages']:
+                if isinstance(value, list):
+                    key += '[]'
                     value = encodeList(value)
                 line = u"%s=%s\n" % (key, unicode(value))
                 data.write(line)