Esempio n. 1
0
        class SchemaSource(SampleSource):
            provider(ISectionBlueprint)

            def __init__(self, transmogrifier, name, options, previous):
                super(
                    SchemaSource,
                    self).__init__(
                    transmogrifier,
                    name,
                    options,
                    previous)
                sourcecontent = options.get('source-content', 'full')
                if sourcecontent == 'full':
                    self.sample = (
                        dict(_path='/spam',
                             foo='one value',
                             _type='TransmogrifyDexterityFTI',
                             title='Spam',
                             description='Lorem Ipsum bla bla!',
                             test_file={
                                 'data': zptlogo,
                                 'filename': 'zptlogo.gif'},
                             test_date='2010-10-12',
                             test_datetime='2010-10-12 17:59:59',
                             fieldnotchanged='nochange',
                             ),
                        dict(_path='/two',
                             foo='Bla',
                             _type='TransmogrifyDexterityFTI',
                             title='My Second Object',
                             # description=None, # None is not valid for this
                             # field.
                             test_file=zptlogo,
                             _filename="testlogo.gif",
                             test_date=date(2010, 0o1, 0o1, ),
                             test_datetime=datetime(2010, 0o1, 0o1, 17, 59, 59),
                             fieldnotchanged='nochange',
                             ),
                    )
                elif sourcecontent == 'onlytitle':
                    self.sample = (
                        dict(_path='/spam',
                             _type='TransmogrifyDexterityFTI',
                             title='Spammety spam'),
                        dict(_path='/two',
                             _type='TransmogrifyDexterityFTI',
                             title='My Awesome Second Object'),
                    )
Esempio n. 2
0
def includeme(config):
    from zope.interface import Interface, provider
    class ILispyParserFactory(Interface):
        def __call__(*args, **kwargs):
            pass
    class ILispyParser(Interface):
        def __call__(data):
            pass

    def set_lispy_parser(config, *args, **kwargs):
        factory = config.registry.getUtility(ILispyParserFactory)
        parser = factory(*args, **kwargs)
        config.registry.registerUtility(provider(ILispyParser)(parser), ILispyParser)

    config.registry.registerUtility(provider(ILispyParserFactory)(create_handler), ILispyParserFactory)
    config.add_directive("set_lispy_parser", set_lispy_parser)
Esempio n. 3
0
def trivialInput(symbol):
    """
    Create a new L{IRichInput} implementation for the given input symbol.

    This creates a new type object and is intended to be used at module scope
    to define rich input types.  Generally, only one use per symbol should be
    required.  For example::

        Apple = trivialInput(Fruit.apple)

    @param symbol: A symbol from some state machine's input alphabet.

    @return: A new type object usable as a rich input for the given symbol.
    @rtype: L{type}
    """
    return provider(IRichInput)(type(
            symbol.name.title(), (FancyStrMixin, object), {
                "symbol": _symbol(symbol),
                }))
Esempio n. 4
0
def trivialInput(symbol):
    """
    Create a new L{IRichInput} implementation for the given input symbol.

    This creates a new type object and is intended to be used at module scope
    to define rich input types.  Generally, only one use per symbol should be
    required.  For example::

        Apple = trivialInput(Fruit.apple)

    @param symbol: A symbol from some state machine's input alphabet.

    @return: A new type object usable as a rich input for the given symbol.
    @rtype: L{type}
    """
    return provider(IRichInput)(type(symbol.name.title(),
                                     (FancyStrMixin, object), {
                                         "symbol": _symbol(symbol),
                                     }))
Esempio n. 5
0
    IVirtualAccess,
    ) 
from block.chain.monoid.mutable import Failure as MFailure
from block.chain.monoid.immutable import Failure as IMFailure
Failure = MFailure

### Wrapped value
@implementer(IFalsyValue)
class _Nothing(object):
    def __nonzero__(self):
        return False
    __bool__ = __nonzero__
Nothing = _Nothing()
### Access registration

IdentityAccess = provider(IVirtualAccess)(op)
 
@implementer(IVirtualAccess)
class BoundAccess(object):
    def __init__(self,o):
        self.o = o

    def attrgetter(self, k):
        return getattr(self.o, k)

    def itemgetter(self, k):
        return self.o[k]

    def methodcaller(self, k, *args, **kwargs):
        def wrapped(v):
            return getattr(self.o, k)(v, *args, **kwargs)
Esempio n. 6
0
def _add_bubbling_event(registry, SubjectClass, fn, name="", dynamic=True):
    iface = iface_from_class(SubjectClass, dynamic=dynamic, Exception=BubblingConfigurationError)
    if not isinstance(iface, (list, tuple)):
        iface = [iface]
    fn = provider(IEvent)(fn)
    registry.adapters.register(iface, IEvent, name, fn)
Esempio n. 7
0
def compute_value(fn):
    return provider(IComputeValue)(fn)
Esempio n. 8
0
class AtomServiceMime(AtomMime):
    provider(IAtomServiceMime)
    mime_type_string = 'application/atomsvc+xml'
Esempio n. 9
0
class AtomEntryMime(AtomMime):
    provider(IAtomEntryMime)
    mime_type_string = 'application/atom+xml;type=entry'
Esempio n. 10
0
class AtomFeedMime(AtomMime):
    provider(IAtomFeedMime)
    mime_type_string = 'application/atom+xml;type=feed'
Esempio n. 11
0
 def set_lispy_parser(config, *args, **kwargs):
     factory = config.registry.getUtility(ILispyParserFactory)
     parser = factory(*args, **kwargs)
     config.registry.registerUtility(provider(ILispyParser)(parser), ILispyParser)
Esempio n. 12
0
def compute_value(fn):
    return provider(IComputeValue)(fn)