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())
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())
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()) )
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
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)
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 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
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 []
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 []
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
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)
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 get_factory(target): return getComponent((target, ), IGhostManager, default=CopyManager)
def get_factory(target): return getComponent((target,), IGhostManager, default=CopyManager)
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