Commit 78a8f52c authored by Arnaud Fontaine's avatar Arnaud Fontaine

WIP: Make ERP5Type self-contained and independent of ERP5 Product.

parent c502e47c
......@@ -29,7 +29,7 @@
import os, shutil, tempfile, unittest
from Acquisition import aq_base
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5.ERP5Site import addERP5Tool
from Products.ERP5Type.ERP5Site import addERP5Tool
class TestInotifyTool(ERP5TypeTestCase):
def test_inotify(self):
......
......@@ -37,7 +37,7 @@ class MagentoTestConnector:
def __init__(self):
"""
"""
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
self.context = getSite()
......
......@@ -184,7 +184,7 @@ class OxatisTestConnector:
def __init__(self):
"""
"""
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
self.context = getSite()
......
......@@ -107,7 +107,7 @@ class UbercartTestConnector:
def __init__(self):
"""
"""
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
self.context = getSite()
def validateXMLScheme(self, xml, xsd_filename):
......
......@@ -116,7 +116,7 @@ class VirtueMartTestConnector:
def __init__(self):
"""
"""
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
self.context = getSite()
def getPropertySheetDefinitionList(self, type):
......
......@@ -5451,7 +5451,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
# update tools if necessary
if self.getTitle() == 'erp5_core' and self.getTemplateUpdateTool():
from Products.ERP5.ERP5Site import ERP5Generator
from Products.ERP5Type.ERP5Site import ERP5Generator
gen = getattr(site, '_generator_class', ERP5Generator)()
LOG('Business Template', 0, 'Updating Tools')
gen.setup(site, 0, update=1)
......@@ -6457,9 +6457,9 @@ Business Template is a set of definitions, such as skins, portal types and categ
_migrate_exception_set = set([
## Bootstrap
'Products.ERP5.Document.BusinessTemplate',
'Products.ERP5.ERP5Site',
'Products.ERP5Type.ERP5Site',
'Products.ERP5.genbt5list',
'Products.ERP5.Tool.CategoryTool',
'Products.ERP5Type.Tool.CategoryTool',
'Products.ERP5.Tool.TemplateTool',
'Products.ERP5Type.Base',
'Products.ERP5Type.Cache',
......
......@@ -59,7 +59,7 @@ class PortalTypeClassInteractor(Interactor):
"""
Call resetDynamicDocuments at the end of the transaction
"""
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
# method_call_object might be an unwrapped DCWorflowDefinition method,
# no even belonging to a container.
portal = getSite()
......
......@@ -41,21 +41,18 @@ from Products.ERP5Type.Globals import package_home
product_path = package_home( globals() )
# Define object classes and tools
from Tool import CategoryTool, IdTool, TemplateTool,\
from Tool import IdTool, TemplateTool,\
TestTool, DomainTool, AlarmTool,\
TrashTool, ContributionTool, NotificationTool, PasswordTool,\
GadgetTool, ContributionRegistryTool, IntrospectionTool,\
AcknowledgementTool, SolverTool,\
UrlRegistryTool, InterfaceTool,\
CertificateAuthorityTool, InotifyTool
import ERP5Site
from Document import PythonScript, SQLMethod
object_classes = ( ERP5Site.ERP5Site,
PythonScript.PythonScriptThroughZMI,
object_classes = ( PythonScript.PythonScriptThroughZMI,
SQLMethod.SQLMethod,
)
portal_tools = ( CategoryTool.CategoryTool,
IdTool.IdTool,
portal_tools = ( IdTool.IdTool,
TemplateTool.TemplateTool,
AlarmTool.AlarmTool,
DomainTool.DomainTool,
......
......@@ -37,7 +37,7 @@ from erp5.component.module.ExpandPolicy import policy_dict, TREE_DELIVERED_CACHE
from zLOG import LOG, WARNING
from Products.ERP5.mixin.property_recordable import PropertyRecordableMixin
from Products.ERP5Type.mixin.property_recordable import PropertyRecordableMixin
from erp5.component.mixin.ExplainableMixin import ExplainableMixin
from erp5.component.interface.IExpandable import IExpandable
......
......@@ -30,7 +30,7 @@
erp5.component.interface.ISimulationMovement
"""
from Products.ERP5.interfaces.property_recordable import IPropertyRecordable
from Products.ERP5Type.interfaces.property_recordable import IPropertyRecordable
from Products.ERP5.interfaces.movement import IMovement
from erp5.component.interface.IDivergenceController import IDivergenceController
from Products.ERP5.interfaces.explainable import IExplainable
......
......@@ -27,11 +27,11 @@
#
##############################################################################
from Products.ERP5.interfaces.predicate import IPredicate
from Products.ERP5Type import interfaces
_MARKER = []
class IMappedValue(IPredicate):
class IMappedValue(interfaces.IPredicate):
"""Mapped Value document interface specification
A Mapped Value provides
......
......@@ -387,7 +387,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
parent = self.aq_parent
portal_types = parent.portal_types
portal_property_sheets = parent.portal_property_sheets
from Products.ERP5.ERP5Site import ERP5Generator
from Products.ERP5Type.ERP5Site import ERP5Generator
ERP5Generator.bootstrap(portal_types, 'erp5_core', 'PortalTypeTemplateItem', (
'Catalog',
'Catalog Tool',
......
......@@ -54,7 +54,7 @@ def ERP5Site_createModuleScribus(self,
from Products.ERP5Form.CreatePropertySheet import LocalGenerator
# importing module to get an access to the 'searchFolder' method
# needed to be able to list the objects in 'list_object_view' form
from Products.ERP5.ERP5Site import ERP5Site
from Products.ERP5Type.ERP5Site import ERP5Site
from zLOG import LOG, TRACE, WARNING, ERROR, INFO
# CREATING MODULES INSTANCES
......
......@@ -49,7 +49,7 @@ def ERP5Site_updateModuleScribus(self,
from Products.ERP5Form.CreatePropertySheet import LocalGenerator
# importing module to get an access to the 'searchFolder' method
# needed to be able to list the objects in 'list_object_view' form
from Products.ERP5.ERP5Site import ERP5Site
from Products.ERP5Type.ERP5Site import ERP5Site
from Products.CMFCore.utils import getToolByName
from zLOG import LOG, TRACE, WARNING, ERROR, INFO
......
......@@ -58,7 +58,7 @@ class FieldValueCacheDict(dict):
def clear(self):
super(FieldValueCacheDict, self).clear()
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
try:
portal = getSite()
except IndexError:
......@@ -68,7 +68,7 @@ class FieldValueCacheDict(dict):
self._last_sync = portal.getCacheCookie('form_field_value_cache')
def __getitem__(self, cache_id):
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
try:
portal = getSite()
except IndexError:
......
......@@ -41,7 +41,7 @@ import random
import getopt, sys, os, re
from urllib import quote
from Products.ERP5.ERP5Site import ERP5Site
from Products.ERP5Type.ERP5Site import ERP5Site
from Products.Formulator.TALESField import TALESMethod
from Products.Formulator.MethodField import Method
from Products.ERP5Type.Utils import convertToUpperCase
......
......@@ -29,7 +29,7 @@ from logging import getLogger
from Products.ERP5SyncML.Engine.EngineMixin import EngineMixin
from Products.ERP5SyncML.SyncMLConstant import ACTIVITY_PRIORITY
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
syncml_logger = getLogger('ERP5SyncML')
......
......@@ -38,7 +38,7 @@ from Products.ERP5SyncML.SyncMLConstant import ACTIVITY_PRIORITY, \
from Products.ERP5SyncML.SyncMLMessage import SyncMLRequest
from Products.ERP5SyncML.Engine.SynchronousEngine import SyncMLSynchronousEngine
from Products.ERP5SyncML.Engine.AsynchronousEngine import SyncMLAsynchronousEngine
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
synchronous_engine = SyncMLSynchronousEngine()
asynchronous_engine = SyncMLAsynchronousEngine()
......
......@@ -27,7 +27,7 @@
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
class ERP5Transport:
"""
......
......@@ -27,7 +27,7 @@
from HTTP import ConnectionError
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
class MailTransport:
......
......@@ -38,7 +38,7 @@ from ERP5Diff import ERP5Diff
from DateTime import DateTime
from SyncMLConstant import SYNCML_NAMESPACE, NSMAP, MAX_LEN
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
E = ElementMaker(namespace=SYNCML_NAMESPACE, nsmap=NSMAP)
parser = etree.XMLParser(remove_blank_text=True)
......
......@@ -27,7 +27,7 @@
##############################################################################
from Products.ERP5Type.Tool.WebServiceTool import ConnectionError
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
class MethodWrapper(object):
......
......@@ -353,7 +353,7 @@ def _aq_reset():
# Callers expect to re-generates accessors right now, so call
# resetDynamicDocuments to maintain backward-compatibility
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
getSite().portal_types.resetDynamicDocuments()
class PropertyHolder(object):
......
......@@ -27,7 +27,7 @@
##############################################################################
from Products.ERP5Type.Tool.WebServiceTool import ConnectionError
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
class MethodWrapper(object):
......
......@@ -232,7 +232,7 @@ class StandardProperty(IdAsReferenceMixin('_property'), XMLObject):
@param kind: 'min' or 'max'
@type kind: string
@param portal: Portal object
@type portal: Products.ERP5.ERP5Site.ERP5Site
@type portal: Products.ERP5Type.ERP5Site.ERP5Site
"""
property_dict['reference'] = '%s_range_%s' % (property_dict['reference'],
kind)
......@@ -281,7 +281,7 @@ class StandardProperty(IdAsReferenceMixin('_property'), XMLObject):
@param accessor_holder: Accessor holder to applied the accessors on
@type accessor_holder: Products.ERP5Type.dynamic.accessor_holder.AccessorHolderType
@param portal: Portal object
@type portal: Products.ERP5.ERP5Site.ERP5Site
@type portal: Products.ERP5Type.ERP5Site.ERP5Site
"""
try:
localizer = portal._getOb('Localizer')
......@@ -498,7 +498,7 @@ class StandardProperty(IdAsReferenceMixin('_property'), XMLObject):
@param accessor_holder: Accessor holder to applied the accessors on
@type accessor_holder: Products.ERP5Type.dynamic.accessor_holder.AccessorHolderType
@param portal: Portal object
@type portal: Products.ERP5.ERP5Site.ERP5Site
@type portal: Products.ERP5Type.ERP5Site.ERP5Site
@param do_register: Register the property in the Zope property map
@type do_register: bool
"""
......@@ -637,7 +637,7 @@ class StandardProperty(IdAsReferenceMixin('_property'), XMLObject):
@param expression_context: Expression context for TALES Expression
@type expression_context: Products.PageTemplates.Expressions.ZopeContext
@param portal: Portal object
@type portal: Products.ERP5.ERP5Site.ERP5Site
@type portal: Products.ERP5Type.ERP5Site.ERP5Site
@see applyDefinitionOnAccessorHolder
"""
......
......@@ -134,7 +134,7 @@ class Message(Persistent):
message = message.encode('utf-8')
message = Template(message).substitute(self.mapping)
else:
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
request = Globals.get_request()
translation_service = getGlobalTranslationService()
if self.mapping:
......
......@@ -80,7 +80,7 @@ class BaseTool (UniqueObject, Folder):
# Tools are causing problems: they used to have no type_class, or wrong
# type_class, or sometimes have no type definitions at all.
# Fix type definition if possible before any migration.
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
types_tool = getSite().portal_types
type_definition = getattr(types_tool, portal_type, None)
if type_definition is not None and \
......
......@@ -78,7 +78,7 @@ class PropertySheetTool(BaseTool):
def _bootstrap(self):
bt_name = 'erp5_property_sheets'
from Products.ERP5.ERP5Site import ERP5Generator
from Products.ERP5Type.ERP5Site import ERP5Generator
content_path_list = [
'BaseType',
'BusinessTemplate',
......@@ -103,7 +103,7 @@ class PropertySheetTool(BaseTool):
template_tool = portal.aq_base.__of__(portal.aq_parent.__of__(
RequestContainer(REQUEST=get_request()))).portal_templates
if template_tool.getInstalledBusinessTemplate(bt_name) is None:
from Products.ERP5.ERP5Site import getBootstrapBusinessTemplateUrl
from Products.ERP5Type.ERP5Site import getBootstrapBusinessTemplateUrl
url = getBootstrapBusinessTemplateUrl(bt_name)
template_tool.download(url).install()
transaction.get().addBeforeCommitHook(unrestricted_apply, (install,))
......
......@@ -123,7 +123,7 @@ class TypesTool(TypeProvider):
return False
def _bootstrap(self):
from Products.ERP5.ERP5Site import ERP5Generator
from Products.ERP5Type.ERP5Site import ERP5Generator
ERP5Generator.bootstrap(self, 'erp5_core', 'PortalTypeTemplateItem', (
'Business Template',
'Standard Property',
......@@ -158,7 +158,14 @@ class TypesTool(TypeProvider):
for provider in self.type_provider_list:
provider_value = _getOb(provider, None)
if provider_value is not None:
try:
type_info_list += listTypeInfo(provider_value, container=container)
except TypeError:
# DO NOT COMMIT: Products.ERP5.Tool.SolverTool, should be there
# after installing ERP5 products later or should it be moved to
# Products.ERP5Type?
pass
return type_info_list
def _aq_dynamic(self, id):
......
......@@ -101,7 +101,7 @@ def super_user():
uf = user.aq_inner.aq_parent
except AttributeError:
# XXX: local imports are bad, getSite should be moved to ERP5Type.
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
uf = getSite().acl_users
role_list = uf.valid_roles()
if anonymous:
......
......@@ -1097,7 +1097,7 @@ def registerDocumentClass(module_name, class_name):
LOG('Utils', WARNING,
"Ignoring replacement of %s by %s" % (old_value, new_value))
return
assert module_name == 'Products.ERP5.Tool.CategoryTool', module_name
assert module_name == 'Products.ERP5Type.Tool.CategoryTool', module_name
LOG('Utils', WARNING, "Replacing %s by %s" % (old_value, new_value))
else:
raise Exception("Class %s and %s from different products have the "
......
......@@ -90,14 +90,15 @@ def initialize( context ):
# Import Product Components
from Tool import (CacheTool, MemcachedTool, SessionTool,
TypesTool, WebServiceTool, PropertySheetTool,
ComponentTool)
ComponentTool, CategoryTool)
import Document
from Base import Base
import XMLObject
from ERP5Type import ERP5TypeInformation
import CodingStyle
# Define documents, classes, constructors and tools
object_classes = ()
import ERP5Site
object_classes = (ERP5Site.ERP5Site,)
content_constructors = ()
content_classes = ( Base,
XMLObject.XMLObject,
......@@ -108,7 +109,8 @@ def initialize( context ):
TypesTool.TypesTool,
WebServiceTool.WebServiceTool,
PropertySheetTool.PropertySheetTool,
ComponentTool.ComponentTool
ComponentTool.ComponentTool,
CategoryTool.CategoryTool
)
# Do initialization step
initializeProduct(context, this_module, globals(),
......
......@@ -34,7 +34,7 @@ import sys
import imp
import collections
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
from . import aq_method_lock
from types import ModuleType
from zLOG import LOG, BLATHER, WARNING
......
......@@ -343,7 +343,7 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
" class hierarchy")
portal_type = klass.__name__
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
site = getSite()
with aq_method_lock:
try:
......
......@@ -156,7 +156,7 @@ class PickleUpdater(ObjectReader, ObjectWriter, object):
if 1:
from Products.ERP5Type.Core.Folder import Folder
from Products.ERP5.Tool.CategoryTool import CategoryTool
from Products.ERP5Type.Tool.CategoryTool import CategoryTool
Base__setstate__ = Base.__setstate__
......
......@@ -10,3 +10,5 @@ from value_access_provider import IValueAccessProvider
from constraint import IConstraint
from role_provider import ILocalRoleAssignor, ILocalRoleGenerator
from types_tool import ITypesTool, ITypeProvider
from property_recordable import IPropertyRecordable
from predicate import IPredicate
......@@ -34,7 +34,7 @@ from __future__ import absolute_import
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
from Products.ERP5Type.Globals import InitializeClass
from Products.ERP5.mixin.property_recordable import PropertyRecordableMixin
from Products.ERP5Type.mixin.property_recordable import PropertyRecordableMixin
from Products.ERP5Type import Permissions
from Products.ERP5Type.Base import Base
from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter
......
......@@ -73,7 +73,7 @@ def manage_addToolForm(self, REQUEST):
""" Show the add tool form.
"""
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
import erp5.component.tool
seen_tool_component_set = set()
for tool_component in getSite().portal_components.objectValues(portal_type='Tool Component'):
......
......@@ -65,7 +65,7 @@ def formatLine(self, tb, *args, **kwargs):
f_globals = f.f_globals
line_str = HTMLExceptionFormatter_formatLine(self, tb, *args, **kwargs)
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
try:
portal_absolute_url = getSite().absolute_url()
......
......@@ -115,7 +115,7 @@ MANAGER.register_transform(nodes.Module,
lambda n: n.name == 'erp5')
def _buildAstroidModuleFromComponentModuleName(modname):
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
from Acquisition import aq_base
portal = getSite()
component_tool = aq_base(portal.portal_components)
......
......@@ -63,7 +63,7 @@ class CodingStyleTest(CodingStyleTestCase, testXHTML.TestXHTMLMixin):
"""
template_tool = self.portal.portal_templates
from Products.ERP5.ERP5Site import getBootstrapDirectory
from Products.ERP5Type.ERP5Site import getBootstrapDirectory
bt5_path_list = [os.environ.get('erp5_tests_bootstrap_path') or
getBootstrapDirectory()]
for path in os.environ['erp5_tests_bt5_path'].split(','):
......
......@@ -82,7 +82,7 @@ class ERP5TypeLiveTestCase(ERP5TypeTestCaseMixin):
if self.portal is not None:
return self.portal
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
site = getSite()
# reconstruct the acquistion chain with an independant request.
# RequestContainer -> Application -> Site
......
......@@ -1192,7 +1192,7 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
ZopeTestCase._print('Adding %s ERP5 Site ... ' % portal_name)
kw = self._getSiteCreationParameterDict()
factory = app.manage_addProduct['ERP5']
factory = app.manage_addProduct['ERP5Type']
factory.manage_addERP5Site(portal_name,
erp5_catalog_storage=erp5_catalog_storage,
light_install=light_install,
......@@ -1319,7 +1319,7 @@ class ERP5TypeTestCase(ERP5TypeCommandLineTestCase):
This TestCase setups an ERP5Site and installs business templates.
"""
from Products.ERP5 import ERP5Site
from Products.ERP5Type import ERP5Site
ERP5Site.getBootstrapBusinessTemplateUrl = lambda bt_title: \
ERP5TypeCommandLineTestCase._getBTPathAndIdList((bt_title,))[0][0]
......
......@@ -66,7 +66,7 @@ else:
# must be cleared of data from previous execution if any
_print("Catalog will be recreated to clear data (if any) from previous execution")
import Products.ZMySQLDA.db
from Products.ERP5.ERP5Site import default_sql_connection_string
from Products.ERP5Type.ERP5Site import default_sql_connection_string
sql_db = Products.ZMySQLDA.db.DB(os.environ.get('erp5_sql_connection_string',
default_sql_connection_string))
......
......@@ -406,7 +406,7 @@ class ERP5TypeTestLoader(unittest.TestLoader):
"""
template_tool = self.portal.portal_templates
from Products.ERP5.ERP5Site import getBootstrapDirectory
from Products.ERP5Type.ERP5Site import getBootstrapDirectory
bt5_path_list = [os.environ.get('erp5_tests_bootstrap_path') or
getBootstrapDirectory()]
for path in os.environ['erp5_tests_bt5_path'].split(','):
......
......@@ -1183,7 +1183,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
con = db.open(transaction_manager=tm)
app = con.root()['Application'].__of__(self.app.aq_parent)
portal = app[self.getPortalName()]
from Products.ERP5.ERP5Site import getSite, setSite
from Products.ERP5Type.ERP5Site import getSite, setSite
old_site = getSite()
setSite(portal)
......@@ -2885,7 +2885,7 @@ class Test(ERP5TypeTestCase):
"""
ret = ERP5TypeTestLoader_loadTestsFromNames(self, *args, **kwargs)
from Products.ERP5.ERP5Site import getSite
from Products.ERP5Type.ERP5Site import getSite
getSite().portal_components.reset(force=True)
# Simulate a new REQUEST while the old one has been GC'ed
......
......@@ -27,7 +27,7 @@
##############################################################################
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5.ERP5Site import ERP5Site
from Products.ERP5Type.ERP5Site import ERP5Site
from Products import ERP5Security
from Products.ERP5Type.Base import Base
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
......
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