Commit a9de2548 authored by Jens Vagelpohl's avatar Jens Vagelpohl

- 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.
parent a053e0d2
......@@ -14,6 +14,11 @@ Bugs Fixed
- LP #142451: If non-recursive ownership changes are made using
``changeOwnership``, do not touch any children.
- 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.
Features Added
++++++++++++++
......
......@@ -30,6 +30,7 @@ class VirtualHostMonster(Persistent, Item, Implicit):
meta_type='Virtual Host Monster'
priority = 25
id = 'VHM'
title = ''
lines = ()
have_map = 0
......@@ -255,17 +256,17 @@ class VirtualHostMonster(Persistent, Item, Implicit):
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),
)
......@@ -111,9 +111,68 @@ for i, (vaddr, vr, _vh, p, ubase) in enumerate(gen_cases()):
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__':
......
<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 &quot;VirtualHostBase&quot;, the protocol,
and the host into the path.
</p>
<p class="form-help">
Insert &quot;VirtualHostRoot&quot; 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 &quot;/foo&quot; 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>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment