diff MoinMoin/themes/__init__.py @ 2253:46b74c363c6f

UI for indicating multiple names and switching namespaces.
author Ashutosh Singla <ashu1461@gmail.com>
date Mon, 02 Sep 2013 17:41:54 +0530
parents ecd43cdbb9b6
children 6dd5af01d54d
line wrap: on
line diff
--- a/MoinMoin/themes/__init__.py	Tue Aug 27 19:11:15 2013 +0530
+++ b/MoinMoin/themes/__init__.py	Mon Sep 02 17:41:54 2013 +0530
@@ -298,6 +298,31 @@
             url = url or url_for('frontend.login')
         return url
 
+    def get_fqnames(self, fqname):
+        """
+        Return the list of other fqnames associated with the item.
+        """
+        if fqname.field != NAME_EXACT:
+            return []
+        item = self.storage.get_item(**fqname.query)
+        fqnames = item.fqnames
+        fqnames.remove(fqname)
+        return fqnames or []
+
+    def get_namespaces(self, ns):
+        """
+        Return the list of tuples (composite name, namespace) referring to namespaces other
+        than the current namespace.
+        """
+        ns = u'' if ns.value == '~' else ns.value
+        namespace_root_mapping = []
+        for namespace, _ in app.cfg.namespace_mapping:
+            namespace = namespace.rstrip('/')
+            if namespace != ns:
+                fq_namespace = CompositeName(namespace, NAME_EXACT, u'')
+                namespace_root_mapping.append((namespace or '~', fq_namespace.get_root_fqname()))
+        return namespace_root_mapping
+
 
 def get_editor_info(meta, external=False):
     addr = meta.get(ADDRESS)