Commit e466a244 authored by Nicolas Dumazet's avatar Nicolas Dumazet

Postpone as much as possible import to prevent loops

This allows ActiveObject import in SQLCatalog, enabling again activate() on
SQL Catalog, and eventually fixing the current test failures (AttributeError:
SQLCatalog_catalogTransformation raised on portal/portal_catalog)

A proper, durable fix to the silent import failures in SQLCatalog is still
required.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33995 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2428d520
......@@ -32,7 +32,6 @@
from PropertyExistence import PropertyExistence
from Products.CMFCore.Expression import Expression
from Products.ZSQLCatalog.SQLCatalog import Query, NegatedQuery
class AttributeUnicity(PropertyExistence):
"""
......@@ -69,6 +68,7 @@ class AttributeUnicity(PropertyExistence):
from Products.ERP5Type.Utils import createExpressionContext
econtext = createExpressionContext(obj)
criterion_dict = expression(econtext)
from Products.ZSQLCatalog.SQLCatalog import Query, NegatedQuery
# Add uid in criterion keys to avoid fetching current object.
criterion_dict['query'] = NegatedQuery(Query(uid=obj.getUid()))
portal = obj.portal_catalog.getPortalObject()
......
......@@ -64,7 +64,6 @@ from Products.PageTemplates.Expressions import SecureModuleImporter
from Products.ZCatalog.Lazy import LazyMap
from Products.ERP5Type import Permissions
from Products.ERP5Type import Constraint
from Products.ERP5Type.Accessor.Constant import PropertyGetter as \
PropertyConstantGetter
......@@ -1125,6 +1124,7 @@ def createConstraintList(property_holder, constraint_definition):
constraint_definition -- the constraint with all attributes
"""
from Products.ERP5Type import Constraint
try:
consistency_class = getattr(Constraint, constraint_definition['type'])
except AttributeError:
......@@ -1501,10 +1501,11 @@ def setDefaultProperties(property_holder, object=None, portal=None):
createRelatedValueAccessors(property_holder, cat, read_permission=read_permission)
# Unnecessary to create these accessors more than once.
base_category_dict.clear()
from Products.ERP5Type.Constraint import PropertyTypeValidity
# Create the constraint method list - always check type
property_holder.constraints = [
Constraint.PropertyTypeValidity(id='type_check',
description="Type Validity Check Error") ]
PropertyTypeValidity(id='type_check',
description="Type Validity Check Error") ]
for const in constraint_list:
createConstraintList(property_holder, constraint_definition=const)
......
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