"""


def plugin_builder(plugin_name, plugin_code):
    if plugin_name == '__init__':
        return
    try:
        all_widgets = getattr(plugin_code, '__all__')
        for name in all_widgets:
            candidate = getattr(plugin_code, name)
            if issubclass(candidate, Form):
                return candidate
    except AttributeError:
        pass


CFG_WIDGETS = PluginContainer(os.path.join(CFG_PYLIBDIR, 'invenio',
                                           'bibworkflow_widgets',
                                           '*_widget.py'),
                              plugin_builder=plugin_builder)

widgets = {}
for widget in CFG_WIDGETS.itervalues():
    widgets[widget.__name__] = widget

# ## Let's report about broken plugins
# open(os.path.join(CFG_LOGDIR, 'broken-deposition-fields.log'), 'w').write(
#     pformat(CFG_FIELDS.get_broken_plugins()))

__all__ = ['widgets']
Beispiel #2
0
    try:
        all = getattr(plugin_code, '__all__')
        for name in all:
            candidate = getattr(plugin_code, name)
            if issubclass(candidate, Field):
                return candidate
    except AttributeError:
        pass

CFG_FIELDS = PluginContainer(os.path.join(CFG_PYLIBDIR, 'invenio',
                                          'webdeposit_deposition_fields',
                                          '*_field.py'),
                             plugin_builder=plugin_builder)


class Fields(object):
    pass

fields = Fields()

for field in CFG_FIELDS.itervalues():
    ## Change the names of the fields from the file names to the class names.
    if field is not None:
        fields.__setattr__(field.__name__, field)

## Let's report about broken plugins
open(os.path.join(CFG_LOGDIR, 'broken-deposition-fields.log'), 'w').write(
    pformat(CFG_FIELDS.get_broken_plugins()))

__all__ = ['fields']
    dep_type = "My Deposition"

    # Define the name in plural
    plural = "My depositions"

    # Define in which deposition group it will belong
    group = "My Depositions Group"

    # Enable the deposition
    enabled = True
"""

deposition_metadata = {}
deposition_types = {}

for dep in CFG_DOC_METADATA.itervalues():
    if dep.enabled:
        if dep is not None:
            deposition_metadata[dep.dep_type] = dict()
            deposition_metadata[dep.dep_type]["workflow"] = dep.workflow
            deposition_metadata[dep.dep_type]["workflow_name"] = dep.__name__
            if hasattr(dep, 'collection'):
                deposition_metadata[
                    dep.dep_type]["collection"] = dep.collection

        if dep.group not in deposition_types:
            deposition_types[dep.group] = []
        if dep.enabled:
            deposition_types[dep.group].append({
                "name": dep.plural,
                "dep_type": dep.dep_type
Beispiel #4
0
    return candidates


CFG_FIELDS = PluginContainer(os.path.join(CFG_PYLIBDIR, 'invenio',
                                          'webdeposit_deposition_fields',
                                          '*_field.py'),
                             plugin_builder=plugin_builder)


class Fields(object):
    pass


fields = Fields()

for field_list in CFG_FIELDS.itervalues():
    for field in field_list:
        ## Change the names of the fields from the file names to the class names.
        if field is not None:
            setattr(fields, field.__name__, field)


#
# Customize some WTForms fields
#
# Note: Because DynamicFieldList extends fields.FieldList it cannot be
# located in a plugin file.
class DynamicFieldList(fields.FieldList):
    """
    Encapsulate an ordered list of multiple instances of the same field type,
    keeping data as a list.