server/schemaserial.py
branchstable
changeset 2396 8bfb99d7bbcc
parent 2395 e3093fc12a00
child 2458 4d114865098f
equal deleted inserted replaced
2395:e3093fc12a00 2396:8bfb99d7bbcc
   275 
   275 
   276 def serialize_schema(cursor, schema, verbose=False):
   276 def serialize_schema(cursor, schema, verbose=False):
   277     """synchronize schema and permissions in the database according to
   277     """synchronize schema and permissions in the database according to
   278     current schema
   278     current schema
   279     """
   279     """
   280     print '-> storing the schema in the database...'
   280     _title = '-> storing the schema in the database '
       
   281     print _title,
   281     eschemas = schema.entities()
   282     eschemas = schema.entities()
   282     aller = eschemas + schema.relations()
   283     aller = eschemas + schema.relations()
   283     if not verbose:
   284     if not verbose:
   284         pb_size = len(aller) + len(CONSTRAINTS) + len([x for x in eschemas if x.specializes()])
   285         pb_size = len(aller) + len(CONSTRAINTS) + len([x for x in eschemas if x.specializes()])
   285         pb = ProgressBar(pb_size)
   286         pb = ProgressBar(pb_size, title=_title)
   286     for cstrtype in CONSTRAINTS:
   287     for cstrtype in CONSTRAINTS:
   287         rql = 'INSERT CWConstraintType X: X name "%s"' % cstrtype
   288         rql = 'INSERT CWConstraintType X: X name "%s"' % cstrtype
   288         if verbose:
   289         if verbose:
   289             print rql
   290             print rql
   290         cursor.execute(rql)
   291         cursor.execute(rql)