server/schemaserial.py
changeset 3737 e8c669e33689
parent 3732 f9336257e0b9
child 3890 d7a270f50f54
equal deleted inserted replaced
3735:80fb4083c29b 3737:e8c669e33689
   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     quiet = not os.environ['APYCOT_ROOT']
   280     quiet = os.environ.get('APYCOT_ROOT')
   281     if not quiet:
   281     if not quiet:
   282         _title = '-> storing the schema in the database '
   282         _title = '-> storing the schema in the database '
   283         print _title,
   283         print _title,
   284     eschemas = schema.entities()
   284     eschemas = schema.entities()
   285     aller = eschemas + schema.relations()
   285     aller = eschemas + schema.relations()
   297             pb.update()
   297             pb.update()
   298     groupmap = group_mapping(cursor, interactive=False)
   298     groupmap = group_mapping(cursor, interactive=False)
   299     for ertype in aller:
   299     for ertype in aller:
   300         # skip eid and has_text relations
   300         # skip eid and has_text relations
   301         if ertype in VIRTUAL_RTYPES:
   301         if ertype in VIRTUAL_RTYPES:
   302             pb.update()
   302             if pb is not None:
       
   303                 pb.update()
   303             continue
   304             continue
   304         for rql, kwargs in erschema2rql(schema[ertype]):
   305         for rql, kwargs in erschema2rql(schema[ertype]):
   305             if verbose:
   306             if verbose:
   306                 print rql % kwargs
   307                 print rql % kwargs
   307             cursor.execute(rql, kwargs)
   308             cursor.execute(rql, kwargs)