server/schemaserial.py
changeset 5379 c082dea0731b
parent 4835 13b0b96d7982
child 5423 e15abfdcce38
equal deleted inserted replaced
5378:0f54a0e128ac 5379:c082dea0731b
    50                     continue
    50                     continue
    51     return res
    51     return res
    52 
    52 
    53 def cstrtype_mapping(cursor):
    53 def cstrtype_mapping(cursor):
    54     """cached constraint types mapping"""
    54     """cached constraint types mapping"""
    55     return dict(cursor.execute('Any T, X WHERE X is CWConstraintType, X name T'))
    55     map = dict(cursor.execute('Any T, X WHERE X is CWConstraintType, X name T'))
       
    56     if not 'BoundConstraint' in map:
       
    57         map['BoundConstraint'] = map['BoundaryConstraint']
       
    58     return map
    56 
    59 
    57 # schema / perms deserialization ##############################################
    60 # schema / perms deserialization ##############################################
    58 
    61 
    59 def deserialize_schema(schema, session):
    62 def deserialize_schema(schema, session):
    60     """return a schema according to information stored in an rql database
    63     """return a schema according to information stored in an rql database
   238             pb.update()
   241             pb.update()
   239     # serialize constraint types
   242     # serialize constraint types
   240     cstrtypemap = {}
   243     cstrtypemap = {}
   241     rql = 'INSERT CWConstraintType X: X name %(ct)s'
   244     rql = 'INSERT CWConstraintType X: X name %(ct)s'
   242     for cstrtype in CONSTRAINTS:
   245     for cstrtype in CONSTRAINTS:
       
   246         if cstrtype == 'BoundConstraint':
       
   247             continue # XXX deprecated in yams 0.29 / cw 3.8.1
   243         cstrtypemap[cstrtype] = execute(rql, {'ct': unicode(cstrtype)},
   248         cstrtypemap[cstrtype] = execute(rql, {'ct': unicode(cstrtype)},
   244                                         build_descr=False)[0][0]
   249                                         build_descr=False)[0][0]
   245         if pb is not None:
   250         if pb is not None:
   246             pb.update()
   251             pb.update()
       
   252     cstrtypemap['BoundConstraint'] = cstrtypemap['BoundaryConstraint']
   247     # serialize relations
   253     # serialize relations
   248     for rschema in schema.relations():
   254     for rschema in schema.relations():
   249         # skip virtual relations such as eid, has_text and identity
   255         # skip virtual relations such as eid, has_text and identity
   250         if rschema in VIRTUAL_RTYPES:
   256         if rschema in VIRTUAL_RTYPES:
   251             if pb is not None:
   257             if pb is not None: