server/schemaserial.py
branchstable
changeset 3857 6676a839dc97
parent 3854 8633cd05b6b5
child 3876 1169d3154be6
equal deleted inserted replaced
3856:1c9589e46b16 3857:6676a839dc97
   282     eschemas = schema.entities()
   282     eschemas = schema.entities()
   283     aller = eschemas + schema.relations()
   283     aller = eschemas + schema.relations()
   284     if not verbose and not os.environ.get('APYCOT_ROOT'):
   284     if not verbose and not os.environ.get('APYCOT_ROOT'):
   285         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()])
   286         pb = ProgressBar(pb_size, title=_title)
   286         pb = ProgressBar(pb_size, title=_title)
       
   287     else:
       
   288         pb = None
   287     rql = 'INSERT CWConstraintType X: X name %(ct)s'
   289     rql = 'INSERT CWConstraintType X: X name %(ct)s'
   288     for cstrtype in CONSTRAINTS:
   290     for cstrtype in CONSTRAINTS:
   289         if verbose:
   291         if verbose:
   290             print rql
   292             print rql
   291         cursor.execute(rql, {'ct': unicode(cstrtype)})
   293         cursor.execute(rql, {'ct': unicode(cstrtype)})
   292         if not verbose:
   294         if pb is not None:
   293             pb.update()
   295             pb.update()
   294     groupmap = group_mapping(cursor, interactive=False)
   296     groupmap = group_mapping(cursor, interactive=False)
   295     for ertype in aller:
   297     for ertype in aller:
   296         # skip eid and has_text relations
   298         # skip eid and has_text relations
   297         if ertype in VIRTUAL_RTYPES:
   299         if ertype in VIRTUAL_RTYPES:
   298             pb.update()
   300             if pb is not None:
       
   301                 pb.update()
   299             continue
   302             continue
   300         for rql, kwargs in erschema2rql(schema[ertype]):
   303         for rql, kwargs in erschema2rql(schema[ertype]):
   301             if verbose:
   304             if verbose:
   302                 print rql % kwargs
   305                 print rql % kwargs
   303             cursor.execute(rql, kwargs)
   306             cursor.execute(rql, kwargs)
   304         for rql, kwargs in erperms2rql(schema[ertype], groupmap):
   307         for rql, kwargs in erperms2rql(schema[ertype], groupmap):
   305             if verbose:
   308             if verbose:
   306                 print rql
   309                 print rql
   307             cursor.execute(rql, kwargs)
   310             cursor.execute(rql, kwargs)
   308         if not verbose:
   311         if pb is not None:
   309             pb.update()
   312             pb.update()
   310     for rql, kwargs in specialize2rql(schema):
   313     for rql, kwargs in specialize2rql(schema):
   311         if verbose:
   314         if verbose:
   312             print rql % kwargs
   315             print rql % kwargs
   313         cursor.execute(rql, kwargs)
   316         cursor.execute(rql, kwargs)
   314         if not verbose:
   317         if pb is not None:
   315             pb.update()
   318             pb.update()
   316     print
   319     print
   317 
   320 
   318 
   321 
   319 def _ervalues(erschema):
   322 def _ervalues(erschema):