changeset 4649:268004c7b206

merged moin/1.8
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 14 Mar 2009 17:02:31 +0100
parents 5e634ea82648 (current diff) 321ca881ce70 (diff)
children e673b8b21dc2
files MoinMoin/PageGraphicalEditor.py MoinMoin/action/AttachFile.py MoinMoin/config/multiconfig.py
diffstat 3 files changed, 70 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageGraphicalEditor.py	Sat Mar 14 14:27:37 2009 +0100
+++ b/MoinMoin/PageGraphicalEditor.py	Sat Mar 14 17:02:31 2009 +0100
@@ -312,7 +312,7 @@
         url_prefix_static = request.cfg.url_prefix_static
         url_prefix_local = request.cfg.url_prefix_local
         wikipage = wikiutil.quoteWikinameURL(self.page_name)
-        fckbasepath = url_prefix_local + '/applets/FCKeditor'
+        fckbasepath = request.cfg.url_prefix_fckeditor
         wikiurl = request.script_root + '/'
         themepath = '%s/%s' % (url_prefix_static, request.theme.name)
         smileypath = themepath + '/img'
--- a/MoinMoin/_tests/test_packages.py	Sat Mar 14 14:27:37 2009 +0100
+++ b/MoinMoin/_tests/test_packages.py	Sat Mar 14 17:02:31 2009 +0100
@@ -7,15 +7,20 @@
     @license: GNU GPL, see COPYING for details.
 """
 
+import os
+import py
 import tempfile
-import py
 import zipfile
 
-from MoinMoin import wikiutil
+from datetime import datetime
+from MoinMoin import user, wikiutil
+from MoinMoin.action import AttachFile
+from MoinMoin.action.PackagePages import PackagePages
+from MoinMoin.packages import Package, ScriptEngine, MOIN_PACKAGE_FILE, ZipPackage, packLine, unpackLine
+from MoinMoin._tests import become_superuser, create_page, nuke_page
 from MoinMoin.Page import Page
-from MoinMoin.action.PackagePages import PackagePages
-from MoinMoin.packages import Package, ScriptEngine, MOIN_PACKAGE_FILE, packLine, unpackLine
-from MoinMoin._tests import become_superuser
+from MoinMoin.PageEditor import PageEditor
+
 
 
 class DebugPackage(Package, ScriptEngine):
@@ -110,5 +115,59 @@
         temp = tempfile.NamedTemporaryFile(suffix='.zip')
         package.collectpackage(['___//THIS PAGE SHOULD NOT EXIST\\___'], temp)
         assert not zipfile.is_zipfile(temp.name)
+
+
+class TestRealPackageInstallation:
+
+
+    def create_package(self, script, page=None):
+        # creates the package example zip file
+        userid = user.getUserIdentification(self.request)
+        COMPRESSION_LEVEL = zipfile.ZIP_DEFLATED
+        zip_file = tempfile.mkstemp(suffix='.zip')[1]
+        zf = zipfile.ZipFile(zip_file, "w", COMPRESSION_LEVEL)
+        if page:
+            timestamp = wikiutil.version2timestamp(page.mtime_usecs())
+            zi = zipfile.ZipInfo(filename="1", date_time=datetime.fromtimestamp(timestamp).timetuple()[:6])
+            zi.compress_type = COMPRESSION_LEVEL
+            zf.writestr(zi, page.get_raw_body().encode("utf-8"))
+        zf.writestr("1_attachment", "sample attachment")
+        zf.writestr(MOIN_PACKAGE_FILE, script.encode("utf-8"))
+        zf.close()
+        return zip_file
+
+    def testAttachments_after_page_creation(self):
+        pagename = u'PackageTestPageCreatedFirst'
+        page = create_page(self.request, pagename, u"This page has not yet an attachments dir")
+        script = u"""MoinMoinPackage|1
+AddRevision|1|%(pagename)s
+AddAttachment|1_attachment|my_test.txt|%(pagename)s
+Print|Thank you for using PackagePages!
+""" % {"pagename": pagename}
+        zip_file = self.create_package(script, page)
+        package = ZipPackage(self.request, zip_file)
+        package.installPackage()
+        assert Page(self.request, pagename).exists()
+        assert AttachFile.exists(self.request, pagename, "my_test.txt")
+
+        nuke_page(self.request, pagename)
+        os.unlink(zip_file)
+
+    def testAttachments_without_page_creation(self):
+        pagename = u"PackageAttachmentAttachWithoutPageCreation"
+        script = u"""MoinMoinPackage|1
+AddAttachment|1_attachment|my_test.txt|%(pagename)s
+Print|Thank you for using PackagePages!
+""" % {"pagename": pagename}
+        zip_file = self.create_package(script)
+        package = ZipPackage(self.request, zip_file)
+        package.installPackage()
+        assert not Page(self.request, pagename).exists()
+        assert AttachFile.exists(self.request, pagename, "my_test.txt")
+
+        nuke_page(self.request, pagename)
+        os.unlink(zip_file)
+
+
 coverage_modules = ['MoinMoin.packages']
 
--- a/MoinMoin/config/multiconfig.py	Sat Mar 14 14:27:37 2009 +0100
+++ b/MoinMoin/config/multiconfig.py	Sat Mar 14 17:02:31 2009 +0100
@@ -369,6 +369,9 @@
         if self.url_prefix_local is None:
             self.url_prefix_local = self.url_prefix_static
 
+        if self.url_prefix_fckeditor is None:
+            self.url_prefix_fckeditor = self.url_prefix_local + '/applets/FCKeditor'
+
         if self.secrets is None:  # admin did not setup a real secret, so make up something
             self.secrets = self.calc_secrets()
 
@@ -915,6 +918,8 @@
      "used as the base URL for icons, css, etc. - includes the moin version number and changes on every release. This replaces the deprecated and sometimes confusing `url_prefix = '/wiki'` setting."),
     ('url_prefix_local', None,
      "used as the base URL for some Javascript - set this to a URL on same server as the wiki if your url_prefix_static points to a different server."),
+    ('url_prefix_fckeditor', None,
+     "used as the base URL for FCKeditor - similar to url_prefix_local, but just for FCKeditor."),
 
     ('url_prefix_action', None,
      "Use 'action' to enable action URL generation to be compatible with robots.txt. It will generate .../action/info/PageName?action=info then. Recommended for internet wikis."),