changeset 2227:00debb5be61a

cleanup ..
author Ashutosh Singla <ashu1461@gmail.com>
date Sat, 20 Jul 2013 23:54:16 +0530
parents 09a9bffa1581
children c992a1dda217
files MoinMoin/constants/keys.py MoinMoin/forms.py MoinMoin/items/__init__.py MoinMoin/themes/_tests/test_navi_bar.py
diffstat 4 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/constants/keys.py	Sat Jul 20 02:40:21 2013 +0530
+++ b/MoinMoin/constants/keys.py	Sat Jul 20 23:54:16 2013 +0530
@@ -114,6 +114,8 @@
 LATEST_REVS = 'latest_revs'
 ALL_REVS = 'all_revs'
 
+# key for composite name
+FQNAME = u'fqname'
 # Values that FIELD can take in the composite name: [NAMESPACE/][@FIELD/]NAME
 FIELDS = [
     NAME_EXACT, ITEMID, REVID, TAGS, USERID, ITEMLINKS, ITEMTRANSCLUSIONS
--- a/MoinMoin/forms.py	Sat Jul 20 02:40:21 2013 +0530
+++ b/MoinMoin/forms.py	Sat Jul 20 23:54:16 2013 +0530
@@ -84,7 +84,7 @@
     """
     names = meta.get(NAME)
     current_namespace = meta.get(NAMESPACE, fqname.namespace)
-    if names is None:
+    if not names:
         return
     if len(names) != len(set(names)):
         raise NameNotValidError(L_("The names in the name list must be unique."))
@@ -132,7 +132,7 @@
             self.invalid_name_msg = _(e)
             return self.note_error(element, state, 'invalid_name_msg')
         if state[FQNAME].field == ITEMID:
-            if not self.validitemid(meta.get(ITEMID)):
+            if not self.validitemid(meta.get(ITEMID, state[FQNAME].value)):
                 return self.note_error(element, state, 'invalid_itemid_msg')
         return True
 
--- a/MoinMoin/items/__init__.py	Sat Jul 20 02:40:21 2013 +0530
+++ b/MoinMoin/items/__init__.py	Sat Jul 20 23:54:16 2013 +0530
@@ -344,7 +344,10 @@
         """
         names = self.meta.get(NAME, [])
         if self.fqname.field == NAME_EXACT:
-            names.remove(self.fqname.value)
+            try:
+                names.remove(self.fqname.value)
+            except ValueError:
+                pass
             names.insert(0, self.fqname.value)
         return names
 
--- a/MoinMoin/themes/_tests/test_navi_bar.py	Sat Jul 20 02:40:21 2013 +0530
+++ b/MoinMoin/themes/_tests/test_navi_bar.py	Sat Jul 20 23:54:16 2013 +0530
@@ -41,13 +41,16 @@
         test_segment_name_1, test_item_name_1, test_item_exists_1 = test_result[0]
         test_segment_name_2, test_item_name_2, test_item_exists_2 = test_result[1]
         test_segment_name_3, test_item_name_3, test_item_exists_3 = test_result[2]
+        test_segment_name_4, test_item_name_4, test_item_exists_4 = test_result[3]
 
-        assert test_segment_name_1.value == 'some'
-        assert test_item_name_1.value == 'some'
-        assert test_segment_name_2.value == 'place'
-        assert test_item_name_2.value == 'some/place'
-        assert test_segment_name_3.value == 'test_item'
-        assert test_item_name_3.value == 'some/place/test_item'
+        assert test_segment_name_1.value == '~'
+        assert test_item_name_1.value == ''
+        assert test_segment_name_2.value == 'some'
+        assert test_item_name_2.value == 'some'
+        assert test_segment_name_3.value == 'place'
+        assert test_item_name_3.value == 'some/place'
+        assert test_segment_name_4.value == 'test_item'
+        assert test_item_name_4.value == 'some/place/test_item'
 
     def test_parent_item(self):
         test_result = ThemeSupport.parent_item(self.theme, 'moin/moin-2.0/Item')