<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <tuple>
        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
        <tuple/>
      </tuple>
    </pickle>
    <pickle>
      <dictionary>
        <item>
            <key> <string>Python_magic</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>Script_magic</string> </key>
            <value> <int>3</int> </value>
        </item>
        <item>
            <key> <string>__ac_local_roles__</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_bind_names</string> </key>
            <value>
              <object>
                <klass>
                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
                </klass>
                <tuple/>
                <state>
                  <dictionary>
                    <item>
                        <key> <string>_asgns</string> </key>
                        <value>
                          <dictionary>
                            <item>
                                <key> <string>name_container</string> </key>
                                <value> <string>container</string> </value>
                            </item>
                            <item>
                                <key> <string>name_context</string> </key>
                                <value> <string>context</string> </value>
                            </item>
                            <item>
                                <key> <string>name_m_self</string> </key>
                                <value> <string>script</string> </value>
                            </item>
                            <item>
                                <key> <string>name_subpath</string> </key>
                                <value> <string>traverse_subpath</string> </value>
                            </item>
                          </dictionary>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>_body</string> </key>
            <value> <string encoding="cdata"><![CDATA[

# This script checks for naming validity.\n
#\n
# NOTE: Do not rely on this script too much! After all, human must take care.\n
\n
# TODO:\n
# - Add more abbriviation words.\n
# - Check language dependencies (e.g. "Account Of" should not be allowed, because it cannot be\n
#   translated naturally for other languages).\n
# - Check skin names.\n
# - Check script names (from skin folders and workflows).\n
\n
ABBRIVIATION_WORD_LIST = ( \'ID\', \'URL\', \'URI\', \'VAT\', \'FAX\', \'GAP\', \'IBAN\', \'BBAN\', \'EAN\', \'BOM\', \'BIC\'\n
                         , \'CSV\', \'SVN\', \'UBM\', \'VPN\', \'CAD\', \'ERP5\'\n
                         )\n
ABBRIVIATION_WORD_DICT = dict([(word, 1) for word in ABBRIVIATION_WORD_LIST])\n
\n
# List of words that do not need to be titlecased\n
LOWERCASE_WORD_LIST = (\'g\', \'cm\', \'kg\', \'%\', \'/\', \'...\')\n
LOWERCASE_WORD_DICT = dict([(word, 1) for word in LOWERCASE_WORD_LIST])\n
\n
# List of allowed characters, usefull to detect non-english strings\n
ALLOWED_CHARS = \'abcdefghijklmnopqrstuvwxyz0123456789%/. ()-_?&\'\n
\n
\n
\n
def checkField(folder, form, field):\n
  """\n
    Generic function that test the validity of ERP5Form fields.\n
  """\n
  path = \'/\'.join([folder.id, form.id])\n
  error_message = checkTitle(path, field.id, field.title())\n
  if field.id == \'listbox\':\n
    path = \'/\'.join([path, \'listbox\'])\n
    for id, title in field.get_value(\'columns\'):\n
      error_message += checkTitle(path, \'columns\', title)\n
    for id, title in field.get_value(\'all_columns\'):\n
      error_message += checkTitle(path, \'all_columns\', title)\n
\n
    a = field.getListMethodName()\n
    if (a!= None and not a.endswith(\'List\')):\n
      if a not in [\'portal_catalog\', \'searchFolder\', \'objectValues\']:\n
        error_message = "%s : %s : %r Bad Naming Convention\\n" % (path, id, a)\n
  return error_message\n
\n
\n
def checkTitle(path, id, title):\n
  """\n
    Generic function that test the validity of a title.\n
  """\n
  error_message = \'\'\n
\n
  if len(title.strip()) == 0:\n
    return "%s : %s : can\'t be empty\\n" % (path, id)\n
\n
  for c in title:\n
    if c.lower() not in ALLOWED_CHARS:\n
      return "%s : %s : %r character not allowed\\n" % (path, id, c)\n
\n
  word_list = title.split(\' \')\n
  for word in word_list:\n
    word = word.strip(\'()\')\n
\n
    if word.isdigit():\n
      continue\n
\n
    if word.upper() in ABBRIVIATION_WORD_DICT:\n
      if not word.isupper():\n
        error_message += \'%s : %s : %r is not upper case even though it is an abbriviation\\n\' % (path, id, word)\n
    elif word.endswith(\'s\') and word[:-1].upper() in ABBRIVIATION_WORD_DICT:\n
      if not word[:-1].isupper():\n
        error_message += \'%s : %s : %r is not upper case even though it is an abbriviation\\n\' % (path, id, word)\n
    else:\n
      if not word.istitle() and word not in LOWERCASE_WORD_DICT:\n
        error_message += \'%s : %s : %r is not titlecased\\n\' % (path, id, word)\n
  if len(word_list) > 1 and word_list[-1].upper() == \'LIST\' and word_list[-2].upper() != \'PACKING\':\n
    error_message += \'%s : %s : %r is a jargon\\n\' % (path, id, title)\n
  return error_message\n
\n
\n
\n
message_list = []\n
\n
\n
# Test portal_skins content\n
for folder in context.portal_skins.objectValues(spec=(\'Folder\',)):\n
  if not folder.id.startswith(\'erp5_\'):\n
    continue\n
  for form in folder.objectValues(spec=(\'ERP5 Form\',)):\n
    message = checkTitle(\'/\'.join([folder.id, form.id]), \'Title of the Form itself\', form.title)\n
    if message:\n
      message_list.append(message)\n
    for group in form.get_groups():\n
      if group == \'hidden\':\n
        continue\n
      for field in form.get_fields_in_group(group):\n
        if field.get_value(\'hidden\') or field.id == \'matrixbox\':\n
          continue\n
        message = checkField(folder, form, field)\n
        if message:\n
          message_list.append(message)\n
\n
\n
# Test worflow related stuff\n
for wf in context.portal_workflow.objectValues():\n
\n
  # Test workflow states\n
  wf_states = wf.states\n
  message = \'\'\n
  if wf_states not in (None, (), [], \'\'):\n
    for state in wf_states.objectValues() :\n
      message += checkTitle(\'/\'.join([\'portal_workflow\', wf.id, \'states\', state.id]), \'title\', state.title)\n
    if message:\n
      message_list.append(message)\n
\n
#   # Test workflow states\n
#   wf_scripts = wf.scripts\n
#   message = \'\'\n
#   if wf_scripts not in (None, (), [], \'\'):\n
#     for script in wf_scripts.objectValues():\n
#       message += checkTitle(\'/\'.join([\'portal_workflow\', wf.id, \'scripts\', script.id]), \'id\', script.id)\n
#     if message:\n
#       message_list.append(message)\n
\n
\n
# Test portal types\n
for ptype in context.portal_types.objectValues():\n
  pt_title = ptype.title\n
  pt_id = ptype.id\n
  message = \'\'\n
  if pt_title not in (None, \'\'):\n
    message += checkTitle(\'/\'.join([\'portal_types\', pt_id]), \'title\', pt_title)\n
  else:\n
    message += checkTitle(\'/\'.join([\'portal_types\', pt_id]), \'id\', pt_id)\n
  if message:\n
    message_list.append(message)\n
\n
\n
# Output the result as HTML with http links to objects\n
if html_output :\n
  print "<html>"\n
  for message in message_list:\n
    for sub_message in message.split("\\n"):\n
      if len(sub_message) > 0:\n
        form, text = sub_message.split(\':\', 1)\n
        print \'<a href="%s/manage_workspace">%s</a> : %s<br/>\' % (form.strip(), form, text)\n
      else:\n
        print "<br/>"\n
  return printed\n
\n
\n
return ("%d problems found :\\n\\n" % len(message_list)) + \'\\n\'.join(message_list)\n


]]></string> </value>
        </item>
        <item>
            <key> <string>_code</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_filepath</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_owner</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>html_output=1</string> </value>
        </item>
        <item>
            <key> <string>errors</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
        <item>
            <key> <string>func_code</string> </key>
            <value>
              <object>
                <klass>
                  <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
                </klass>
                <tuple/>
                <state>
                  <dictionary>
                    <item>
                        <key> <string>co_argcount</string> </key>
                        <value> <int>1</int> </value>
                    </item>
                    <item>
                        <key> <string>co_varnames</string> </key>
                        <value>
                          <tuple>
                            <string>html_output</string>
                            <string>_print_</string>
                            <string>_print</string>
                            <string>ABBRIVIATION_WORD_LIST</string>
                            <string>dict</string>
                            <string>append</string>
                            <string>$append0</string>
                            <string>_getiter_</string>
                            <string>word</string>
                            <string>ABBRIVIATION_WORD_DICT</string>
                            <string>LOWERCASE_WORD_LIST</string>
                            <string>LOWERCASE_WORD_DICT</string>
                            <string>ALLOWED_CHARS</string>
                            <string>checkTitle</string>
                            <string>checkField</string>
                            <string>message_list</string>
                            <string>_getattr_</string>
                            <string>context</string>
                            <string>folder</string>
                            <string>form</string>
                            <string>message</string>
                            <string>group</string>
                            <string>field</string>
                            <string>wf</string>
                            <string>wf_states</string>
                            <string>None</string>
                            <string>state</string>
                            <string>_inplacevar_</string>
                            <string>ptype</string>
                            <string>pt_title</string>
                            <string>pt_id</string>
                            <string>sub_message</string>
                            <string>len</string>
                            <string>text</string>
                          </tuple>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>func_defaults</string> </key>
            <value>
              <tuple>
                <int>1</int>
              </tuple>
            </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>ERP5Site_checkNamingConventions</string> </value>
        </item>
        <item>
            <key> <string>warnings</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
