def GenerateCollectionTraversal(ctx): collection_names = [] for k, v in ctx.domain_model.__dict__.items(): if IManagedContainer.providedBy(v): collection_names.append(k) if not collection_names: return # Note: the templated CollectionTraverser TYPE returned by this is # instantiated multiple times in case of inheritance of catalyzed # descriptors e.g. for Motion, it is instantiated once for # ParliamentaryItemDescriptor and once for MotionDescriptor. traverser = CollectionTraverser(*collection_names) # provideSubscriptionAdapter(factory, adapts=None, provides=None) component.provideSubscriptionAdapter(traverser, adapts=(ctx.domain_interface, IPublisherRequest), provides=ITraverserPlugin) # provideAdapter(factory, adapts=None, provides=None, name="") component.provideAdapter(PluggableTraverser, adapts=(ctx.domain_interface, IPublisherRequest), provides=IPublishTraverse )
def GenerateCollectionTraversal(ctx): collection_names = [] for k, v in ctx.domain_model.__dict__.items(): if IManagedContainer.providedBy(v): collection_names.append(k) if not collection_names: return # Note: the templated CollectionTraverser TYPE returned by this is # instantiated multiple times in case of inheritance of catalyzed # descriptors e.g. for Motion, it is instantiated once for # ParliamentaryItemDescriptor and once for MotionDescriptor. traverser = CollectionTraverser(*collection_names) # provideSubscriptionAdapter(factory, adapts=None, provides=None) component.provideSubscriptionAdapter(traverser, adapts=(ctx.domain_interface, IPublisherRequest), provides=ITraverserPlugin) # provideAdapter(factory, adapts=None, provides=None, name="") component.provideAdapter(PluggableTraverser, adapts=(ctx.domain_interface, IPublisherRequest), provides=IPublishTraverse)
def get_managed_containers(context): """Get the managed container instances off context. """ attrs = [] kls = context.__class__ seen = [] for class_item in inspect.getmro(kls): for key, value in class_item.__dict__.items(): if IManagedContainer.providedBy(value): if key not in seen: try: attrs.append((key, getattr(context, key))) except AttributeError: attrs.append((key, FILES_VERSION_CONTAINER_ATTRIBUTE_ERROR_HACK(context, key))) seen.append(key) return attrs
def get_collection_names(domain_model): return [ k for k, v in domain_model.__dict__.items() if IManagedContainer.providedBy(v) ]