server/schemaserial.py
branchstable
changeset 5425 7c84e3f370de
parent 5423 e15abfdcce38
child 5426 0d4853a6e5ee
equal deleted inserted replaced
5421:8167de96c523 5425:7c84e3f370de
    63                     continue
    63                     continue
    64     return res
    64     return res
    65 
    65 
    66 def cstrtype_mapping(cursor):
    66 def cstrtype_mapping(cursor):
    67     """cached constraint types mapping"""
    67     """cached constraint types mapping"""
    68     return dict(cursor.execute('Any T, X WHERE X is CWConstraintType, X name T'))
    68     map = dict(cursor.execute('Any T, X WHERE X is CWConstraintType, X name T'))
       
    69     if not 'BoundConstraint' in map:
       
    70         map['BoundConstraint'] = map['BoundaryConstraint']
       
    71     return map
    69 
    72 
    70 # schema / perms deserialization ##############################################
    73 # schema / perms deserialization ##############################################
    71 
    74 
    72 def deserialize_schema(schema, session):
    75 def deserialize_schema(schema, session):
    73     """return a schema according to information stored in an rql database
    76     """return a schema according to information stored in an rql database
   251             pb.update()
   254             pb.update()
   252     # serialize constraint types
   255     # serialize constraint types
   253     cstrtypemap = {}
   256     cstrtypemap = {}
   254     rql = 'INSERT CWConstraintType X: X name %(ct)s'
   257     rql = 'INSERT CWConstraintType X: X name %(ct)s'
   255     for cstrtype in CONSTRAINTS:
   258     for cstrtype in CONSTRAINTS:
       
   259         if cstrtype == 'BoundConstraint':
       
   260             continue # XXX deprecated in yams 0.29 / cw 3.8.1
   256         cstrtypemap[cstrtype] = execute(rql, {'ct': unicode(cstrtype)},
   261         cstrtypemap[cstrtype] = execute(rql, {'ct': unicode(cstrtype)},
   257                                         build_descr=False)[0][0]
   262                                         build_descr=False)[0][0]
   258         if pb is not None:
   263         if pb is not None:
   259             pb.update()
   264             pb.update()
       
   265     cstrtypemap['BoundConstraint'] = cstrtypemap['BoundaryConstraint']
   260     # serialize relations
   266     # serialize relations
   261     for rschema in schema.relations():
   267     for rschema in schema.relations():
   262         # skip virtual relations such as eid, has_text and identity
   268         # skip virtual relations such as eid, has_text and identity
   263         if rschema in VIRTUAL_RTYPES:
   269         if rschema in VIRTUAL_RTYPES:
   264             if pb is not None:
   270             if pb is not None: