How to use the schema.schema.getMetaType function in schema

To help you get started, we’ve selected a few schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mediatum / mediatum / web / edit / modules / subfolder.py View on Github external
sorted_children.reverse()
        for position, child in enumerate(sorted_children, start=1):
            child.orderpos = position
        db.session.commit()
        req.writeTAL('web/edit/modules/subfolder.html', {'nodelist': sorted_children, "language": language, "csrf": req.csrf_token.current_token}, macro="ordered_list")
        return ""

    nodelist = []
    attributes = []
    fields = {}
    i = 0
    for child in list(node.container_children.sort_by_orderpos()):
        i += 1  # count container children
        nodelist.append(child)
        if getMetaType(child.schema):
            for field in getMetaType(child.schema).getMetaFields():
                if not field in fields.keys():
                    fields[field] = 0
                fields[field] += 1

    for field in fields:
        if i == fields[field]:
            attributes.append(field)
    ctx = {
            "node": node,
            "nodelist": nodelist,
            "sortattributes": sorted(attributes, lambda x, y: cmp(x.getLabel().lower(), y.getLabel().lower())),
            "language": language,
            "csrf": req.csrf_token.current_token
           }
    return req.getTAL("web/edit/modules/subfolder.html", ctx, macro="edit_subfolder")
github mediatum / mediatum / web / edit / edit_search.py View on Github external
user = users.getUserFromRequest(req)
    if "search" in users.getHideMenusForUser(user):
        req.writeTAL("web/edit/edit.html", {}, macro="access_error")
        return

    if "Reset" in req.params:
        return search_form(req, id, "edit_search_reset_msg")
    
    try:
        searchvalues = req.session["esearchvals"]
    except:
        req.session["esearchvals"] = searchvalues = {}

    node = tree.getNode(id)
    objtype = req.params["objtype"]
    type = getMetaType(objtype)
    
    query = ""

    if "full" in req.params:
        value = req.params["full"]
        searchvalues[objtype + ".full"] = value
        for word in value.split(" "):
            if word:
                if query:
                    query += " and "
                query += "full=" + protect(word)
 
    for field in type.getMetaFields():
        if field.Searchfield():
            name=field.getName()
            if name in req.params and req.params.get(name,"").replace("'",'').replace('"','').strip()!="":
github mediatum / mediatum / web / edit / modules / subfolder.py View on Github external
if req.params.get("sortdirection", "up") != "up":
            sorted_children.reverse()
        for position, child in enumerate(sorted_children, start=1):
            child.orderpos = position
        db.session.commit()
        req.writeTAL('web/edit/modules/subfolder.html', {'nodelist': sorted_children, "language": language, "csrf": req.csrf_token.current_token}, macro="ordered_list")
        return ""

    nodelist = []
    attributes = []
    fields = {}
    i = 0
    for child in list(node.container_children.sort_by_orderpos()):
        i += 1  # count container children
        nodelist.append(child)
        if getMetaType(child.schema):
            for field in getMetaType(child.schema).getMetaFields():
                if not field in fields.keys():
                    fields[field] = 0
                fields[field] += 1

    for field in fields:
        if i == fields[field]:
            attributes.append(field)
    ctx = {
            "node": node,
            "nodelist": nodelist,
            "sortattributes": sorted(attributes, lambda x, y: cmp(x.getLabel().lower(), y.getLabel().lower())),
            "language": language,
            "csrf": req.csrf_token.current_token
           }
    return req.getTAL("web/edit/modules/subfolder.html", ctx, macro="edit_subfolder")
github mediatum / mediatum / web / admin / modules / metatype.py View on Github external
def showFieldOverview(req):
    path = req.path[1:].split("/")
    fields = getFieldsForMeta(path[1])
    fields.sort(lambda x, y: cmp(x.orderpos, y.orderpos))

    v = {}
    v["metadatatype"] = getMetaType(path[1])
    v["metafields"] = fields
    v["fieldoptions"] = fieldoption
    v["fieldtypes"] = getMetaFieldTypeNames()
    v["csrf"] = req.csrf_token.current_token
    return req.getTAL("web/admin/modules/metatype.html", v, macro="show_fieldoverview")
github mediatum / mediatum / core / tree_db.py View on Github external
def getDescription(self):
        if self.metadatatypename:
            mtype = schema.getMetaType(self.metadatatypename)
            if mtype:
                return mtype.getDescription()
            else:
                return ""
github mediatum / mediatum / core / tree_db.py View on Github external
def getMetaFields(self,type=None):
        try:
            return self.metaFields()
        except:
            pass

        try:
            if self.metadatatypename:
                return schema.getMetaType(self.metadatatypename).getMetaFields(type)
            else:
                return []
        except AttributeError:
            return []
github mediatum / mediatum / utils / doi.py View on Github external
    @param node
    Creates and returns the path to the 'metadata file' needed to register the doi with datacite via api
    """
    if 'doi' not in node.attributes:
        raise Exception('doi not set')
    else:
        tmp = config.get('paths.tempdir')
        filename = 'meta_file_%s.txt' % node.get('node.id')
        path = os.path.join(tmp, filename)

        if os.path.exists(path):
            pass
        else:
            try:
                with open(path, 'w') as f:
                    mask = getMetaType(node.getSchema()).getMask('doi')
                    xml = mask.getViewHTML([node], flags=8)
                    f.write(xml)
            except AttributeError:
                logging.getLogger('backend').error(
                    'Doi was not successfully registered: Doi-mask for Schema %s is missing and should be created' % node.getSchema())
                node.removeAttribute('doi')
            except IOError:
                logging.getLogger('errors').error('Error creating %s' % path)

        return path
github mediatum / mediatum / web / admin / modules / metatype_mask.py View on Github external
def showMaskList(req, id):
    metadatatype = getMetaType(id)
    masks = metadatatype.getMasks()
    order = getSortCol(req)
    actfilter = getFilter(req)

    # resets filter to all if adding mask in /metatype view
    # if req.params.get('acttype') == 'mask' or req.params.get('acttype') == 'schema':
    #     if req.path == '/metatype' and 'filterbutton' not in req.params:
    #         actfilter = '*'

    # resets filter when going to a new view
    if 'filterbutton' not in req.params:
        actfilter = '*'

    # filter
    if actfilter != "":
        if actfilter in ("all", "*", t(lang(req), "admin_filter_all")):
github mediatum / mediatum / export / oai.py View on Github external
def get_oai_export_mask_for_schema_name_and_metadataformat(schema_name, metadataformat):
    schema = getMetaType(schema_name)
    if schema:
        mask = schema.getMask(u"oai_" + metadataformat.lower())
    else:
        mask = None
    return mask