예제 #1
0
def ERP5Site_clearActivities(self):
    """
    This method is used to recreated the activities keeping the 
    previous activities from one activity. The issue related to recreate 
    the Activity tables from one activity is that the activity (this method) 
    is also recreated, so it is kept for ever. 

    This method use a flag to define if the portal already recreated the 
    activities table. If yes, the flag is removed and the recreation will 
    be ignored.

    This method should be run into a single activity to prevent some action
    be excetured many times other parts.
  """
    instance_home = getConfiguration().instancehome
    flag_fs_path = instance_home + "/ACTIVITY_RECREATE_FLAG"
    log("Start to Clear activities.")
    if not os.path.exists(flag_fs_path):
        try:
            flag = open(flag_fs_path, 'w+')
            log("Clear Activities")
            self.getPortalObject().portal_activities.manageClearActivities(
                keep=1)
            active_result = ActiveResult()
            active_result.edit(
                summary="Activities Recreated",
                severity=0,
                detail="Activities Tables was recreated Sucessfully.")
            return active_result
        except:
            os.remove(flag_fs_path)
            raise

    os.remove(flag_fs_path)
    return
def ERP5Site_clearActivities(self):
  """
    This method is used to recreated the activities keeping the 
    previous activities from one activity. The issue related to recreate 
    the Activity tables from one activity is that the activity (this method) 
    is also recreated, so it is kept for ever. 

    This method use a flag to define if the portal already recreated the 
    activities table. If yes, the flag is removed and the recreation will 
    be ignored.

    This method should be run into a single activity to prevent some action
    be excetured many times other parts.
  """
  instance_home = getConfiguration().instancehome
  flag_fs_path = instance_home + "/ACTIVITY_RECREATE_FLAG"
  log("Start to Clear activities.")
  if not os.path.exists(flag_fs_path):
    try:
      flag = open(flag_fs_path, 'w+')
      log("Clear Activities")
      self.getPortalObject().portal_activities.manageClearActivities(keep=1)
      active_result = ActiveResult()
      active_result.edit(summary="Activities Recreated",
                       severity=0,
                       detail="Activities Tables was recreated Sucessfully.")
      return active_result
    except:
      os.remove(flag_fs_path)
      raise 

  os.remove(flag_fs_path)
  return
def checkConversionToolAvailability(self):
  """
  Check conversion tool (oood) is available for erp5.
  This script convert an odt document into HTML and try to read
  the returned string and find out expected string
  """
  portal = self.getPortalObject()
  document_id = 'P-ERP5-TEST.Conversion.Tool.Availability-001-en.odt'
  document_path = 'portal_skins/erp5_administration/%s' % (document_id,)
  document_file = portal.restrictedTraverse(document_path)

  message = None
  severity = 0

  try:
    temp_document = newTempOOoDocument(self, document_id, data=document_file.data, source_reference=document_id)
    temp_document.convertToBaseFormat()
    _, html_result = temp_document.convert(format='html')
  except ConflictError:
    raise
  except: #Which Errors should we catch ?
    #Transformation failed
    message = 'Conversion tool got unexpected error:\n%s' % ''.join(ExceptionFormatter.format_exception(*sys.exc_info()))
  else:
    #Everything goes fine, Check that expected string is present in HTML conversion
    if 'AZERTYUIOPMQ' not in html_result:
      message = 'Conversion to HTML Failed:\n%s' % (html_result,)

  active_process = self.newActiveProcess()
  result = ActiveResult()
  if message:
    severity = 1
    result.edit(detail=message)
  result.edit(severity=severity)
  active_process.activateResult(result)
