hooks/metadata.py
changeset 5082 d6fd82a5a4e8
parent 5066 bf5cbc351e99
child 5174 78438ad513ca
child 5421 8167de96c523
equal deleted inserted replaced
5052:c9dbd95333f7 5082:d6fd82a5a4e8
    10 
    10 
    11 from datetime import datetime
    11 from datetime import datetime
    12 
    12 
    13 from cubicweb.selectors import implements
    13 from cubicweb.selectors import implements
    14 from cubicweb.server import hook
    14 from cubicweb.server import hook
    15 
    15 from cubicweb.server.utils import eschema_eid
    16 
       
    17 def eschema_eid(session, eschema):
       
    18     """get eid of the CWEType entity for the given yams type"""
       
    19     # eschema.eid is None if schema has been readen from the filesystem, not
       
    20     # from the database (eg during tests)
       
    21     if eschema.eid is None:
       
    22         eschema.eid = session.execute(
       
    23             'Any X WHERE X is CWEType, X name %(name)s',
       
    24             {'name': str(eschema)})[0][0]
       
    25     return eschema.eid
       
    26 
    16 
    27 
    17 
    28 class MetaDataHook(hook.Hook):
    18 class MetaDataHook(hook.Hook):
    29     __abstract__ = True
    19     __abstract__ = True
    30     category = 'metadata'
    20     category = 'metadata'