Commit 8da18165 authored by Jérome Perrin's avatar Jérome Perrin

CodingStyle: implement a basic ERP5Form.checkConsistency

Checking conventions for form, dialog and reports based on
https://web.archive.org/web/20140318125244/http://www.erp5.org/GuidelinesForNamingConvention#ERP5_Form
parent fea57588
...@@ -38,6 +38,8 @@ from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate ...@@ -38,6 +38,8 @@ from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
from Products.CMFCore.utils import _checkPermission, getToolByName from Products.CMFCore.utils import _checkPermission, getToolByName
from Products.CMFCore.exceptions import AccessControl_Unauthorized from Products.CMFCore.exceptions import AccessControl_Unauthorized
from Products.ERP5Type import PropertySheet, Permissions from Products.ERP5Type import PropertySheet, Permissions
from Products.ERP5Type import CodingStyle
from Products.ERP5Type.ObjectMessage import ObjectMessage
from urllib import quote from urllib import quote
from Products.ERP5Type.Globals import DTMLFile, get_request from Products.ERP5Type.Globals import DTMLFile, get_request
...@@ -1320,6 +1322,27 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate): ...@@ -1320,6 +1322,27 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
def _getAcquireLocalRoles(self): def _getAcquireLocalRoles(self):
return True return True
def _checkConsistency(self, fixit=0, filter=None, **kw):
message_list = CodingStyle.checkConsistency(self, fixit=fixit, source_code=self.asXML())
object_relative_url = '/'.join(self.getPhysicalPath())[len(self.getPortalObject().getPath()):],
def addMessage(message):
message_list.append(
ObjectMessage(
object_relative_url=object_relative_url,
message=message))
if self.pt:
prefix, method = self.getId().split('_', 1)
del prefix
if self.pt in ('form_view', 'form_list', 'form_dialog', 'report_view'):
if not method.startswith('view'):
addMessage('Form name must follow ${portal_type}_view.* naming')
if self.pt == 'form_dialog' and not method.endswith('Dialog'):
addMessage('Dialog form name must follow ${portal_type}_view.*Dialog naming')
if self.pt == 'report_view' and not method.endswith('Report'):
addMessage('Report form name must follow ${portal_type}_view.*Report naming')
return message_list
# utility function # utility function
def get_field_meta_type_and_proxy_flag(field): def get_field_meta_type_and_proxy_flag(field):
if field.meta_type=='ProxyField': if field.meta_type=='ProxyField':
......
...@@ -123,7 +123,7 @@ def checkConsistency(self, fixit=0, source_code=None): ...@@ -123,7 +123,7 @@ def checkConsistency(self, fixit=0, source_code=None):
if prefix not in getSkinPrefixList(self): if prefix not in getSkinPrefixList(self):
message_list.append( message_list.append(
ObjectMessage(object_relative_url='/'.join(self.getPhysicalPath())[portal_path_len:], ObjectMessage(object_relative_url='/'.join(self.getPhysicalPath())[portal_path_len:],
message='Wrong prefix %s for python script %s' % (prefix, document_id))) message='Wrong prefix %s for %s %s' % (prefix, self.meta_type, document_id)))
# Make sure source code does not contain legacy callables # Make sure source code does not contain legacy callables
if source_code: if source_code:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment