|
[Collective-checkins] r112169 - in collective.xdv/trunk:
collective/xdv collective/xdv/tests docs
From: Marshall Scorcio <svn-changes@pl...> - 2010-03-02 23:14
|
Author: marshalium
Date: Tue Mar 2 23:14:22 2010
New Revision: 112169
Modified:
collective.xdv/trunk/collective/xdv/tests/test_transform.py
collective.xdv/trunk/collective/xdv/utils.py
collective.xdv/trunk/docs/HISTORY.txt
Log:
Made zope paths resolve relative to Plone site.
Modified: collective.xdv/trunk/collective/xdv/tests/test_transform.py
==============================================================================
--- collective.xdv/trunk/collective/xdv/tests/test_transform.py (original)
+++ collective.xdv/trunk/collective/xdv/tests/test_transform.py Tue Mar 2 23:14:22 2010
@@ -18,7 +18,6 @@
from collective.xdv.interfaces import ITransformSettings
from collective.xdv.transform import getCache
-from collective.xdv.utils import resolve_url
from xdv.compiler import compile_theme
@@ -104,17 +103,18 @@
# The theme
self.failUnless("This is the theme" in browser.contents)
- def test_theme_stored_in_zope(self):
- rules_contents = open(resolve_url('python://collective.xdv/tests/rules.xml')[6:])
- theme_contents = open(resolve_url('python://collective.xdv/tests/theme.html')[6:])
-
+ def test_theme_stored_in_plone_site(self):
+ # We'll upload the theme files to the Plone site root
+ rules_contents = open(os.path.join(os.path.split(__file__)[0], 'rules.xml'))
+ theme_contents = open(os.path.join(os.path.split(__file__)[0], 'theme.html'))
self.portal.manage_addDTMLMethod('theme.html', file=theme_contents)
self.portal.manage_addDTMLMethod('rules.xml', file=rules_contents)
self.settings.enabled = True
- self.settings.theme = u'plone/theme.html'
- self.settings.rules = u'plone/rules.xml'
+ # These urls should be relative to the Plone site root
+ self.settings.theme = u'/theme.html'
+ self.settings.rules = u'/rules.xml'
browser = Browser()
browser.open(self.portal.absolute_url())
Modified: collective.xdv/trunk/collective/xdv/utils.py
==============================================================================
--- collective.xdv/trunk/collective/xdv/utils.py (original)
+++ collective.xdv/trunk/collective/xdv/utils.py Tue Mar 2 23:14:22 2010
@@ -39,11 +39,11 @@
elif request:
request = request.clone()
try:
- data = StringIO(request.traverse(url).read())
- request.close()
+ data = StringIO(request.traverse(get_plone_site_url() + '/' + url).read())
+ request.clear()
return data
except:
- request.close()
+ request.clear()
return None
@@ -67,6 +67,20 @@
return url
+def get_plone_site_url():
+ """Return the path to the Plone site root
+ """
+
+ site = getSite()
+ if site is None:
+ return ''
+
+ portal_url = getToolByName(site, 'portal_url', None)
+ if portal_url is None:
+ return ''
+
+ return portal_url.getPortalObject().absolute_url_path()
+
def expand_absolute_prefix(prefix):
"""Prepend the Plone site URL to the prefix if it starts with /
"""
@@ -77,15 +91,7 @@
if not prefix.startswith('/'):
return prefix
- site = getSite()
- if site is None:
- return prefix
-
- portal_url = getToolByName(site, 'portal_url', None)
- if portal_url is None:
- return None
-
- return portal_url.getPortalObject().absolute_url_path() + prefix
+ return get_plone_site_url() + prefix
def get_host(request):
"""Try to get HTTP host even if there's no HOST header.
Modified: collective.xdv/trunk/docs/HISTORY.txt
==============================================================================
--- collective.xdv/trunk/docs/HISTORY.txt (original)
+++ collective.xdv/trunk/docs/HISTORY.txt Tue Mar 2 23:14:22 2010
@@ -4,6 +4,9 @@
1.0rc5 - unreleased
-------------------
+* Made all zope paths resolve relative to the Plone site.
+ [marshalium]
+
* Add support for resolving files with http/ftp absolute urls and zope paths.
[marshalium]
|
| Thread | Author | Date |
|---|---|---|
| [Collective-checkins] r112169 - in collective.xdv/trunk: collective/xdv collective/xdv/tests docs | Marshall Scorcio <svn-changes@pl...> |