Esempio n. 1
0
 def get_link_status(self):
     """Return an error code if this version of the ghost is broken.
     returning None means the ghost is Ok.
     """
     ghost = self.get_silva_object()
     get_manager = getComponent((ghost,), IGhostManager)
     return get_manager(ghost=ghost).validate(self.get_haunted())
Esempio n. 2
0
 def get_link_status(self):
     """Return an error code if this version of the ghost is broken.
     returning None means the ghost is Ok.
     """
     ghost = self.get_silva_object()
     get_manager = getComponent((ghost, ), IGhostManager)
     return get_manager(ghost=ghost).validate(self.get_haunted())
Esempio n. 3
0
 def _get(self, identifier, cache, iface):
     field = self.form.fields[identifier]
     factory = cache.get(identifier, _marker)
     if factory is _marker:
         factory = component.getComponent(
             (self.form.fields[identifier], self.form), provided=iface)
         cache[identifier] = factory
     return factory(identifier, field, self.content, self.form)
 def resolveInterface(self, name):
     """Resolve an interface listed by availablesInterfaces.
     """
     interface = getComponent(
         (self.context,),
         provided=ICustomizableType, name=name, default=None)
     if interface is None:
         return getUtility(ICustomizableType, name=name)
     return interface
 def truncate(self, name, text):
     manager = getComponent(self.context, IExternalSourceManager)(self.context)
     for identifier in manager.all():
         try:
             source = manager(self.request, instance=identifier)
             source.remove()
         except SourceError:
             logger.error(
                 "Error while removing source %s from text %s", identifier, "/".join(self.context.getPhysicalPath())
             )
Esempio n. 6
0
 def truncate(self, name, text):
     manager = getComponent(self.context,
                            IExternalSourceManager)(self.context)
     for identifier in manager.all():
         try:
             source = manager(self.request, instance=identifier)
             source.remove()
         except SourceError:
             logger.error('Error while removing source %s from text %s',
                          identifier,
                          '/'.join(self.context.getPhysicalPath()))
 def get_source(self):
     """Return the External Source and form associated with the
     given request.
     """
     document = self.get_document()
     source = getComponent(document, IExternalSourceManager)(document)(
         self.request,
         instance=self.request.get('source_instance'),
         name=self.request.get('source_name'))
     source.ignoreContent = 'source_name' in self.request.form
     source.ignoreRequest = 'source_inline' not in self.request.form
     return source
Esempio n. 8
0
def get_ghost_factory(container, target):
    """add new ghost to container
    """
    if target is None:
        return None

    get_manager = getComponent((target,), IGhostManager, default=None)
    if get_manager is None:
        return None

    return lambda identifier: get_manager(
        container=container).modify(target, identifier).create(recursive=True)
Esempio n. 9
0
 def getSerializers(self):
     form = self.form
     assert form.getContent() is not None
     content = form.getContentData()
     for field in form.fields:
         try:
             value = content.get(field.identifier)
         except KeyError:
             continue
         factory = component.getComponent(
             (field, form), IXMLFieldSerializer)
         yield factory(field, form, value)
 def get_source(self):
     """Return the External Source and form associated with the
     given request.
     """
     document = self.get_document()
     source = getComponent(document, IExternalSourceManager)(document)(
         self.request,
         instance=self.request.get('source_instance'),
         name=self.request.get('source_name'))
     source.ignoreContent = 'source_name' in self.request.form
     source.ignoreRequest = 'source_inline' not in self.request.form
     return source
Esempio n. 11
0
def queryRESTComponent(specs, args, name=u'', parent=None, id=_marker):
    """Query the ZCA for a REST component.
    """
    factory = getComponent(specs, IRESTComponent, name, default=None)
    if factory is not None:
        result = factory(*args)
        if result is not None and IRESTComponent.providedBy(result):
            # Set parenting information / for security
            if id is _marker:
                id = name
            result.__name__ = id
            result.__parent__ = parent
            return result
    return None
