Exemplo n.º 1
0
def deleteOrphanElements():
    """this will delete elements with no parent and are not root elements"""
    roots = [mtm.root for mtm in common.PM.getMediaTypeManager(returnAll=True)]
    if not roots:
        return
    lost_children = Element.select().where(Element.parent >> None, ~(Element.id << roots))
    for lost_child in lost_children:
        log.info("Element %s is lost. Begone." % lost_child.id)
    Element.delete().where(Element.id << lost_children).execute()
Exemplo n.º 2
0
def cleanTemporaryElements():
    common.addState(6)
    for temp in list(Element.select().where(Element.status == common.TEMP)):
        temp.delete_instance(silent=True)

    log.info("Removeing temp elements DONE")
    common.removeState(6)
Exemplo n.º 3
0
def deleteOrphanElements():
    log.info("Getting elements")
    elements = Element.select()
    delete_count = 0
    for element in list(elements):
        try:
            if element.parent:
                _ = element.parent
        except Element.DoesNotExist:
            log("deleting element %s" % element.get_id())
            #element.delete_instance(silent=True)
            super(Element, element).delete_instance()
            delete_count += 1

    log.info("deleted %s orphanaged elements" % delete_count)
Exemplo n.º 4
0
def deleteOrphanElements():
    """this will delete elements with no parent and are not root elements"""
    roots = [mtm.root for mtm in common.PM.getMediaTypeManager(returnAll=True)]
    if not roots:
        return
    lost_children = Element.select().where(Element.parent >> None, ~(Element.id << roots))
    for lost_child in lost_children:
        log.info("Element %s is lost. Begone." % lost_child.id)
    for element in Element.select().where(~(Element.id << roots)):
        try:
            element.parent
        except element.DoesNotExist:
            log.info("Element %s parents are dead. Begone." % element.id)
            Element.delete().where(Element.id == element.id).execute()

    Element.delete().where(Element.id << lost_children).execute()
Exemplo n.º 5
0
def deleteOrphanImages():
    log.info("Getting orphanaged images")
    elements = Element.select()
    image_dq = Image.delete().where(~(Image.element << elements))
    deleted_rows = image_dq.execute()
    log.info("Deleted %s orphanaged images" % deleted_rows)
Exemplo n.º 6
0
def deleteOrphanFields():
    log.info("Getting orphanaged fields")
    elements = Element.select()
    fields_dq = Field.delete().where(~(Field.element << elements))
    deleted_rows = fields_dq.execute()
    log.info("Deleted %s orphanaged fields" % deleted_rows)
Exemplo n.º 7
0
def cleanTemporaryElements():
    log.info("Getting temp elements")
    elements_dq = Element.delete().where(Element.status == common.TEMP)
    deleted_rows = elements_dq.execute()
    log.info("Deleted %s temp elements" % deleted_rows)
Exemplo n.º 8
0
def deleteOrphanImages():
    log.info("Getting orphanaged images")
    elements = Element.select()
    image_dq = Image.delete().where(~(Image.element << elements))
    deleted_rows = image_dq.execute()
    log.info("Deleted %s orphanaged images" % deleted_rows)
Exemplo n.º 9
0
def deleteOrphanFields():
    log.info("Getting orphanaged fields")
    elements = Element.select()
    fields_dq = Field.delete().where(~(Field.element << elements))
    deleted_rows = fields_dq.execute()
    log.info("Deleted %s orphanaged fields" % deleted_rows)
Exemplo n.º 10
0
def cleanTemporaryElements():
    log.info("Getting temp elements")
    elements_dq = Element.delete().where(Element.status == common.TEMP)
    deleted_rows = elements_dq.execute()
    log.info("Deleted %s temp elements" % deleted_rows)