def forget(self, schema): name = str(schema) if IInterface.providedBy(schema): name = identify_interface(schema) if name not in self._names: return self._names.remove(name)
def bind(self, schema): if not IInterface.providedBy(schema): raise TypeError("Cannot bind non-interface object %s" % schema) name = identify_interface(schema) if name in self._names: raise KeyError("duplicate schema: Interface %s already managed." % (name,)) self._names.append(name)
def bind(self, schema): if not IInterface.providedBy(schema): raise TypeError('Cannot bind non-interface object %s' % schema) name = identify_interface(schema) if name in self._names: raise KeyError( 'duplicate schema: Interface %s already managed.' % (name,)) self._names.append(name)
def test_dynamic_schema_identification(self): from hashlib import md5 from plone.supermodel import serializeSchema iface = ITestSchema2 oldname = iface.__name__ iface.__name__ = '' assert iface.__module__ == 'uu.retrieval.tests.test_schema' expected_signature = md5(serializeSchema(iface).strip()).hexdigest() expected_name = 'I%s' % expected_signature expected_identifier = '.'.join((iface.__module__, expected_name)) assert identify_interface(ITestSchema2) == expected_identifier iface.__name__ = oldname # clean up
def test_dynamic_schema_identification(self): from hashlib import md5 from plone.supermodel import serializeSchema iface = ITestSchema2 oldname = iface.__name__ iface.__name__ = "" assert iface.__module__ == "uu.retrieval.tests.test_schema" expected_signature = md5(serializeSchema(iface).strip()).hexdigest() expected_name = "I%s" % expected_signature expected_identifier = ".".join((iface.__module__, expected_name)) assert identify_interface(ITestSchema2) == expected_identifier iface.__name__ = oldname # clean up
def __contains__(self, name): if IInterface.providedBy(name): name = identify_interface(name) name = str(name) return name in self._names
def bind(self, schema): if hasattr(self, '_v_schema'): delattr(self, '_v_schema') self._schema = identify_interface(schema) self.make_indexes()
def test_schema_identification(self): name = identify_interface(ITestSchema) assert name == ITestSchema.__identifier__
from zope.schema import getFieldNamesInOrder, ValidationError from zope.schema import interfaces as fieldtypes from uu.retrieval.utils import identify_interface from uu.formlibrary.measure.interfaces import IMeasureDefinition from uu.formlibrary.search.interfaces import COMPARATORS from uu.formlibrary.search.interfaces import IFieldQuery from uu.formlibrary.search.interfaces import IJSONFilterRepresentation from uu.formlibrary.search.interfaces import IRecordFilter, IFilterGroup from uu.formlibrary.search.interfaces import IComposedQuery from uu.formlibrary.utils import normalize_usa_date # field serialization, used by FieldQuery: field_id = lambda f: (identify_interface(f.interface), f.__name__) resolvefield = lambda t: resolve(t[0])[t[1]] # (name, fieldname) -> schema # comparator class resolution from identifier: comparator_cls = lambda v: getattr(query, v) if v in COMPARATORS else None # get index type from FieldQuery def query_idxtype(fieldquery, schema): """Get index type for specific comparator, field combination""" comparator, fieldname = fieldquery.comparator, fieldquery.fieldname field = schema[fieldname] # for text, whether to use text index or field index depends on the # comparator saved on the query: line_types = (fieldtypes.ITextLine, fieldtypes.IBytesLine)
from zope.interface.interfaces import IInterface from zope.schema import getFieldNamesInOrder, ValidationError from zope.schema import interfaces as fieldtypes from uu.retrieval.utils import identify_interface from uu.formlibrary.measure.interfaces import IMeasureDefinition from uu.formlibrary.search.interfaces import COMPARATORS from uu.formlibrary.search.interfaces import IFieldQuery from uu.formlibrary.search.interfaces import IJSONFilterRepresentation from uu.formlibrary.search.interfaces import IRecordFilter, IFilterGroup from uu.formlibrary.search.interfaces import IComposedQuery from uu.formlibrary.utils import normalize_usa_date # field serialization, used by FieldQuery: field_id = lambda f: (identify_interface(f.interface), f.__name__) resolvefield = lambda t: resolve(t[0])[t[1]] # (name, fieldname) -> schema # comparator class resolution from identifier: comparator_cls = lambda v: getattr(query, v) if v in COMPARATORS else None # get index type from FieldQuery def query_idxtype(fieldquery, schema): """Get index type for specific comparator, field combination""" comparator, fieldname = fieldquery.comparator, fieldquery.fieldname field = schema[fieldname] # for text, whether to use text index or field index depends on the # comparator saved on the query: line_types = (fieldtypes.ITextLine, fieldtypes.IBytesLine)