Changeset 1225

Show
Ignore:
Timestamp:
09/08/08 12:47:26
Author:
liebster
Message:

added test and modified package

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qPingTool/branches/plone-3.1/PingTool.py

    r1224 r1225  
    33from Acquisition import aq_base 
    44 
    5 from zope.interface import implements 
    65from AccessControl import ClassSecurityInfo 
    76 
    87from Products.Archetypes.public import * 
    98 
     9from Products.CMFCore.ActionProviderBase import ActionProviderBase 
    1010from Products.CMFPlone.interfaces.OrderedContainer import IOrderedContainer 
    1111from Products.CMFPlone.PloneFolder import PloneFolder 
     
    1515from Products.CMFCore.permissions import ManagePortal 
    1616from Products.CMFCore.utils import getToolByName 
    17 from Products.CMFCore.ActionProviderBase import ActionProviderBase 
    1817 
    1918from Products.ATContentTypes.content.folder import ATFolder 
     
    2120from Products.XMLRPCMethod.XMLRPCMethod import RPCThread, XMLRPCMethod 
    2221 
    23 from util import getCanonicalURL 
    2422from zLOG import LOG 
    25 from config import TOOL_ID, PROJECTNAME 
     23from config import PROJECTNAME 
    2624 
    2725_marker = [] 
     
    4947        ) + ATFolder.manage_options 
    5048 
    51     security.declareProtected(ManagePortal, 'manage_overview') 
    52     manage_overview = PageTemplateFile(os.path.join('www','overview'), globals()) 
    53     manage_overview.__name__ = 'manage_overview' 
    54     manage_overview._need__name__ = 0 
    55  
    56     def om_icons(self): 
    57         """ Checking on ZMI for canonical_url setting.""" 
    58         icons = ({'path':'misc_/qPingTool/tool.gif' \ 
    59                     ,'alt':self.meta_type \ 
    60                     ,'title':self.meta_type \ 
    61                 },) 
    62         if not getCanonicalURL(self): 
    63             icons = icons + ({'path':'misc_/PageTemplates/exclamation.gif' \ 
    64                                 ,'alt':'Error' \ 
    65                                 ,'title':'PingTool needs setting canonical_url' \ 
    66                                 },) 
    67         return icons 
    68  
    6949    security.declareProtected(ManagePortal, 'pingFeedReader') 
    7050    def pingFeedReader(self,context): 
    7151        """ ping """ 
    72         status = 'success' 
    73         message = 'The servers are pinged' 
    74         if context.meta_type == 'BlogFolder': 
    75             blog = context.simpleblog_tool.getFrontPage(context) 
     52        status = 'failed' 
     53        if context.meta_type == 'WeblogEntry': 
     54            blog = context.getWeblog() 
    7655        else: 
    7756            blog = context 
    7857 
    79         title = blog.Title() 
    80         portal = context.portal_url.getPortalObject() 
    81         canonical_url = getCanonicalURL(context) 
    82         if canonical_url: 
    83             url = context.portal_url.getRelativeContentURL(blog) 
    84             url = canonical_url + url 
    85         else: 
    86             return status, 'Ping is impossible.See portal_pingtool.' 
     58        pingProp = self.getPingProperties(blog) 
     59        if not pingProp['enable_ping']: 
     60            message = 'Ping is dissabled.' 
     61            return status, message 
    8762 
     63        url = blog.absolute_url_path()[1:] 
    8864        ps = getToolByName(context,'portal_syndication') 
    8965        rss_templates = {'Blog':'','RSS1':'/RSS','RSS2':'/RSS2'} 
    90         pingProp = self.getPingProperties(blog) 
    91         result = 'ok' 
    92         if not pingProp['enable_ping']: 
    93            message = 'Ping is dissabled' 
    94            return status, message 
    9566        if ps.isSyndicationAllowed(blog): 
     67            status = 'success' 
     68            message = 'The servers are pinged.' 
    9669            sites = pingProp['ping_sites'] 
    9770            if sites: 
     
    10477                    PingMethod = XMLRPCMethod('myid',"",site_url,site_method,25) 
    10578                    blog_url = url + site_rss_version 
     79                    title = blog.Title() 
    10680                    try:  
    10781                        #LOG('qPing', 0, title, blog_url, site_url) 
    108                         result = PingMethod(title,blog_url) 
     82                        result_ping = PoingMethod(title,blog_url) 
     83                        result = result_ping['message'] 
    10984                    except: 
    110                         LOG('qPingTool', 100,"The site "+  site_url+" generated error for "+ blog_url, result) 
    111                     message += '\n'+ str(result) 
     85                        result = 'The site %s generated error for %s.' % (site_url, blog_url) 
     86                        LOG('qPingTool', 100, result) 
     87                    message += '\nReturned message: ' + str(result) 
     88        else: 
     89            message = 'The %s is not syndication allowed' % url  
    11290        return status, message 
    11391 
  • qPingTool/branches/plone-3.1/configure.zcml

    r1224 r1225  
    44    i18n_domain="qPingTool"> 
    55 
    6    <adapter factory=".adapter.CanonicalURL" /> 
    7  
    86   <include file="profiles.zcml" /> 
    97   <include file="skins.zcml" /> 
  • qPingTool/branches/plone-3.1/profiles/default/types/PingInfo.xml

    r1224 r1225  
    1717 <property name="allowed_content_types"/> 
    1818 <property name="allow_discussion">False</property> 
     19 
     20 <alias from="(Default)" to="base_view"/> 
     21 <alias from="edit" to="base_edit"/> 
     22 <alias from="index.html" to="(Default)"/> 
     23 <alias from="properties" to="base_metadata"/> 
     24 <alias from="view" to="base_view"/> 
     25 
    1926 <action title="View" 
    2027         action_id="view" 
     
    3340         visible="True" 
    3441         i18n:attributes="title"> 
    35   <permission value="View"/> 
     42  <permission value="Modify portal content"/> 
    3643 </action> 
    3744 <action title="Properties" 
  • qPingTool/branches/plone-3.1/profiles/default/types/PingTool.xml

    r1224 r1225  
    1313 <property name="filter_content_types">True</property> 
    1414 <property name="allowed_content_types"> 
    15   <element value="PingInfo"/></property> 
     15  <element value="PingInfo"/> 
     16 </property> 
    1617 <property name="allow_discussion">False</property> 
     18 <property name="default_view">base_view</property> 
     19 <property name="view_methods"> 
     20  <element value="base_view"/> 
     21 </property> 
     22 <property name="default_view_fallback">False</property> 
     23 
    1724 <alias from="(Default)" to="base_view"/> 
    1825 <alias from="edit" to="base_edit"/> 
    1926 <alias from="index.html" to="(Default)"/> 
    20  <alias from="properties" to="base_metadata"/> 
    2127 <alias from="view" to="(Default)"/> 
     28 
    2229 <action title="View" 
    2330         action_id="view" 
    2431         category="object" 
    2532         condition_expr="" 
    26          url_expr="string:folder_contents
     33         url_expr="string:${object_url}/view
    2734         visible="True" 
    2835         i18n:attributes="title"> 
    2936  <permission value="Manage portal"/> 
    3037 </action> 
     38 <action title="Edit" 
     39         action_id="edit" 
     40         category="object" 
     41         condition_expr="" 
     42         url_expr="string:${object_url}/edit" 
     43         visible="True" 
     44         i18n:attributes="title"> 
     45  <permission value="Modify portal content"/> 
     46 </action> 
     47 
    3148</object>