some more improvements
This commit is contained in:
parent
c5fe2044b5
commit
b4a8ae1ed1
1 changed files with 14 additions and 33 deletions
43
psu.py
43
psu.py
|
@ -182,7 +182,8 @@ def reindex_objects(objs, **kw):
|
||||||
util.reindex(obj, catalog)
|
util.reindex(obj, catalog)
|
||||||
loop('reindex %s objects' % len(objs), objs, do_reindex, **kw)
|
loop('reindex %s objects' % len(objs), objs, do_reindex, **kw)
|
||||||
|
|
||||||
# auxiliary functions
|
|
||||||
|
# some common repair tasks
|
||||||
|
|
||||||
def get_type_instances(name):
|
def get_type_instances(name):
|
||||||
return sc.concepts[name].getChildren([sc.hasType])
|
return sc.concepts[name].getChildren([sc.hasType])
|
||||||
|
@ -190,49 +191,29 @@ def get_type_instances(name):
|
||||||
def notify_modification(c, info):
|
def notify_modification(c, info):
|
||||||
notifyModification(c)
|
notifyModification(c)
|
||||||
|
|
||||||
|
|
||||||
# some common repair tasks
|
|
||||||
|
|
||||||
def update_type_instances(**kw):
|
def update_type_instances(**kw):
|
||||||
info = startup('Notify Type Instances', **kw)
|
objs = get_type_instances(kw.pop('type'))
|
||||||
ctype = kw.pop('type')
|
loop('Notify Type Instances', objs, notify_modification, **kw)
|
||||||
for c in get_type_instances(ctype):
|
|
||||||
update(notify_modification, c, info)
|
|
||||||
if stop_condition(info):
|
|
||||||
break
|
|
||||||
finish(info)
|
|
||||||
|
|
||||||
def update_type_instances_title_from_adapted(**kw):
|
def update_type_instances_title_from_adapted(**kw):
|
||||||
info = startup('Update Type Instances Title', **kw)
|
def update_type_title_from_adapted(c, info):
|
||||||
ctype = kw.pop('type')
|
|
||||||
for c in get_type_instances(ctype):
|
|
||||||
update(update_type_title_from_adapted, c, info)
|
|
||||||
if stop_condition(info):
|
|
||||||
break
|
|
||||||
finish(info)
|
|
||||||
|
|
||||||
def update_type_title_from_adapted(c, info):
|
|
||||||
c.title = adapted(c).title
|
c.title = adapted(c).title
|
||||||
notifyModification(c)
|
notifyModification(c)
|
||||||
|
objs = get_type_instances(kw.pop('type'))
|
||||||
|
loop('Update Type Instances Title', objs, update_type_title_from_adapted, **kw)
|
||||||
|
|
||||||
def removeRecords(container, **kw):
|
def removeRecords(container, **kw):
|
||||||
"""Remove records from container selected by the criteria given."""
|
"""Remove records from container selected by the criteria given."""
|
||||||
info = startup('Remove records', container=container, **kw)
|
def remove(obj, info):
|
||||||
|
notifyRemoved(obj)
|
||||||
|
del container[obj.__name__]
|
||||||
|
info = startup('Remove records', **kw)
|
||||||
date = kw.pop('date', None)
|
date = kw.pop('date', None)
|
||||||
if date:
|
if date:
|
||||||
kw['timeFromTo'] = (
|
kw['timeFromTo'] = (
|
||||||
date2TimeStamp(strptime(date + ' 00:00:00')),
|
date2TimeStamp(strptime(date + ' 00:00:00')),
|
||||||
date2TimeStamp(strptime(date + ' 23:59:59')))
|
date2TimeStamp(strptime(date + ' 23:59:59')))
|
||||||
for obj in container.query(**kw):
|
loop('Remove records', container.query(**kw), remove, **kw)
|
||||||
update(remove, obj, info)
|
|
||||||
if stop_condition(info):
|
|
||||||
break
|
|
||||||
finish(info)
|
|
||||||
|
|
||||||
def remove(obj, info):
|
|
||||||
notifyRemoved(obj)
|
|
||||||
del info.container[obj.__name__]
|
|
||||||
|
|
||||||
|
|
||||||
# helper functions and classes
|
# helper functions and classes
|
||||||
|
|
Loading…
Add table
Reference in a new issue