[Zope-Checkins] SVN: Zope/trunk/ - LP #142750 and LP #142481: To prevent confusion when choosing an Id and
Jens Vagelpohl
jens at dataflake.org
Wed May 19 08:08:38 EDT 2010
Log message for revision 112531:
- LP #142750 and LP #142481: To prevent confusion when choosing an Id and
to avoid issues when creating two VirtualHostMonsters in the same
container the VirtualHostMoster now has a default Id. It can no longer
be selected, and the intermediary Add view is gone.
Changed:
U Zope/trunk/doc/CHANGES.rst
U Zope/trunk/src/Products/SiteAccess/VirtualHostMonster.py
U Zope/trunk/src/Products/SiteAccess/tests/testVirtualHostMonster.py
D Zope/trunk/src/Products/SiteAccess/www/VirtualHostMonsterAdd.dtml
-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst 2010-05-19 12:08:33 UTC (rev 112530)
+++ Zope/trunk/doc/CHANGES.rst 2010-05-19 12:08:37 UTC (rev 112531)
@@ -162,6 +162,11 @@
Bugs Fixed
++++++++++
+- LP #142750 and LP #142481: To prevent confusion when choosing an Id and
+ to avoid issues when creating two VirtualHostMonsters in the same
+ container the VirtualHostMoster now has a default Id. It can no longer
+ be selected, and the intermediary Add view is gone.
+
- LP #142451: If non-recursive ownership changes are made using
``changeOwnership``, do not touch any children.
Modified: Zope/trunk/src/Products/SiteAccess/VirtualHostMonster.py
===================================================================
--- Zope/trunk/src/Products/SiteAccess/VirtualHostMonster.py 2010-05-19 12:08:33 UTC (rev 112530)
+++ Zope/trunk/src/Products/SiteAccess/VirtualHostMonster.py 2010-05-19 12:08:37 UTC (rev 112531)
@@ -30,6 +30,7 @@
meta_type='Virtual Host Monster'
priority = 25
+ id = 'VHM'
title = ''
lines = ()
have_map = 0
@@ -255,17 +256,17 @@
InitializeClass(VirtualHostMonster)
-def manage_addVirtualHostMonster(self, id, REQUEST=None, **ignored):
+def manage_addVirtualHostMonster(self, REQUEST=None, **ignored):
""" """
+ container = self.this()
vhm = VirtualHostMonster()
- vhm.id = str(id)
- if REQUEST:
- return vhm.manage_addToContainer(self.this(),
- '%s/manage_main' % REQUEST['URL1'])
- else:
- vhm.addToContainer(self.this())
+ container._setObject(vhm.getId(), vhm)
+ if REQUEST is not None:
+ goto = '%s/manage_main' % self.absolute_url()
+ qs = 'manage_tabs_message=Virtual+Host+Monster+added.'
+ REQUEST['RESPONSE'].redirect('%s?%s' % (goto, qs))
+
constructors = (
- ('manage_addVirtualHostMonsterForm', DTMLFile('www/VirtualHostMonsterAdd', globals())),
('manage_addVirtualHostMonster', manage_addVirtualHostMonster),
)
Modified: Zope/trunk/src/Products/SiteAccess/tests/testVirtualHostMonster.py
===================================================================
--- Zope/trunk/src/Products/SiteAccess/tests/testVirtualHostMonster.py 2010-05-19 12:08:33 UTC (rev 112530)
+++ Zope/trunk/src/Products/SiteAccess/tests/testVirtualHostMonster.py 2010-05-19 12:08:37 UTC (rev 112531)
@@ -111,9 +111,68 @@
setattr(VHMRegressions, 'testTraverse%s' % i, test)
+class VHMAddingTests(unittest.TestCase):
+
+ def setUp(self):
+ from OFS.Folder import Folder
+ super(VHMAddingTests, self).setUp()
+ self.root = Folder('root')
+
+ def _makeOne(self):
+ from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster
+ return VirtualHostMonster()
+
+ def test_add_with_existing_vhm(self):
+ from Products.SiteAccess.VirtualHostMonster import \
+ manage_addVirtualHostMonster
+ from zExceptions import BadRequest
+ vhm1 = self._makeOne()
+ vhm1.manage_addToContainer(self.root)
+
+ vhm2 = self._makeOne()
+ self.assertRaises(BadRequest, vhm2.manage_addToContainer, self.root)
+ self.assertRaises( BadRequest
+ , manage_addVirtualHostMonster
+ , self.root
+ )
+
+ def test_add_id_collision(self):
+ from OFS.Folder import Folder
+ from Products.SiteAccess.VirtualHostMonster import \
+ manage_addVirtualHostMonster
+ from zExceptions import BadRequest
+ self.root._setObject('VHM', Folder('VHM'))
+ vhm1 = self._makeOne()
+
+ self.assertRaises(BadRequest, vhm1.manage_addToContainer, self.root)
+ self.assertRaises( BadRequest
+ , manage_addVirtualHostMonster
+ , self.root
+ )
+
+ def test_add_addToContainer(self):
+ from ZPublisher.BeforeTraverse import queryBeforeTraverse
+ vhm1 = self._makeOne()
+ vhm1.manage_addToContainer(self.root)
+
+ self.failUnless(vhm1.getId() in self.root.objectIds())
+ self.failUnless(queryBeforeTraverse(self.root, vhm1.meta_type))
+
+ def test_add_manage_addVirtualHostMonster(self):
+ from Products.SiteAccess.VirtualHostMonster import \
+ manage_addVirtualHostMonster
+ from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster
+ from ZPublisher.BeforeTraverse import queryBeforeTraverse
+ manage_addVirtualHostMonster(self.root)
+
+ self.failUnless(VirtualHostMonster.id in self.root.objectIds())
+ hook = queryBeforeTraverse(self.root, VirtualHostMonster.meta_type)
+ self.failUnless(hook)
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(VHMRegressions))
+ suite.addTest(unittest.makeSuite(VHMAddingTests))
return suite
if __name__ == '__main__':
Deleted: Zope/trunk/src/Products/SiteAccess/www/VirtualHostMonsterAdd.dtml
===================================================================
--- Zope/trunk/src/Products/SiteAccess/www/VirtualHostMonsterAdd.dtml 2010-05-19 12:08:33 UTC (rev 112530)
+++ Zope/trunk/src/Products/SiteAccess/www/VirtualHostMonsterAdd.dtml 2010-05-19 12:08:37 UTC (rev 112531)
@@ -1,61 +0,0 @@
-<dtml-var manage_page_header>
-
-<dtml-let form_title="'Add Virtual Host Monster'">
- <dtml-var manage_form_title>
-</dtml-let>
-
-<p class="form-help">
-A Virtual Host Monster changes the URLs generated by all objects
-within the same Folder, using information passed to it in special URL
-path elements. This is useful if you are using some rewriting tool
-(Apache or an Access Rule, for example) to insert these special
-elements into your URL.
-</p>
-
-<p class="form-help">
-To set the protocol ('http', 'https') and host ('www.foo.com') portion
-of generated URLs, insert "VirtualHostBase", the protocol,
-and the host into the path.
-</p>
-
-<p class="form-help">
-Insert "VirtualHostRoot" directly after the name of the
-Folder that is supposed to be the root of the virtual host.<br><br>
-For example, to publish Folder "/foo" as <b>http://www.foo.com/</b>,
-put a Virtual Host Monster in the root folder and rewrite requests for that
-URL to <b>/VirtualHostBase/http/www.foo.com/foo/VirtualHostRoot/</b>
-</p>
-
-<p class="form-help">
-Values affected include DTML variables starting with URL or BASE, and
-the absolute_url() methods of objects.
-</p>
-
-
-<form action="manage_addVirtualHostMonster" method="post">
-<table cellspacing="0" cellpadding="2" border="0">
- <tr>
- <td align="left" valign="top">
- <div class="form-label">
- Id
- </div>
- </td>
- <td align="left" valign="top">
- <input type="text" name="id" size="40" />
- </td>
- </tr>
- <tr>
- <td align="left" valign="top">
- </td>
- <td align="left" valign="top">
- <div class="form-element">
- <input class="form-element" type="submit" name="submit"
- value=" Add " />
- </div>
- </td>
- </tr>
-</table>
-</form>
-
-<dtml-var manage_page_footer>
-
More information about the Zope-Checkins
mailing list