コード例 #1
0
ファイル: interfaces.py プロジェクト: py361/zc.catalog
class ISelfPopulatingExtent(IExtent):
    """An extent that knows how to create it's own initial population."""

    populated = schema.Bool(
        title=_("Populated"),
        description=_(
            "Flag indicating whether self-population has been performed."),
        readonly=True,
    )

    def populate():
        """Populate the extent based on the current content of the database.
コード例 #2
0
ファイル: index.py プロジェクト: Zojax/zojax.catalog
    def value(self, value):
        if not isinstance(value, datetime.datetime):
            raise ValueError(
                _('This index only indexes timezone-aware datetimes.'))

        if value.tzinfo is None:
            value = datetime.datetime(
                value.year, value.month, value.day, value.hour,
                value.minute, value.second, value.microsecond, pytz.utc)

        value = value.astimezone(pytz.utc)
        return super(DateTimeNormalizer, self).value(value)
コード例 #3
0
    def all(value, index):
        """Normalize a query value for an "all_of" search; return the value
        for query"""

    def minimum(value, index, exclude=False):
        """normalize a query value for minimum of a range; return the value for
        query"""

    def maximum(value, index, exclude=False):
        """normalize a query value for maximum of a range; return the value for
        query"""


resolution_vocabulary = SimpleVocabulary(
    [SimpleTerm(i, t, t) for i, t in enumerate(
        (_('day'), _('hour'), _('minute'), _('second'), _('microsecond')))])
#          0         1          2            3            4


class IDateTimeNormalizer(INormalizer):
    resolution = schema.Choice(
        vocabulary=resolution_vocabulary,
        title=_('Resolution'),
        default=2,
        required=True)


class ICallableWrapper(zope.index.interfaces.IInjection,
                       zope.index.interfaces.IIndexSearch,
                       zope.index.interfaces.IStatistics,
                       IIndexValues):
コード例 #4
0
ファイル: index.py プロジェクト: grodniewicz/oship
 def value(self, value):
     if not isinstance(value, datetime.datetime) or value.tzinfo is None:
         raise ValueError(
             _('This index only indexes timezone-aware datetimes.'))
     return set_resolution(value, self.resolution)
コード例 #5
0
ファイル: interfaces.py プロジェクト: py361/zc.catalog
class IDateTimeNormalizer(INormalizer):
    resolution = schema.Choice(vocabulary=resolution_vocabulary,
                               title=_('Resolution'),
                               default=2,
                               required=True)
コード例 #6
0
ファイル: interfaces.py プロジェクト: py361/zc.catalog
    def all(value, index):
        """Normalize a query value for an "all_of" search; return the value
        for query"""

    def minimum(value, index, exclude=False):
        """normalize a query value for minimum of a range; return the value for
        query"""

    def maximum(value, index, exclude=False):
        """normalize a query value for maximum of a range; return the value for
        query"""


resolution_vocabulary = SimpleVocabulary([
    SimpleTerm(i, t, t)
    for i, t in enumerate((_('day'), _('hour'), _('minute'), _('second'),
                           _('microsecond')))
])
#  0         1          2            3            4


class IDateTimeNormalizer(INormalizer):
    resolution = schema.Choice(vocabulary=resolution_vocabulary,
                               title=_('Resolution'),
                               default=2,
                               required=True)


class ICallableWrapper(zope.index.interfaces.IInjection,
                       zope.index.interfaces.IIndexSearch,
                       zope.index.interfaces.IStatistics, IIndexValues):
コード例 #7
0
 def value(self, value):
     if not isinstance(value, datetime.datetime) or value.tzinfo is None:
         raise ValueError(
             _('This index only indexes timezone-aware datetimes.'))
     return set_resolution(value, self.resolution)