コード例 #1
0
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)
コード例 #2
0
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
    )
コード例 #3
0
ファイル: admin.py プロジェクト: BenoitTalbot/bungeni-portal
def generate_doc_for(domain_class, title=None, color=0):
    doc = etree.fromstring(SIMPLE_LIST)
    _color = COLOURS[color]
    if color:
        doc.attrib["style"] = "background-color:#%s;" % _color
    if title:
        add_sub_element(doc, "li", title)
    
    proxy_dict = domain_class.__dict__
    class_dict = {}
    class_dict.update(proxy_dict)
    if domain_class is domain.GroupSitting:
        class_dict.update(GROUP_SITTING_EXTRAS)
    sort_key = lambda kv: str(IManagedContainer.providedBy(kv[1]) or kv[0] in GROUP_SITTING_EXTRAS.keys()) + "-" + kv[0]
    class_keys = sorted([ kv for kv in class_dict.iteritems() ],
        key = sort_key
    )
    for (key, value) in class_keys:
        if (not key.startswith("_")) and (not hasattr(value, "__call__")):
            elx = add_sub_element(doc, "li")
            if (key in GROUP_SITTING_EXTRAS.keys() or
                IManagedContainer.providedBy(value)
            ):
                _title = "%s (list)" % key
                color = (color + 1) % COLOUR_COUNT
                next_color = COLOURS[color]
                elx.attrib["style"] = "border-left:1px solid #%s;" % next_color
                add_sub_element(elx, "span", _title, 
                    style=X_TITLE % next_color
                )
                if key in GROUP_SITTING_EXTRAS.keys():
                    container_name = value
                else:
                    container_name = value.container
                cls_name = container_name.split(".").pop().replace("Container", 
                    ""
                )
                the_model = getattr(domain, cls_name)
                elx.append(generate_doc_for(the_model, title, color))
                continue
            elx.text = key
    return doc
コード例 #4
0
ファイル: admin.py プロジェクト: mohalfaki/bungeni-portal
def generate_doc_for(domain_class, title=None, color=0):
    doc = etree.fromstring(SIMPLE_LIST)
    _color = COLOURS[color]
    if color:
        doc.attrib["style"] = "background-color:#%s;" % _color
    if title:
        add_sub_element(doc, "li", title)

    proxy_dict = domain_class.__dict__
    class_dict = {}
    class_dict.update(proxy_dict)
    if domain_class is domain.GroupSitting:
        class_dict.update(GROUP_SITTING_EXTRAS)
    sort_key = lambda kv: str(
        IManagedContainer.providedBy(kv[1]) or kv[0] in GROUP_SITTING_EXTRAS.
        keys()) + "-" + kv[0]
    class_keys = sorted([kv for kv in class_dict.iteritems()], key=sort_key)
    for (key, value) in class_keys:
        if (not key.startswith("_")) and (not hasattr(value, "__call__")):
            elx = add_sub_element(doc, "li")
            if (key in GROUP_SITTING_EXTRAS.keys()
                    or IManagedContainer.providedBy(value)):
                _title = "%s (list)" % key
                color = (color + 1) % COLOUR_COUNT
                next_color = COLOURS[color]
                elx.attrib["style"] = "border-left:1px solid #%s;" % next_color
                add_sub_element(elx,
                                "span",
                                _title,
                                style=X_TITLE % next_color)
                if key in GROUP_SITTING_EXTRAS.keys():
                    container_name = value
                else:
                    container_name = value.container
                cls_name = container_name.split(".").pop().replace(
                    "Container", "")
                the_model = getattr(domain, cls_name)
                elx.append(generate_doc_for(the_model, title, color))
                continue
            elx.text = key
    return doc
コード例 #5
0
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

    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)
コード例 #6
0
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
    
    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
    )
コード例 #7
0
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

    traverser = CollectionTraverser( *collection_names )
    
    # register collection traversal subscription adapter
    subscriber( ctx.zcml, 
                for_=(ctx.domain_interface, IPublisherRequest ),
                factory=traverser,
                provides=ITraverserPlugin
                )
    
    adapter( ctx.zcml,
             for_ = ( ctx.domain_interface, IPublisherRequest ),
             factory = (PluggableTraverser,),
             provides = IPublishTraverse )