changeset 2251:22d1b58d785f

Fix for issue 19. Redirects for deault roots are now done in the show function itself.
author Ashutosh Singla <ashu1461@gmail.com>
date Sat, 24 Aug 2013 15:52:53 +0530
parents eb0525763040
children ecd43cdbb9b6
files MoinMoin/apps/frontend/views.py MoinMoin/items/__init__.py
diffstat 2 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Tue Aug 20 20:23:35 2013 +0530
+++ b/MoinMoin/apps/frontend/views.py	Sat Aug 24 15:52:53 2013 +0530
@@ -361,6 +361,10 @@
 def show_item(item_name, rev):
     item_displayed.send(app._get_current_object(),
                         item_name=item_name)
+    fqname = split_fqname(item_name)
+    if not fqname.value and fqname.field == NAME_EXACT:
+        fqname = fqname.get_root_fqname()
+        return redirect(url_for_item(fqname)) 
     try:
         item = Item.create(item_name, rev_id=rev)
         flaskg.user.add_trail(item_name)
@@ -368,7 +372,6 @@
     except AccessDenied:
         abort(403)
     except FieldNotUniqueError:
-        fqname = split_fqname(item_name)
         revs = flaskg.storage.documents(**fqname.query)
         fq_names = []
         for rev in revs:
--- a/MoinMoin/items/__init__.py	Tue Aug 20 20:23:35 2013 +0530
+++ b/MoinMoin/items/__init__.py	Sat Aug 24 15:52:53 2013 +0530
@@ -275,7 +275,7 @@
         return cls(*args, **kw)
 
     @classmethod
-    def create(cls, name=u'', itemtype=None, contenttype=None, rev_id=CURRENT, item=None, set_root=False):
+    def create(cls, name=u'', itemtype=None, contenttype=None, rev_id=CURRENT, item=None):
         """
         Create a highlevel Item by looking up :name or directly wrapping
         :item and extract the Revision designated by :rev_id revision.
@@ -296,8 +296,6 @@
         fqname = split_fqname(name)
         if fqname.field not in UFIELDS:  # Need a unique key to extract stored item.
             raise FieldNotUniqueError("field {0} is not in UFIELDS".format(fqname.field))
-        if set_root and not fqname.value and fqname.field == NAME_EXACT:
-            fqname = fqname.get_root_fqname()
 
         rev = get_storage_revision(fqname, itemtype, contenttype, rev_id, item)
         contenttype = rev.meta.get(CONTENTTYPE) or contenttype