def check(node_uid, section_uid, mirror_section_uid):
    precision = precision_by_section_uid[section_uid]
    if mirror_section_uid is None:
        mirror_section_uid = SimpleQuery(mirror_section_uid=None)
    line_list = portal.portal_simulation.getMovementHistoryList(
        portal_type=portal.getPortalAccountingMovementTypeList(),
        grouping_reference=context.getGroupingReference(),
        node_uid=node_uid,
        section_uid=section_uid,
        mirror_section_uid=mirror_section_uid)
    if not line_list:
        return
    total = round(sum([(l.total_price or 0) for l in line_list]), precision)
    if total != 0:
        # XXX if n transactions that do not match are grouped together, the same
        # problem will be reported n times.
        portal.restrictedTraverse(active_process).postResult(
            ActiveResult(summary=script.getId(),
                         detail='%s has wrong grouping (%s)' %
                         (context.getRelativeUrl(), total),
                         result='',
                         severity=100))

    # XXX we could check this as well
    """
예제 #5
0
def example_random_forest_function(self, active_process_path):
    digits = load_digits()

    X_train, X_test, y_train, y_test = train_test_split(digits.data,
                                                        digits.target,
                                                        random_state=0)

    # Create an active process
    active_process = self.portal_activities.unrestrictedTraverse(
        active_process_path)

    # Use CMFActivity as a backend for joblib
    with parallel_backend('CMFActivity',
                          n_jobs=2,
                          active_process=active_process):
        final_model = grow_ensemble(RandomForestClassifier(),
                                    X_train,
                                    y_train,
                                    n_estimators=10,
                                    n_jobs=2,
                                    random_state=42)
    score = final_model.score(X_test, y_test)

    # Set result value and an id to the active result and post it
    result = ActiveResult(result=score, signature=123)
    active_process.postResult(result)
    log('ok', len(final_model.estimators_))
    return 'ok', len(final_model.estimators_), score
예제 #6
0
def ERP5Site_restartZopeInstance(self):
    """
    Zope must be restart after update the Products or Software
    But the restart into one activity, will make the activity always
    fail and with the server will be restart many times.

    This method use a flag to define if the server was already restarted.
    If yes, the flag is removed and the restart will be ignored.

    This method should be run into a single activity to prevent rollback
    other parts.
  """
    import Lifetime
    Lifetime.shutdown(1, fast=1)
    log("Zope Restart was launched.")

    active_result = ActiveResult()
    active_result.edit(summary="Zope Restart",
                       severity=0,
                       detail="Zope was restart Sucessfully.")
    return active_result
def ERP5Site_restartZopeInstance(self):
  """
    Zope must be restart after update the Products or Software
    But the restart into one activity, will make the activity always
    fail and with the server will be restart many times.

    This method use a flag to define if the server was already restarted.
    If yes, the flag is removed and the restart will be ignored.

    This method should be run into a single activity to prevent rollback
    other parts.
  """
  import Lifetime
  Lifetime.shutdown(1,fast=1)
  log("Zope Restart was launched.")

  active_result = ActiveResult()
  active_result.edit(summary="Zope Restart",
                     severity=0,
                     detail="Zope was restart Sucessfully.")
  return active_result
def checkConversionToolAvailability(self):
  """
  Check conversion tool (oood) is available for erp5.
  This script convert an odt document into HTML and try to read
  the returned string and find out expected string
  """
  portal = self.getPortalObject()
  document_id = 'P-ERP5-TEST.Conversion.Tool.Availability-001-en.odt'
  document_path = 'portal_skins/erp5_administration/%s' % (document_id,)
  document_file = portal.restrictedTraverse(document_path)

  message = None
  severity = 0

  try:
    temp_document = newTempOOoDocument(self, document_id, data=document_file.data, source_reference=document_id)
    temp_document.convertToBaseFormat()
    _, html_result = temp_document.convert(format='html')
  except ConflictError:
    raise
  except: #Which Errors should we catch ?
    #Transformation failed
    message = 'Conversion tool got unexpected error:\n%s' % ''.join(ExceptionFormatter.format_exception(*sys.exc_info()))
  else:
    #Everything goes fine, Check that expected string is present in HTML conversion
    if 'AZERTYUIOPMQ' not in html_result:
      message = 'Conversion to HTML Failed:\n%s' % (html_result,)

  active_process = self.newActiveProcess()
  result = ActiveResult()
  if message:
    severity = 1
    result.edit(detail=message)
  result.edit(severity=severity)
  active_process.postResult(result)
예제 #9
0
def example_simple_function(self, active_process_path):
    """ simple function to calculate sqrt
  """
    active_process = self.portal_activities.unrestrictedTraverse(
        active_process_path)

    # Use CMFActivity as a backend for joblob
    with parallel_backend('CMFActivity', active_process=active_process):
        result = Parallel(n_jobs=2, pre_dispatch='all', timeout=30,
                          verbose=30)(delayed(sqrt)(i**2) for i in range(5))

    # Set result value and an id to the active result and post it
    result = ActiveResult(result=result)
    active_process.postResult(result)
    log("joblib activity result", result)
    return result
packet_size = search_kw.pop('packet_size', 30)
limit = packet_size * search_kw.pop('activity_count', 100)

r = sub.getDocumentIdList(limit=limit, **search_kw)

result_count = len(r)
if result_count:
  if result_count == limit:
    # Recursive call to prevent too many activity generation
    next_kw = dict(activate_kw, priority=1+activate_kw.get('priority', 1))
    kw["min_id"] = r[-1].getId()
    sub.activate(**next_kw).SynchronizationTool_activateCheckPointFixe(
      callback, method_kw, activate_kw, **kw)

  r = [x.getId() for x in r]
  callback_method = getattr(sub.activate(**activate_kw), callback)
  for i in xrange(0, result_count, packet_size):
    callback_method(id_list=r[i:i+packet_size],
                    **method_kw)

if result_count < limit:
  # Register end of point fixe
  from Products.CMFActivity.ActiveResult import ActiveResult
  active_result = ActiveResult()
  active_result.edit(summary='Info',
                   severity=0,
                   detail="Point fixe check ended at %r" % (DateTime().strftime("%d/%m/%Y %H:%M"),))
  sub.activate(active_process=method_kw["active_process"],
              activity='SQLQueue', 
              priority=2,).ERP5Site_saveCheckCatalogTableResult(active_result)
예제 #11
0
def some(iterable, function):
  for v in iterable:
    if function(v): return True
  return False

# Browse files and folders recursively
def execute(skin):
  for o in skin.objectValues():
    # browsing files
    oid = o.id
    # force oid to be a string
    if callable(oid): oid = oid()
    if o.meta_type in meta_type_checklist or \
       some(file_extension_checklist, oid.endswith):
      # this file matches the cheklists requirements
      current_cache_manager_id = o.ZCacheable_getManagerId()
      if current_cache_manager_id is None:
        # the current file is not cached
        if fixit: o.ZCacheable_setManagerId(cache_manager_id)
        else: incorrect_file_absolute_url_list.append(o.absolute_url(relative=1))
    elif o.meta_type == 'Folder':
      execute(o)

for skin in context.portal_skins.objectValues():
  execute(skin)
  
if incorrect_file_absolute_url_list != []:
  return ActiveResult(severity=100, detail="There is no cache set for:\n" + "\n".join(incorrect_file_absolute_url_list))
  
return ActiveResult(severity=0, detail="OK")
예제 #12
0
                        "amount": line.total_price or 0,
                        "quantity": line.quantity or 0,
                        "quantity_unit":
                        translate(line.strict_quantity_unit_title)
                    }
                }
            else:
                if not line_dict[product_title].has_key(period):
                    line_dict[product_title][period] = {
                        "amount": line.total_price or 0,
                        "quantity": line.quantity or 0,
                        "quantity_unit":
                        translate(line.strict_quantity_unit_title)
                    }
                else:
                    line_dict[product_title][period]['amount'] = line_dict[
                        product_title][period]['amount'] + (line.total_price
                                                            or 0)
                    line_dict[product_title][period]['quantity'] = line_dict[
                        product_title][period]['quantity'] + (line.quantity
                                                              or 0)

active_process_value = portal.restrictedTraverse(active_process)
active_process_value.postResult(
    ActiveResult(sevrity=1,
                 detail=dumps({
                     'type': "result",
                     'client_dict': client_dict,
                     'product_dict': product_dict,
                 })))
예제 #13
0
from Products.CMFActivity.ActiveResult import ActiveResult
from Products.ERP5.Tool.TemplateTool import BusinessTemplateUnknownError
from Products.ERP5.Tool.TemplateTool import CATALOG_UPDATABLE

portal = context.getPortalObject()
template_tool = portal.portal_templates
bt5 = portal.getPromiseParameter('portal_templates', 'expected_bt5')

if bt5 is None:
  return

active_result = ActiveResult()

bt5_list = bt5.split()
bt5_list.extend(template_tool.getInstalledBusinessTemplateTitleList())

try:
  message_list = template_tool.upgradeSite(bt5_list, dry_run=True,
                                 update_catalog=CATALOG_UPDATABLE)
  severity = len(message_list)
except BusinessTemplateUnknownError, error:
  severity = -1
  detail = str(error)

if severity == -1:
  severity = 5
  summary = "Unable to resolve bt5 dependencies"
elif severity == 0:
  summary = "Nothing to do."
  detail = ""
else:
예제 #14
0
    

for brain in portal.portal_simulation.getInventoryList(**search_params):
  if round(brain.total_price, precision) == 0:
    print '%s has a 0 balance but some not grouped transactions.' % brain.mirror_section_relative_url
    if fixit:
      tr = brain.getObject().getParentValue()
      grouped_line_list = tr.AccountingTransaction_guessGroupedLines()
      if not grouped_line_list:
        # Group whatever can be grouped. XXX maybe we want to make this optional.
        grouped_line_list = tr.AccountingTransaction_guessGroupedLines(
          accounting_transaction_line_uid_list=[
            line.uid for line in portal.portal_simulation.getMovementHistoryList(
                                    node_uid=brain.node_uid,
                                    mirror_section_uid=brain.mirror_section_uid,
                                    section_uid=section_uid_list,
                                    simulation_state=('stopped', 'delivered'),
                                    portal_type=portal.getPortalAccountingMovementTypeList(),
                                    grouping_reference=None,) if not line.getObject().getGroupingReference()])
      if grouped_line_list:
        print 'FIXED', grouped_line_list
      else:
        print 'NOT FIXED'
        
active_result = ActiveResult(
  summary=context.getTitle(),
  severity=str(printed) and 100 or 0,
  detail=printed,)
  
active_process.postResult(active_result)
예제 #15
0
active_process_path = site.portal_activities.newActiveProcess(
    start_date=DateTime(), causality_value=sub).getPath()
method_kw = {
    "publication_path": pub.getPath(),
    "subscription_path": sub.getPath(),
    "active_process": active_process_path,
}
activate_kw = {
    "priority": 3,
    "activity": "SQLQueue",
}

# Register start of point fixe
from Products.CMFActivity.ActiveResult import ActiveResult

active_result = ActiveResult()
active_result.edit(summary='Info',
                   severity=0,
                   detail="Point fixe check launched at %r" %
                   (DateTime().strftime("%d/%m/%Y %H:%M"), ))
sub.activate(
    active_process=active_process_path,
    activity='SQLQueue',
    priority=2,
).ERP5Site_saveCheckCatalogTableResult(active_result)

context.SynchronizationTool_activateCheckPointFixe(callback=callback,
                                                   method_kw=method_kw,
                                                   activate_kw=activate_kw)

qs = '?portal_status_message=%s' % "Point fixe running, active process path is %s" % (
예제 #16
0
  on, at maximum, bundle_object_count objects.

  bundle_object_count
    Maximum number of objects to deal with in one transaction. 
    An activity is started after each successfull execution which
    found bundle_object_count to work on.
  property_override_method_id
    Id of a method that generates a dictionary of reference values
    for a particular item in the catalog.
  catalog_kw
    Extra parameters passed to catalog
  retry
"""
from DateTime import DateTime
from Products.CMFActivity.ActiveResult import ActiveResult
active_result = ActiveResult()
portal = context.getPortalObject()
activate = portal.portal_activities.activate
result_list = []
if catalog_kw is None:
  catalog_kw = {}

