|
Revision 589
(checked in by mylan, 2 years ago)
|
Add and register CanonicalURL adapter.cd '/data/mylan/opt/work/SimpleBlog/adsenseproduct/Extensions'
|
- Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 |
from zope.interface import Interface, implements |
|---|
| 2 |
from Products.CMFCore.utils import getToolByName |
|---|
| 3 |
|
|---|
| 4 |
class ICanonicalURL(Interface): |
|---|
| 5 |
""" Interface for canonical URL API providing.""" |
|---|
| 6 |
|
|---|
| 7 |
def getCanonicalURL(): |
|---|
| 8 |
"""Get canonical_url property value.""" |
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
class CanonicalURL(object): |
|---|
| 21 |
""" CanonicalURL adapter |
|---|
| 22 |
""" |
|---|
| 23 |
implements(ICanonicalURL) |
|---|
| 24 |
|
|---|
| 25 |
def __init__(self, context): |
|---|
| 26 |
""" init |
|---|
| 27 |
""" |
|---|
| 28 |
self.context = context |
|---|
| 29 |
|
|---|
| 30 |
def getCanonicalURL(self): |
|---|
| 31 |
"""Get canonical_url property value |
|---|
| 32 |
""" |
|---|
| 33 |
portal = getToolByName(self.context, 'portal_url').getPortalObject() |
|---|
| 34 |
return portal.getProperty('canonical_url',None) |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
def registerAdapter(): |
|---|
| 61 |
from Products.CMFPlone.interfaces import IPloneBaseTool |
|---|
| 62 |
from zope.component import provideAdapter |
|---|
| 63 |
provideAdapter(CanonicalURL, adapts=[IPloneBaseTool,], provides=ICanonicalURL ) |
|---|