server/schemaserial.py
changeset 5970 fb8acdab4e12
parent 5896 67683b7e591a
child 6080 d0cb8fde4957
equal deleted inserted replaced
5969:caea22e82d83 5970:fb8acdab4e12
    24 
    24 
    25 from logilab.common.shellutils import ProgressBar
    25 from logilab.common.shellutils import ProgressBar
    26 
    26 
    27 from yams import schema as schemamod, buildobjs as ybo
    27 from yams import schema as schemamod, buildobjs as ybo
    28 
    28 
    29 from cubicweb import CW_SOFTWARE_ROOT
    29 from cubicweb import CW_SOFTWARE_ROOT, typed_eid
    30 from cubicweb.schema import (CONSTRAINTS, ETYPE_NAME_MAP,
    30 from cubicweb.schema import (CONSTRAINTS, ETYPE_NAME_MAP,
    31                              VIRTUAL_RTYPES, PURE_VIRTUAL_RTYPES)
    31                              VIRTUAL_RTYPES, PURE_VIRTUAL_RTYPES)
    32 from cubicweb.server import sqlutils
    32 from cubicweb.server import sqlutils
    33 
    33 
    34 def group_mapping(cursor, interactive=True):
    34 def group_mapping(cursor, interactive=True):
    56             while True:
    56             while True:
    57                 value = raw_input('eid for group %s: ' % group).strip()
    57                 value = raw_input('eid for group %s: ' % group).strip()
    58                 if not value:
    58                 if not value:
    59                     continue
    59                     continue
    60                 try:
    60                 try:
    61                     res[group] = int(value)
    61                     eid = typed_eid(value)
    62                 except ValueError:
    62                 except ValueError:
    63                     print 'eid should be an integer'
    63                     print 'eid should be an integer'
    64                     continue
    64                     continue
       
    65                 for eid_ in res.values():
       
    66                     if eid == eid_:
       
    67                         break
       
    68                 else:
       
    69                     print 'eid is not a group eid'
       
    70                     continue
       
    71                 res[name] = eid
       
    72                 break
    65     return res
    73     return res
    66 
    74 
    67 def cstrtype_mapping(cursor):
    75 def cstrtype_mapping(cursor):
    68     """cached constraint types mapping"""
    76     """cached constraint types mapping"""
    69     map = dict(cursor.execute('Any T, X WHERE X is CWConstraintType, X name T'))
    77     map = dict(cursor.execute('Any T, X WHERE X is CWConstraintType, X name T'))