catalog_kw.setdefault('sort_on', (('uid','ascending'),))

if catalog_uid_list is None:
  # No uid list was given: fetch work to do from catalog and spawn activities
  first_run = uid_min is None
  if uid_min is not None:
    # Check what is after last check
    catalog_kw['uid'] = {'query': uid_min, 'range': 'nlt'}
  catalog_uid_list = [x.uid for x in portal.portal_catalog(
예제 #17
0
from Products.ERP5Type.Constraint import PropertyTypeValidity
from Products.CMFActivity.ActiveResult import ActiveResult

portal = context.getPortalObject()
constraint_message_list = []

if context.providesIConstraint():
  # it is not possible to checkConsistency of Constraint itself, as method
  # of this name implement consistency checking on object
  return constraint_message_list

missing_category_document = portal.portal_trash.newContent(
  portal_type='Missing Category Document Constraint',
  temp_object=True)
property_type_validity = PropertyTypeValidity(id='type_check', description='Type Validity Check')

if fixit:
  constraint_message_list.extend(context.fixConsistency())
  constraint_message_list.extend(property_type_validity.fixConsistency(context))
  constraint_message_list.extend(missing_category_document.fixConsistency(context))
else:
  constraint_message_list.extend(context.checkConsistency(fixit=fixit))
  constraint_message_list.extend(property_type_validity.checkConsistency(context, fixit=fixit))
  constraint_message_list.extend(missing_category_document.checkConsistency(context, fixit=fixit))

if constraint_message_list:
  portal.restrictedTraverse(active_process).postResult(ActiveResult(severity=100,
                      constraint_message_list=constraint_message_list))
from Products.CMFActivity.ActiveResult import ActiveResult

portal = context.getPortalObject()
mailhost = portal.MailHost
if getattr(mailhost, 'getMessageList', None) is not None:
    context.newActiveProcess().postResult(
        ActiveResult(
            severity=1,
            summary="%s/MailHost is not real MailHost" % portal.getPath(),
            detail=
            "Possibly comes from DummyMailHost. The object has to be fixed by recreating it."
        ))
    return

promise_url = portal.getPromiseParameter('external_service', 'smtp_url')

if promise_url is None:
    return

promise_url = promise_url.rstrip('/')
if mailhost.force_tls:
    protocol = 'smtps'
else:
    protocol = 'smtp'

if mailhost.smtp_uid:
    auth = '%s:%s@' % (mailhost.smtp_uid, mailhost.smtp_pwd)
else:
    auth = ''

url = "%s://%s%s:%s" % (protocol, auth, mailhost.smtp_host, mailhost.smtp_port)
예제 #19
0
from Products.CMFActivity.ActiveResult import ActiveResult
active_result = ActiveResult()
severity = len(error_list)
if severity == 0:
  summary = "No error"
else:
  summary = "Error"
active_result.edit(summary=summary, severity=severity, detail='\n'.join(error_list))
return active_result
예제 #20
0
from Products.CMFActivity.ActiveResult import ActiveResult

portal = context.getPortalObject()
promise_url = portal.getPromiseParameter('external_service', 'kumofs_url')

if promise_url is None:
  return

plugin = portal.portal_memcached.restrictedTraverse("persistent_memcached_plugin", None)
if plugin is None:
  return

url = "memcached://%s/" % plugin.getUrlString()

active_result = ActiveResult()

if promise_url != url:
  severity = 1
  summary = "Kumofs not configured as expected"
else:
  severity = 0
  summary = "Nothing to do."

active_result.edit(
  summary=summary, 
  severity=severity, 
  detail="Expect %s\nGot %s" % (promise_url, url))

context.newActiveProcess().postResult(active_result)
    try:
        sub_xml = getattr(sub_object,
                          sub_xml_method_id)(context_document=subscription)
    except TypeError:
        sub_xml = getattr(sub_object, sub_xml_method_id)()
    if pub_object:
        try:
            pub_xml = getattr(pub_object,
                              pub_xml_method_id)(context_document=publication)
        except TypeError:
            pub_xml = getattr(pub_object, pub_xml_method_id)()
    else:
        pub_xml = ""
    diff = portal.diffXML(xml_plugin=sub_xml, xml_erp5=pub_xml, html=False)
    context.log("Got diff for GID %s" % (gid, ))
    if diff != "No diff":
        append(diff)

if len(diff_list):
    severity = len(diff_list)
    from Products.CMFActivity.ActiveResult import ActiveResult
    active_result = ActiveResult()
    active_result.edit(summary='Failed',
                       severity=severity,
                       detail='\n'.join(diff_list))
    subscription.activate(
        active_process=active_process,
        activity='SQLQueue',
        priority=2,
    ).ERP5Site_saveCheckCatalogTableResult(active_result)
  gid = subscription.getGidFromObject(sub_object)
  # Retrieve the corresponding document from the publication
  pub_object = publication.getDocumentFromGid(gid)
  # Compare their xml
  try:
    sub_xml = getattr(sub_object, sub_xml_method_id)(context_document=subscription)
  except TypeError:
    sub_xml = getattr(sub_object, sub_xml_method_id)()
  if pub_object:
    try:
      pub_xml = getattr(pub_object, pub_xml_method_id)(context_document=publication)
    except TypeError:
      pub_xml = getattr(pub_object, pub_xml_method_id)()
  else:
    pub_xml = ""
  diff = portal.diffXML(xml_plugin=sub_xml, xml_erp5=pub_xml, html=False)
  context.log("Got diff for GID %s" %(gid,))
  if diff != "No diff":
    append(diff)

if len(diff_list):
  severity = len(diff_list)
  from Products.CMFActivity.ActiveResult import ActiveResult
  active_result = ActiveResult()
  active_result.edit(summary='Failed',
                     severity=severity,
                     detail='\n'.join(diff_list))
  subscription.activate(active_process=active_process,
            activity='SQLQueue', 
            priority=2,).ERP5Site_saveCheckCatalogTableResult(active_result)
from Products.CMFActivity.ActiveResult import ActiveResult
portal = context.getPortalObject()
portal_type = portal.portal_types[portal_type]
active_process = portal.restrictedTraverse(active_process)
this_portal_type_active_process = portal.restrictedTraverse(this_portal_type_active_process)

# XXX we need proxy role for this
result_list = this_portal_type_active_process.getResultList()

if result_list:
  journal_fragment = context.AccountingTransactionModule_viewJournalAsFECXML(
      portal_type=portal_type,
      result_list=result_list)
  
  active_process.postResult(ActiveResult(detail=journal_fragment.encode('utf8').encode('zlib')))

# delete no longer needed active process
this_portal_type_active_process.getParentValue().manage_delObjects(ids=[this_portal_type_active_process.getId()])
예제 #24
0
"""Produce an xml fragment for this accounting transaction and post it to the
active result.
We need a proxy role to post the result.
"""
from Products.CMFActivity.ActiveResult import ActiveResult

portal = context.getPortalObject()
active_process = portal.restrictedTraverse(active_process)
accounting_line_list = context.contentValues(
    portal_type=portal.getPortalAccountingMovementTypeList())

if context.getSourceSectionUid() in section_uid_list:
    if any([
            line.getSource(portal_type='Account')
            for line in accounting_line_list
    ]):
        source_xml = context.AccountingTransaction_viewAsSourceFECXML()
        active_process.postResult(
            ActiveResult(detail=source_xml.encode('utf8').encode('zlib')))

if context.getDestinationSectionUid() in section_uid_list:
    if any([
            line.getDestination(portal_type='Account')
            for line in accounting_line_list
    ]):
        destination_xml = context.AccountingTransaction_viewAsDestinationFECXML(
        )
        active_process.postResult(
            ActiveResult(detail=destination_xml.encode('utf8').encode('zlib')))
예제 #25
0
        'view',
        keep_items=dict(portal_status_message=N_(
            "You haven't defined your email address")))

parameter_dict, stat_columns, selection_columns = context.OrderModule_getOrderReportParameterDict(
)

active_process = context.OrderModule_activateGetOrderStatList(tag=script.id,
                                                              **parameter_dict)

# Create a result to store computed parameter for later
active_process.postResult(
    ActiveResult(sevrity=1,
                 detail=dumps({
                     'type': 'parameters',
                     'params': parameter_dict,
                     'stat_columns': stat_columns,
                     'selection_columns': selection_columns,
                 })))

request = context.REQUEST
context.getPortalObject().portal_skins.changeSkin("Deferred")
request.set('portal_skin', "Deferred")
assert deferred_portal_skin is not None, "No deferred portal skin found in parameters"
request.set('deferred_portal_skin', deferred_portal_skin)

kw['deferred_style'] = 1
kw['active_process'] = active_process.getPath()
request.set('active_process', active_process.getPath())
kw.update(parameter_dict)
kw.pop('format', None)
    # it is not possible to checkConsistency of Constraint itself, as method
    # of this name implement consistency checking on object
    return constraint_message_list

# this constraint is created as a temp object under portal_trash, because
# portal_trash has no restriction on allowed content types.
missing_category_document = portal.portal_trash.newContent(
    portal_type='Missing Category Document Constraint',
    id='missing_category_document_constraint',
    temp_object=True)
property_type_validity = PropertyTypeValidity(
    id='type_check', description='Type Validity Check')

if fixit:
    constraint_message_list.extend(context.fixConsistency())
    constraint_message_list.extend(
        property_type_validity.fixConsistency(context))
    constraint_message_list.extend(
        missing_category_document.fixConsistency(context))
else:
    constraint_message_list.extend(context.checkConsistency(fixit=fixit))
    constraint_message_list.extend(
        property_type_validity.checkConsistency(context, fixit=fixit))
    constraint_message_list.extend(
        missing_category_document.checkConsistency(context, fixit=fixit))

if constraint_message_list:
    portal.restrictedTraverse(active_process).postResult(
        ActiveResult(severity=100,
                     constraint_message_list=constraint_message_list))
예제 #27
0
portal = context.getPortalObject()
promise_repository = portal.getPromiseParameter('portal_templates',
                                                'repository')

if promise_repository is None:
    return

if promise_repository:
    promise_repository_list = promise_repository.split()
    promise_repository_list.sort()
else:
    promise_repository_list = []

repository_list = portal.portal_templates.getRepositoryList()
repository_list.sort()

active_result = ActiveResult()

if repository_list != promise_repository_list:
    severity = 1
    summary = "Template tool not configured as expected"
    detail = '\n'.join(promise_repository_list)
else:
    severity = 0
    summary = "Nothing to do."
    detail = ""

active_result.edit(summary=summary, severity=severity, detail=detail)

context.newActiveProcess().postResult(active_result)
예제 #28
0
from Products.CMFActivity.ActiveResult import ActiveResult
portal = context.getPortalObject()

tracking_list = list(
    reversed(
        portal.portal_simulation.getCurrentTrackingList(
            aggregate_uid=context.getUid())))
if tracking_list:
    delivery_dict = {
        x.uid: x.getObject()
        for x in portal.portal_catalog(
            uid=[x.delivery_uid for x in tracking_list], )
    }
    for previous_brain, next_brain in zip(tracking_list, tracking_list[1:]):
        if delivery_dict[previous_brain.delivery_uid].getDestination(
        ) != delivery_dict[next_brain.delivery_uid].getSource():
            portal.restrictedTraverse(active_process).postResult(
                ActiveResult(summary=script.getId(),
                             detail='%s has tracking error' %
                             context.getRelativeUrl(),
                             result='',
                             severity=100))