Esempio n. 12
0
 def validate(self, data):
     """Validate ghost target before setting it.
     """
     # This is not beauty, but it works.
     content_id = data.get(field_name)
     if content_id is silvaforms.NO_VALUE:
         # If there value is required it is already checked
         return []
     getManager = getComponent((wanted, ), IGhostManager)
     if adding:
         manager = getManager(container=self.form.context)
     else:
         manager = getManager(ghost=self.form.context)
     error = manager.validate(get_content_from_id(content_id), adding)
     if error is not None:
         identifier = widgetId(self.form, self.fields[field_name])
         return [Error(error.doc(), identifier)]
     return []
Esempio n. 13
0
 def validate(self, data):
     """Validate ghost target before setting it.
     """
     # This is not beauty, but it works.
     content_id = data.get(field_name)
     if content_id is silvaforms.NO_VALUE:
         # If there value is required it is already checked
         return []
     getManager = getComponent((wanted,), IGhostManager)
     if adding:
         manager = getManager(container=self.form.context)
     else:
         manager = getManager(ghost=self.form.context)
     error = manager.validate(get_content_from_id(content_id), adding)
     if error is not None:
         identifier = widgetId(self.form, self.fields[field_name])
         return [Error(error.doc(), identifier)]
     return []
Esempio n. 14
0
def queryRESTComponent(specs, args, name=u'', parent=None, id=_marker, placeholder=None):
    """Query the ZCA for a REST component.
    """
    factory = getComponent(specs, IRESTComponent, name, default=None)
    if factory is not None:
        result = factory(*args)
        if result is not None and IRESTComponent.providedBy(result):
            # Set parenting information / for security
            if id is _marker:
                id = name
            result.__name__ = id
            result.__parent__ = parent
            result.__matchdict__ = {}
            result.__matchdict__.update(getattr(parent, '__matchdict__', {}))
            if placeholder is not None:
                result.__matchdict__.update(placeholder)

            return result
    return None
Esempio n. 15
0
def queryRESTComponent(specs,
                       args,
                       name=u'',
                       parent=None,
                       id=_marker,
                       placeholder=None):
    """Query the ZCA for a REST component.
    """
    factory = getComponent(specs, IRESTComponent, name, default=None)
    if factory is not None:
        result = factory(*args)
        if result is not None and IRESTComponent.providedBy(result):
            # Set parenting information / for security
            if id is _marker:
                id = name
            result.__name__ = id
            result.__parent__ = parent
            result.__matchdict__ = {}
            result.__matchdict__.update(getattr(parent, '__matchdict__', {}))
            if placeholder is not None:
                result.__matchdict__.update(placeholder)

            return result
    return None
Esempio n. 16
0
 def prepare(self, name, text):
     self.sources = getComponent(self.context,
                                 IExternalSourceManager)(self.context)
def get_block_configuration(factory, context):
    component = getComponent((implementedBy(factory), context), IBlockConfigurations)
    return component(factory, context)
Esempio n. 18
0
 def _getManager(self):
     return getComponent((interfaces.IGhostAsset,), interfaces.IGhostManager)
Esempio n. 19
0
 def _getManager(self):
     return getComponent((interfaces.IGhostAsset,), interfaces.IGhostManager)
 def prepare(self, name, text):
     self.manager = getComponent(self.context, IExternalSourceManager)(self.context)
     self.seen = set()
 def prepare(self, name, text):
     self.sources = getComponent(self.context, IExternalSourceManager)(self.context)
Esempio n. 22
0
def get_factory(target):
    return getComponent((target, ), IGhostManager, default=CopyManager)
Esempio n. 23
0
def get_factory(target):
    return getComponent((target,), IGhostManager, default=CopyManager)
Esempio n. 24
0
 def _fetchMarker(self, name):
     interface = getComponent((self.context,), provided=ICustomizableType, name=name, default=None)
     if interface is None:
         return getUtility(ICustomizableType, name=name)
     return interface
Esempio n. 25
0
 def prepare(self, name, text):
     self.manager = getComponent(self.context,
                                 IExternalSourceManager)(self.context)
     self.seen = set()