[Checkins] SVN: zope3org/trunk/src/zorg/wikification/browser/ Added file extensions to wiki links

Uwe Oestermeier uwe_oestermeier at iwm-kmrc.de
Thu May 4 13:11:56 EDT 2006


Log message for revision 67966:
  Added file extensions to wiki links

Changed:
  U   zope3org/trunk/src/zorg/wikification/browser/templates/wiki_newpage.pt
  U   zope3org/trunk/src/zorg/wikification/browser/templates/wiki_rename.pt
  U   zope3org/trunk/src/zorg/wikification/browser/wikilink.py
  U   zope3org/trunk/src/zorg/wikification/browser/wikipage.py

-=-
Modified: zope3org/trunk/src/zorg/wikification/browser/templates/wiki_newpage.pt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/templates/wiki_newpage.pt	2006-05-04 17:10:23 UTC (rev 67965)
+++ zope3org/trunk/src/zorg/wikification/browser/templates/wiki_newpage.pt	2006-05-04 17:11:56 UTC (rev 67966)
@@ -59,6 +59,7 @@
                 <td>
                     <input name="entry_submit" type="submit" value="Submit">
                     <input name="cancel_submit" type="reset" value="Cancel"/>
+                    <input tal:condition="view/isUnique" name="scope" id="scope" type="hidden" value="off">
                 </td>
             </tr>
         </table>

Modified: zope3org/trunk/src/zorg/wikification/browser/templates/wiki_rename.pt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/templates/wiki_rename.pt	2006-05-04 17:10:23 UTC (rev 67965)
+++ zope3org/trunk/src/zorg/wikification/browser/templates/wiki_rename.pt	2006-05-04 17:11:56 UTC (rev 67966)
@@ -33,6 +33,7 @@
                 <td>
                     <input name="entry_submit" type="submit" value="Submit">
                     <input name="cancel_submit" type="reset" value="Cancel"/>
+                    <input tal:condition="view/isUnique" name="scope" id="scope" type="hidden" value="off">
                 </td>
             </tr>
         </table>

Modified: zope3org/trunk/src/zorg/wikification/browser/wikilink.py
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/wikilink.py	2006-05-04 17:10:23 UTC (rev 67965)
+++ zope3org/trunk/src/zorg/wikification/browser/wikilink.py	2006-05-04 17:11:56 UTC (rev 67966)
@@ -196,6 +196,12 @@
     def onAbsoluteLink(self, link) :
         """ Event handler that can be specialized. """
         return link
+        
+    def traverseName(self, node, name) :
+        for ext in u'', u'.html', u'.txt' :
+            if (name + ext) in node :
+                return zapi.traverseName(node, name + ext)
+        raise TraversalError
 
     def traverseLink(self, node, link) :
         """ Help method that follows a relative link from a context node. """
@@ -207,7 +213,7 @@
             try :
                 name = path[0]
                 name = unicode(name, encoding='utf-8')
-                node = zapi.traverseName(node, name)
+                node = self.traverseName(node, name)
                 name = path.pop(0)
             except (TraversalError, UnicodeEncodeError, UnicodeDecodeError) :
                 break
@@ -388,7 +394,7 @@
             return False, link
         else :
             node = page.container
-             
+        
         node, path = self.traverseLink(node, link)
         if path :
             return True, self.absoluteAddLink(node, path)
@@ -602,7 +608,7 @@
         
     """
     
-    global_scope = True        # default: depends on usecase
+    global_scope = False        # default: depends on usecase
     render_form = False
     
     def textLink(self) :
@@ -714,7 +720,7 @@
             dc.title = title
         if description :
             dc.description = description
-        
+       
         return name.encode("utf-8")
         
     def performSubstitution(self) :
@@ -749,7 +755,8 @@
         contenttype = self.page.parameter('contenttype')
 
         filename = self.filename("data", label)
-        name = self.page.parameter('name') or unicode(filename, encoding="utf-8")
+        filename = unicode(filename, encoding="utf-8")
+        name = filename or self.page.parameter('name')
 
         if not contenttype :
             contenttype = contenttypes.guess_content_type(filename)[0]

Modified: zope3org/trunk/src/zorg/wikification/browser/wikipage.py
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/wikipage.py	2006-05-04 17:10:23 UTC (rev 67965)
+++ zope3org/trunk/src/zorg/wikification/browser/wikipage.py	2006-05-04 17:11:56 UTC (rev 67966)
@@ -595,6 +595,8 @@
     def _modifyLink(self, cmd, link_id) :
         """ Help method that modified a link and saves the result into
             the file.
+            
+            Returns the modified file or None if the file was not changed.
         """
         processor = ILinkProcessor(self)
         processor.command = cmd
@@ -606,6 +608,8 @@
         if newbody != file.data :
             file.data = newbody
             zope.event.notify(ObjectModifiedEvent(file))
+            return file
+        return None
         
     def uploadFile(self, link_id) :
         """ Uploads a file for a wikified link and redirects 
@@ -621,7 +625,7 @@
         self._modifyLink('image', link_id)
         self.request.response.redirect(self.nextURL())
         
-    def modifyLink(self, cmd, link_id, verbose=True) :
+    def modifyLink(self, cmd, link_id) :
         """ Modify a single link dynamically and return the new
             body.
         """



More information about the Checkins mailing list