def loadSchema(file, registry=Registry(), overwrite=False):
    """Loads a schema file
    
    * file
      A path to a file
    * registry
      A ZConfig datatypes registry instance
    * overwrite
      Overwriting the existing global schema is not possible unless overwrite
      is set to true. Useful only for unit testing.
    """
    global coreblog2Schema
    if coreblog2Schema is not None and not overwrite:
        raise RuntimeError, 'Schema is already loaded'
    schemaLoader = SchemaLoader(registry=registry)
    coreblog2Schema = schemaLoader.loadURL(file)
    return coreblog2Schema
Exemple #2
0
import os

from ZConfig.datatypes import Registry
from ZConfig.loader import SchemaLoader
from Products.ATContentTypes.configuration import datatype

# schema file
DIR = os.path.dirname(os.path.abspath(__file__))
SCHEMA_FILE_NAME = 'schema.xml'
SCHEMA_FILE = os.path.join(DIR, SCHEMA_FILE_NAME)

# registry
# ATCT is using its own datatypes registry to add additional
# handlers.
atctRegistry = Registry()
atctRegistry.register('permission', datatype.permission_handler)
atctRegistry.register('identifer_none', datatype.identifier_none)
atctRegistry.register('byte-size-in-mb', datatype.byte_size_in_mb)
atctRegistry.register('image-dimension', datatype.image_dimension)
atctRegistry.register('image-dimension-or-no', datatype.image_dimension_or_no)
atctRegistry.register('pil-algo', datatype.pil_algo)

# schema
atctSchema = None
def loadSchema(file, registry=atctRegistry, overwrite=False):
    """Loads a schema file
    
    * file
      A path to a file
    * registry
      A ZConfig datatypes registry instance
import os

from ZConfig.datatypes import Registry
from ZConfig.loader import SchemaLoader
from Products.ATContentTypes.configuration import datatype

# schema file
DIR = os.path.dirname(os.path.abspath(__file__))
SCHEMA_FILE_NAME = 'schema.xml'
SCHEMA_FILE = os.path.join(DIR, SCHEMA_FILE_NAME)

# registry
# ATCT is using its own datatypes registry to add additional
# handlers.
atctRegistry = Registry()
atctRegistry.register('permission', datatype.permission_handler)
atctRegistry.register('identifer_none', datatype.identifier_none)
atctRegistry.register('byte-size-in-mb', datatype.byte_size_in_mb)
atctRegistry.register('image-dimension', datatype.image_dimension)
atctRegistry.register('image-dimension-or-no', datatype.image_dimension_or_no)
atctRegistry.register('pil-algo', datatype.pil_algo)

# schema
atctSchema = None


def loadSchema(file, registry=atctRegistry, overwrite=False):
    """Loads a schema file
    
    * file
      A path to a file
Exemple #4
0
__author__  = 'Gilles Lenfant <*****@*****.**>'
__docformat__ = 'restructuredtext'

import os

from ZConfig.datatypes import Registry
from ZConfig.loader import SchemaLoader

import datatypes

_this_dir = os.path.dirname(os.path.abspath(__file__))
SCHEMA_FILE = os.path.join(_this_dir, "schema.xml")

# Our registry
fssRegistry = Registry(stock=None)
fssRegistry.register('existing-storage-path', datatypes.existingStoragePath)
fssRegistry.register('existing-backup-path', datatypes.existingBackupPath)
fssRegistry.register('strategy', datatypes.strategy)

# Our configuration schema
fssSchema = None
def loadSchema(filepath, registry=fssRegistry, overwrite=False):
    """Sets up fssSchema
    @param filepath: path to schema xml file
    @param registry: ZConfig.datatypes.Registry
    @param overwrite: True to change fss
    """

    global fssSchema
    if fssSchema is not None and not overwrite: