Changeset 1237
- Timestamp:
- 09/11/08 04:05:17
- Files:
-
- qPingTool/branches/plone-3.1/Extensions (deleted)
- qPingTool/branches/plone-3.1/History.txt (modified) (1 diff)
- qPingTool/branches/plone-3.1/PingInfo.py (modified) (4 diffs)
- qPingTool/branches/plone-3.1/PingTool.py (modified) (7 diffs)
- qPingTool/branches/plone-3.1/TODO.txt (deleted)
- qPingTool/branches/plone-3.1/__init__.py (modified) (2 diffs)
- qPingTool/branches/plone-3.1/adapter.py (modified) (3 diffs)
- qPingTool/branches/plone-3.1/browser (added)
- qPingTool/branches/plone-3.1/browser/__init__.py (added)
- qPingTool/branches/plone-3.1/browser/configure.zcml (added)
- qPingTool/branches/plone-3.1/browser/ping.py (added)
- qPingTool/branches/plone-3.1/browser/ping_setup.pt (added)
- qPingTool/branches/plone-3.1/config.py (modified) (1 diff)
- qPingTool/branches/plone-3.1/configure.zcml (added)
- qPingTool/branches/plone-3.1/interfaces.py (added)
- qPingTool/branches/plone-3.1/profiles (added)
- qPingTool/branches/plone-3.1/profiles.zcml (added)
- qPingTool/branches/plone-3.1/profiles/default (added)
- qPingTool/branches/plone-3.1/profiles/default/actionicons.xml (added)
- qPingTool/branches/plone-3.1/profiles/default/actions.xml (added)
- qPingTool/branches/plone-3.1/profiles/default/controlpanel.xml (added)
- qPingTool/branches/plone-3.1/profiles/default/import_steps.xml (added)
- qPingTool/branches/plone-3.1/profiles/default/metadata.xml (added)
- qPingTool/branches/plone-3.1/profiles/default/propertiestool.xml (added)
- qPingTool/branches/plone-3.1/profiles/default/qPingTool_various.txt (added)
- qPingTool/branches/plone-3.1/profiles/default/skins.xml (added)
- qPingTool/branches/plone-3.1/profiles/default/toolset.xml (added)
- qPingTool/branches/plone-3.1/profiles/default/types (added)
- qPingTool/branches/plone-3.1/profiles/default/types.xml (added)
- qPingTool/branches/plone-3.1/profiles/default/types/PingInfo.xml (added)
- qPingTool/branches/plone-3.1/profiles/default/types/PingTool.xml (added)
- qPingTool/branches/plone-3.1/refresh.txt (deleted)
- qPingTool/branches/plone-3.1/setuphandlers.py (added)
- qPingTool/branches/plone-3.1/skins.zcml (added)
- qPingTool/branches/plone-3.1/skins/qpingtool/ping_now.cpy (deleted)
- qPingTool/branches/plone-3.1/skins/qpingtool/ping_now.cpy.metadata (deleted)
- qPingTool/branches/plone-3.1/skins/qpingtool/ping_setup.cpt (deleted)
- qPingTool/branches/plone-3.1/skins/qpingtool/ping_setup.cpt.metadata (deleted)
- qPingTool/branches/plone-3.1/skins/qpingtool/save_ping_setup.cpy (deleted)
- qPingTool/branches/plone-3.1/skins/qpingtool/save_ping_setup.cpy.metadata (deleted)
- qPingTool/branches/plone-3.1/util.py (deleted)
- qPingTool/branches/plone-3.1/www/overview.zpt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPingTool/branches/plone-3.1/History.txt
r829 r1237 1 1.0.0 - Unreleased 2 3 * Converted `Extension/Install.py` into a complete GenericSetup profile. 4 * Updated tests to run with Plone 3.x. 5 * General code cleanup and modernization. 6 1 7 0.3 2 8 qPingTool/branches/plone-3.1/PingInfo.py
r697 r1237 1 from Globals import DTMLFile 2 from AccessControl import ClassSecurityInfo 1 3 from Products.Archetypes.public import * 2 from Products.Archetypes.BaseContent import BaseContentMixin 3 from Products.CMFCore.ActionInformation import ActionInformation 4 from Products.CMFCore.Expression import Expression, createExprContext 5 from Products.CMFCore.utils import getToolByName 6 from Acquisition import aq_inner, aq_parent 4 from Products.CMFCore.permissions import ModifyPortalContent 7 5 from Products.CMFDefault.utils import _dtmldir 8 from config import * 9 from AccessControl import ClassSecurityInfo 10 from Globals import InitializeClass, DTMLFile 6 from Products.ATContentTypes.content.base import ATCTContent 7 from Products.ATContentTypes.content.schemata import ATContentTypeSchema, finalizeATCTSchema 8 from Products.ATContentTypes.lib.historyaware import HistoryAwareMixin 9 from config import RSS_LIST, PROJECTNAME 11 10 12 schema = BaseContentMixin.schema + Schema(( 13 #StringField('id', 14 # required=1, 15 # widget=StringWidget(size=70, 16 # label_msgid = 'label_id', 17 # description_msgid = 'help_id'), 18 # ), 11 PingInfoSchema = ATContentTypeSchema.copy() + Schema(( 12 TextField('description', 13 default = '', 14 searchable = 0, 15 widget = TextAreaWidget( 16 label_msgid = 'label_description', 17 description_msgid = 'help_description',), 18 ), 19 19 StringField('url', 20 20 required=1, … … 30 30 StringField('rss_version', 31 31 vocabulary=RSS_LIST, 32 default=' Blog',32 default='Weblog', 33 33 widget=SelectionWidget(label_msgid = 'label_rss_version', 34 34 description_msgid = 'help_rss_version'), 35 ), 36 )) 35 )), 36 marshall=RFC822Marshaller() 37 ) 38 39 finalizeATCTSchema(PingInfoSchema) 37 40 38 39 class PingInfo(BaseContentMixin): 41 class PingInfo(ATCTContent, HistoryAwareMixin): 40 42 """Ping Info container 41 43 id - name of the server to ping … … 44 46 rss_version - rss version supported by the server 45 47 """ 46 47 schema = schema 48 __implements__ = (ATCTContent.__implements__, 49 HistoryAwareMixin.__implements__, 50 ) 51 schema = PingInfoSchema 48 52 49 53 """ … … 55 59 return self.contributors 56 60 57 try: 58 from Products.CMFCore import permissions 59 security.declareProtected(permissions.ModifyPortalContent, 'manage_metadata' ) 60 except: 61 from Products.CMFCore.CMFCorePermissions import ModifyPortalContent 62 security.declareProtected(ModifyPortalContent, 'manage_metadata' ) 63 61 security.declareProtected(ModifyPortalContent, 'manage_metadata' ) 64 62 manage_metadata = DTMLFile('zmi_metadata', _dtmldir) 65 63 66 64 67 registerType(PingInfo )65 registerType(PingInfo, PROJECTNAME) qPingTool/branches/plone-3.1/PingTool.py
r697 r1237 1 #from Globals import InitializeClass2 1 import os 2 from Acquisition import aq_base 3 from zLOG import LOG 4 from zope.interface import implements 5 from AccessControl import ClassSecurityInfo 6 from Products.PageTemplates.PageTemplateFile import PageTemplateFile 7 from Products.Archetypes.public import * 3 8 from Products.CMFCore.ActionProviderBase import ActionProviderBase 9 from Products.CMFCore.permissions import ManagePortal 10 from Products.CMFCore.utils import getToolByName 11 from Products.ATContentTypes.content.folder import ATFolder 12 from Products.CMFPlone.interfaces.OrderedContainer import IOrderedContainer 4 13 from Products.CMFPlone.PloneFolder import PloneFolder 5 from config import TOOL_ID, PROJECTNAME6 from Products.Archetypes.public import *7 from Products.ATContentTypes.content.folder import ATFolder8 from Products.ATContentTypes.content.base import updateActions, updateAliases9 from Products.CMFPlone.interfaces.OrderedContainer import IOrderedContainer10 from Products.CMFCore.ActionInformation import ActionInformation11 from Products.CMFCore.Expression import Expression12 from Products.CMFCore.CMFCorePermissions import ManageProperties13 from Acquisition import aq_base14 from Products.CMFCore.utils import _getViewFor15 from Products.PageTemplates.PageTemplateFile import PageTemplateFile16 14 from Products.XMLRPCMethod.XMLRPCMethod import RPCThread, XMLRPCMethod 17 from Products.CMFCore.utils import getToolByName 18 from util import getCanonicalURL 19 from zLOG import LOG 15 16 from interfaces import IPingTool 17 from adapter import ICanonicalURL 18 from config import PROJECTNAME 20 19 21 20 _marker = [] … … 30 29 31 30 32 class PingTool(ATFolder, PloneFolder, ActionProviderBase): #(BaseFolder, PloneFolder, ActionProviderBase): 33 """This tool serve for operation with ActionInfo objects 31 class PingTool(ATFolder, PloneFolder): 34 32 """ 35 33 36 #schema = BaseSchema37 filter_content_types = 138 allowed_content_types = ('PingInfo',)39 global_allowed = 034 >>> IPingTool.implementedBy(PingTool) 35 True 36 """ 37 security = ClassSecurityInfo() 40 38 41 meta_type = archetype_name = portal_type = 'PingTool' 39 implements(IPingTool) 40 __implements__ = (IOrderedContainer,) 42 41 43 ######## 44 content_icon = 'tool.gif' 45 immediate_view = 'view' 46 default_view = 'view' 47 48 ######## 49 __implements__ = (IOrderedContainer,) 50 _actions = ( ActionInformation( 51 id='ping' 52 , title='Ping setup' 53 , action=Expression( 54 text='string:${folder_url}/ping_setup') 55 , condition=Expression( 56 text='python: folder is object and portal.portal_syndication.isSyndicationAllowed(object)') 57 , permissions=(ManageProperties,) 58 , category='folder' 59 , visible=1 60 ), 61 ) 62 63 actions = updateActions(ATFolder, 64 ({'id' : 'view' \ 65 ,'name' : 'View' \ 66 ,'action' : 'string:folder_contents' \ 67 ,'permissions': ('Manage portal',) \ 68 ,'category' :'object' \ 69 }, 70 ) 71 ) 72 73 aliases = updateAliases(ATFolder, 74 {'(Default)' : 'folder_listing' \ 75 ,'view' : 'folder_contents' \ 76 }, 77 ) 78 42 archetype_name = portal_type = 'PingTool' 79 43 manage_options = ( 80 44 {'label' : 'Overview', 'action' : 'manage_overview'}, … … 85 49 manage_overview._need__name__ = 0 86 50 51 def om_icons(self): 52 """ Checking on ZMI for canonical_url setting.""" 53 icons = ({'path':'misc_/qPingTool/tool.gif' \ 54 ,'alt':self.meta_type \ 55 ,'title':self.meta_type \ 56 },) 57 if not ICanonicalURL(self).getCanonicalURL(): 58 icons = icons + ({'path':'misc_/PageTemplates/exclamation.gif' \ 59 ,'alt':'Error' \ 60 ,'title':'PingTool needs setting canonical_url' \ 61 },) 62 return icons 63 64 security.declareProtected(ManagePortal, 'pingFeedReader') 87 65 def pingFeedReader(self,context): 88 66 """ ping """ 89 status = 'success' 90 message = 'The servers are pinged' 91 if context.meta_type == 'BlogFolder': 92 blog = context.simpleblog_tool.getFrontPage(context) 93 else: 94 blog = context 95 96 title = blog.Title() 97 portal = context.portal_url.getPortalObject() 98 canonical_url = getCanonicalURL(context) 67 68 status = 'failed' 69 blog = context 70 pingProp = self.getPingProperties(blog) 71 if not pingProp['enable_ping']: 72 message = 'Ping is dissabled.' 73 return status, message 74 canonical_url = ICanonicalURL(self).getCanonicalURL() 99 75 if canonical_url: 100 76 url = context.portal_url.getRelativeContentURL(blog) 101 77 url = canonical_url + url 102 78 else: 103 return status, 'Ping is impossible.Se e portal_pingtool.'79 return status, 'Ping is impossible.Setup canonical_url.' 104 80 105 81 ps = getToolByName(context,'portal_syndication') 106 rss_templates = {'Blog':'','RSS1':'/RSS','RSS2':'/RSS2'} 107 pingProp = self.getPingProperties(blog) 108 result = 'ok' 109 if not pingProp['enable_ping']: 110 message = 'Ping is dissabled' 111 return status, message 82 rss_templates = {'Weblog':'','RSS1':'/RSS','RSS2':'/RSS2'} 112 83 if ps.isSyndicationAllowed(blog): 84 status = 'success' 85 message = 'The servers are pinged.' 113 86 sites = pingProp['ping_sites'] 114 87 if sites: … … 121 94 PingMethod = XMLRPCMethod('myid',"",site_url,site_method,25) 122 95 blog_url = url + site_rss_version 96 title = blog.Title() 123 97 try: 124 98 #LOG('qPing', 0, title, blog_url, site_url) 125 result = PingMethod(title,blog_url) 99 result_ping = PingMethod(title,blog_url) 100 result = result_ping['message'] 126 101 except: 127 LOG('qPingTool', 100,"The site "+ site_url+" generated error for "+ blog_url, result) 128 message += '\n'+ str(result) 102 result = 'The site %s generated error for %s.' % (site_url, blog_url) 103 LOG('qPingTool', 100, result) 104 message += '\nReturned message from %s: %s' % (site_url, str(result)) 105 else: 106 message = 'The %s is not syndication allowed' % url 129 107 return status, message 130 108 131 109 security.declareProtected(ManagePortal, 'setupPing') 132 110 def setupPing(self,context, 133 111 enable_ping=0, … … 137 115 obj=aq_base(context) 138 116 status = 'success' 139 message = 'Your changes have been saved'117 message = "Changes saved." 140 118 syInfo = getattr(obj, 'syndication_information', None) 141 119 … … 149 127 return status, message 150 128 129 security.declareProtected(ManagePortal, 'getPingProperties') 151 130 def getPingProperties(self, context): 152 131 """ """ … … 159 138 return pingPropeties 160 139 161 def om_icons(self): 162 """ Checking on ZMI for canonical_url setting.""" 163 icons = ({'path':'misc_/qPingTool/tool.gif' \ 164 ,'alt':self.meta_type \ 165 ,'title':self.meta_type \ 166 },) 167 if not getCanonicalURL(self): 168 icons = icons + ({'path':'misc_/PageTemplates/exclamation.gif' \ 169 ,'alt':'Error' \ 170 ,'title':'PingTool needs setting canonical_url' \ 171 },) 172 return icons 173 174 registerType(PingTool) 140 registerType(PingTool, PROJECTNAME) qPingTool/branches/plone-3.1/__init__.py
r697 r1237 1 from Globals import package_home2 1 from Products.Archetypes.public import process_types, listTypes 3 2 from Products.CMFCore import utils 4 from Products.CMFCore.DirectoryView import registerDirectory5 import os, os.path6 3 import PingInfo, PingTool 7 4 from config import * 8 5 9 try:10 from adapter import registerAdapter11 registerAdapter()12 except:13 from Products.CMFCore.utils import getToolByName14 from Products.CMFPlone.URLTool import URLTool15 def getCanonicalURL(self):16 portal = getToolByName(self, 'portal_url').getPortalObject()17 return portal.getProperty('canonical_url', None)18 #URLTool.security.declarePublic('getCanonicalURL')19 URLTool.getCanonicalURL = getCanonicalURL20 21 22 registerDirectory(SKINS_DIR, GLOBALS)23 6 tools = ( PingTool.PingTool, ) 24 7 … … 27 10 allow_module('Products.qPingTool.util') 28 11 29 utils.ToolInit("PingTool", tools=tools, product_name=PROJECTNAME,icon=TOOL_ICON,12 utils.ToolInit("PingTool", tools=tools, icon=TOOL_ICON, 30 13 ).initialize(context) 31 14 qPingTool/branches/plone-3.1/adapter.py
r697 r1237 1 from zope.interface import Interface, implements #, Attribute 1 from zope.component import adapts 2 from zope.interface import Interface, implements 3 4 from interfaces import IPingTool 2 5 from Products.CMFCore.utils import getToolByName 3 6 … … 20 23 class CanonicalURL(object): 21 24 """ CanonicalURL adapter 25 26 >>> ICanonicalURL.implementedBy(CanonicalURL) 27 True 28 >>> ICanonicalURL(CanonicalURL(object)) is not None 29 True 22 30 """ 31 32 adapts(IPingTool) 23 33 implements(ICanonicalURL) 24 34 … … 55 65 #portal = getToolByName(self, 'portal_url').getPortalObject() 56 66 #return portal.hasProperty('canonical_url') 57 58 # Register adapter59 60 def registerAdapter():61 from Products.CMFPlone.interfaces import IPloneBaseTool62 from zope.component import provideAdapter63 provideAdapter(CanonicalURL, adapts=[IPloneBaseTool,], provides=ICanonicalURL )qPingTool/branches/plone-3.1/config.py
r697 r1237 1 from Products.CMFCore import CMFCorePermissions2 1 from Products.Archetypes.utils import DisplayList 2 from Products.CMFCore.permissions import ManagePortal 3 3 4 SKINS_DIR = 'skins'5 4 GLOBALS = globals() 6 5 PROJECTNAME = 'qPingTool' 7 6 8 ADD_PERMISSION = CMFCorePermissions.ManagePortal 9 10 TOOL_ID = 'portal_pingtool' 7 ADD_PERMISSION = ManagePortal 11 8 12 9 TOOL_ICON = 'skins/qpingtool/tool.gif' 13 10 14 RSS_LIST = DisplayList(((' Blog','Blog'),('RSS','RSS1'),('RSS2','RSS2')))11 RSS_LIST = DisplayList((('Weblog','Weblog'),('RSS','RSS1'),('RSS2','RSS2'))) 15 12 16 13 CONFIGURATION_CONFIGLET = 'pingtool_config' qPingTool/branches/plone-3.1/www/overview.zpt
r697 r1237 1 1 <tal:header tal:replace="structure here/manage_page_header|nothing">Header</tal:header> 2 2 <tal:message tal:define="manage_tabs_message options/manage_tabs_message | request/manage_tabs_message | nothing" 3 tal:replace="structure here/manage_tabs">Tabs</tal:message>3 tal:replace="structure here/manage_tabs">Tabs</tal:message> 4 4 <tal:body 5 tal:define=" canonical_url_value request/canonical_url_value | python:modules['Products.qPingTool.util'].getCanonicalURL(here);6 hasCanonicalURL request/hasCanonicalURL | python:test(canonical_url_value, 1, 0);7 action python:test(hasCanonicalURL, 'Update', 'Add');5 tal:define="portal here/portal_url/getPortalObject; 6 canonical_url_value request/canonical_url_value | python:portal.getProperty('canonical_url'); 7 hasCanonicalURL request/hasCanonicalURL | python:portal.hasProperty('canonical_url'); 8 8 button request/submit | nothing; 9 9 submitted request/submitted | nothing;"> 10 <div tal:condition="submitted" 11 tal:omit-tag=""> 12 <tal:common> 13 <div tal:condition="python:button=='Update' and hasCanonicalURL"> 14 <tal:block define="result python:portal.manage_changeProperties(canonical_url=canonical_url_value)"/> 15 </div> 16 <div tal:condition="python:button=='Add' and not hasCanonicalURL"> 17 <tal:block define="result python:portal.manage_addProperty('canonical_url', canonical_url_value, 'string')"/> 18 </div> 19 </tal:common> 20 </div> 10 21 11 <div tal:condition="submitted" 12 tal:omit-tag="string:"> 13 <tal:common 14 define="portal here/portal_url/getPortalObject;"> 15 <div tal:condition="python:button=='Update'"> 16 <tal:block define="result python:portal.manage_changeProperties(canonical_url=canonical_url_value)"/> 17 </div> 18 <div tal:condition="python:button=='Add'"> 19 <tal:block define="result python:portal.manage_addProperty('canonical_url', canonical_url_value, 'string')"/> 20 </div> 21 </tal:common> 22 </div> 22 <h3>Overview</h3> 23 <p> 24 <strong>portal_pingtool</strong> is symple tool to enable pinging of external feed agregators. 25 </p> 26 <div tal:omit-tag="" 27 tal:define="hasCanonicalURL request/hasCanonicalURL | python:portal.hasProperty('canonical_url'); 28 action python:test(hasCanonicalURL, 'Update', 'Add');"> 29 <h3 tal:content="string:$action Canonical URL">Update Canonical URL</h3> 30 <p tal:condition="not:hasCanonicalURL">Until you setup canonical_url - Ping Tool will not work.</p> 23 31 24 <h3>Overview</h3> 32 <form method="post" action="" tal:attributes="action python:'manage_'+template.getId()"> 33 <input type="hidden" name="submitted" value="1" /> 34 <p class="form-help" 35 tal:content="string:To $action the property, enter a canonical URL value and click the "$action" button"> 36 To Add/Update the property, enter a canonical URL value and click the "Add/Update" button. 37 </p> 25 38 26 <p> <strong>portal_pingtool</strong> is symple tool to enable pinging of external feed agregators. 27 </p> 28 29 30 <h3 tal:content="string:$action Canonical URL">Update Canonical URL</h3> 31 32 <p tal:condition="not:hasCanonicalURL">Until you setup canonical_url - Ping Tool will not work.</p> 33 34 <form method="put" action="" tal:attributes="action template/getId"> 35 <input type="hidden" name="submitted" value="1" /> 36 37 <p class="form-help" 38 tal:content="string:To $action the property, enter a canonical URL value and click the "$action" button"> 39 To Add/Update the property, enter a canonical URL value 40 and click the "Add/Update" button. 41 </p> 42 43 <table> 44 <tr> 45 <td align="left" valign="top"> 46 <div class="form-label">Canonical URL</div> 47 </td> 48 <td align="left" valign="top"> 49 <input type="text" size="30" value="" name="canonical_url_value" 50 tal:attributes="value canonical_url_value | nothing"/> 51 </tr> 52 <tr> 53 <td align="right" valign="top"> 54 <div class="form-element"> 55 <input class="form-element" type="submit" name="submit" value="Save" 56 tal:attributes="value string:$action;" /> 57 </div> 58 </td> 59 </tr> 60 </table> 61 </form> 39 <table> 40 <tr> 41 <td align="left" valign="top"> 42 <div class="form-label">Canonical URL</div> 43 </td> 44 <td align="left" valign="top"> 45 <input type="text" size="30" value="" name="canonical_url_value" 46 tal:attributes="value canonical_url_value | nothing"/> 47 </tr> 48 <tr> 49 <td align="right" valign="top"> 50 <div class="form-element"> 51 <input class="form-element" type="submit" name="submit" value="Save" 52 tal:attributes="value string:$action;" /> 53 </div> 54 </td> 55 </tr> 56 </table> 57 </form> 58 </div> 62 59 </tal:body> 63 60 <tal:footer tal:replace="structure here/manage_page_footer|nothing">footer</tal:footer>
