1 | from Products.CMFPlone.URLTool import URLTool |
---|
2 | |
---|
3 | from adapters.interfaces import IRequestPortalUrlAnnotator |
---|
4 | |
---|
5 | ## XXX PATCH FOR FILERESOURCE, UNTILL ADD 'POST' METHOD OR FIX |
---|
6 | ## ResourceRegistries.tools.BaseRegistry.BaseRegistryTool.getResourceContent method |
---|
7 | marker = [] |
---|
8 | from Products.Five.browser.resource import FileResource |
---|
9 | |
---|
10 | if getattr(FileResource, 'POST', marker) == marker: |
---|
11 | FileResource.POST = FileResource.GET |
---|
12 | |
---|
13 | |
---|
14 | def urltool_call(self, relative=0, *args, **kw): |
---|
15 | """ Get by default the absolute URL of the portal. If request is annonated then add suffix to portal_url |
---|
16 | """ |
---|
17 | # print '################################ Called patched portal_url __call__: ' + self.REQUEST.URL |
---|
18 | url_suffix = '' |
---|
19 | if self.REQUEST: |
---|
20 | annotator = IRequestPortalUrlAnnotator(self.REQUEST, None) |
---|
21 | if annotator is not None: |
---|
22 | url_suffix = annotator.getPortalUrlSuffix() |
---|
23 | return url_suffix |
---|
24 | return self.getPortalObject().absolute_url(relative=relative) |
---|
25 | |
---|
26 | def urltool_getPortalPath(self): |
---|
27 | """ Get the portal object's URL without the server URL component. |
---|
28 | """ |
---|
29 | |
---|
30 | url_suffix = '' |
---|
31 | if self.REQUEST: |
---|
32 | annotator = IRequestPortalUrlAnnotator(self.REQUEST, None) |
---|
33 | if annotator is not None: |
---|
34 | url_suffix = annotator.getPortalUrlSuffix() |
---|
35 | # print '############ Added sufix to portal_url: ' + url_suffix |
---|
36 | |
---|
37 | return '/'.join(self.getPortalObject().getPhysicalPath()) + url_suffix |
---|
38 | |
---|
39 | URLTool.__call__ = urltool_call |
---|
40 | #URLTool.getPortalPath = urltool_getPortalPath |
---|