|
1 # |
|
2 # Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net> |
|
3 # All Rights Reserved. |
|
4 # |
|
5 # This software is subject to the provisions of the Zope Public License, |
|
6 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. |
|
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
|
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
|
10 # FOR A PARTICULAR PURPOSE. |
|
11 # |
|
12 |
|
13 __docformat__ = 'restructuredtext' |
|
14 |
|
15 |
|
16 # import standard library |
|
17 |
|
18 # import interfaces |
|
19 from pyams_content.shared.common import IWfSharedContent |
|
20 from pyams_sequence.interfaces import ISequentialIdInfo |
|
21 from pyams_skin.layer import IPyAMSUserLayer |
|
22 from pyams_utils.interfaces.url import IRelativeURL |
|
23 |
|
24 # import packages |
|
25 from pyams_utils.adapter import adapter_config, ContextRequestAdapter |
|
26 from pyams_utils.url import absolute_url |
|
27 |
|
28 |
|
29 @adapter_config(context=(IWfSharedContent, IPyAMSUserLayer), provides=IRelativeURL) |
|
30 class SharedContentRelativeUrlAdapter(ContextRequestAdapter): |
|
31 """Shared content relative URL adapter""" |
|
32 |
|
33 def get_url(self, display_context=None, view_name=None, query=None): |
|
34 return absolute_url(display_context, self.request, |
|
35 '++oid++{0}::{1}.html'.format( |
|
36 ISequentialIdInfo(self.context).get_base_oid().strip(), |
|
37 self.context.content_url)) |