519 if syncperms: |
519 if syncperms: |
520 self._synchronize_permissions(rdef, repordef.eid) |
520 self._synchronize_permissions(rdef, repordef.eid) |
521 |
521 |
522 # base actions ############################################################ |
522 # base actions ############################################################ |
523 |
523 |
524 def checkpoint(self): |
524 def checkpoint(self, ask_confirm=True): |
525 """checkpoint action""" |
525 """checkpoint action""" |
526 if self.confirm('commit now ?', shell=False): |
526 if not ask_confirm or self.confirm('commit now ?', shell=False): |
527 self.commit() |
527 self.commit() |
528 |
528 |
529 def cmd_add_cube(self, cube, update_database=True): |
529 def cmd_add_cube(self, cube, update_database=True): |
530 self.cmd_add_cubes( (cube,), update_database) |
530 self.cmd_add_cubes( (cube,), update_database) |
531 |
531 |
684 instschema.del_entity_type(etype) |
684 instschema.del_entity_type(etype) |
685 else: |
685 else: |
686 eschema = self.fs_schema.eschema(etype) |
686 eschema = self.fs_schema.eschema(etype) |
687 confirm = self.verbosity >= 2 |
687 confirm = self.verbosity >= 2 |
688 # register the entity into CWEType |
688 # register the entity into CWEType |
689 self.rqlexecall(ss.eschema2rql(eschema), ask_confirm=confirm) |
689 self.rqlexecall(ss.eschema2rql(eschema, self.group_mapping()), ask_confirm=confirm) |
690 # add specializes relation if needed |
690 # add specializes relation if needed |
691 self.rqlexecall(ss.eschemaspecialize2rql(eschema), ask_confirm=confirm) |
691 self.rqlexecall(ss.eschemaspecialize2rql(eschema), ask_confirm=confirm) |
692 # register groups / permissions for the entity |
|
693 self.rqlexecall(ss.erperms2rql(eschema, self.group_mapping()), |
|
694 ask_confirm=confirm) |
|
695 # register entity's attributes |
692 # register entity's attributes |
696 for rschema, attrschema in eschema.attribute_definitions(): |
693 for rschema, attrschema in eschema.attribute_definitions(): |
697 # ignore those meta relations, they will be automatically added |
694 # ignore those meta relations, they will be automatically added |
698 if rschema.type in META_RTYPES: |
695 if rschema.type in META_RTYPES: |
699 continue |
696 continue |
826 rschema = self.fs_schema.rschema(rtype) |
823 rschema = self.fs_schema.rschema(rtype) |
827 # register the relation into CWRType and insert necessary relation |
824 # register the relation into CWRType and insert necessary relation |
828 # definitions |
825 # definitions |
829 self.rqlexecall(ss.rschema2rql(rschema, addrdef=False), |
826 self.rqlexecall(ss.rschema2rql(rschema, addrdef=False), |
830 ask_confirm=self.verbosity>=2) |
827 ask_confirm=self.verbosity>=2) |
831 # register groups / permissions for the relation |
|
832 self.rqlexecall(ss.erperms2rql(rschema, self.group_mapping()), |
|
833 ask_confirm=self.verbosity>=2) |
|
834 if addrdef: |
828 if addrdef: |
835 self.commit() |
829 self.commit() |
836 self.rqlexecall(ss.rdef2rql(rschema), |
830 self.rqlexecall(ss.rdef2rql(rschema, groupmap=self.group_mapping()), |
837 ask_confirm=self.verbosity>=2) |
831 ask_confirm=self.verbosity>=2) |
838 if rtype in META_RTYPES: |
832 if rtype in META_RTYPES: |
839 # if the relation is in META_RTYPES, ensure we're adding it for |
833 # if the relation is in META_RTYPES, ensure we're adding it for |
840 # all entity types *in the persistent schema*, not only those in |
834 # all entity types *in the persistent schema*, not only those in |
841 # the fs schema |
835 # the fs schema |
878 schema definition file |
872 schema definition file |
879 """ |
873 """ |
880 rschema = self.fs_schema.rschema(rtype) |
874 rschema = self.fs_schema.rschema(rtype) |
881 if not rtype in self.repo.schema: |
875 if not rtype in self.repo.schema: |
882 self.cmd_add_relation_type(rtype, addrdef=False, commit=True) |
876 self.cmd_add_relation_type(rtype, addrdef=False, commit=True) |
883 self.rqlexecall(ss.rdef2rql(rschema, subjtype, objtype), |
877 self.rqlexecall(ss.rdef2rql(rschema, subjtype, objtype, groupmap=self.group_mapping()), |
884 ask_confirm=self.verbosity>=2) |
878 ask_confirm=self.verbosity>=2) |
885 if commit: |
879 if commit: |
886 self.commit() |
880 self.commit() |
887 |
881 |
888 def cmd_drop_relation_definition(self, subjtype, rtype, objtype, commit=True): |
882 def cmd_drop_relation_definition(self, subjtype, rtype, objtype, commit=True): |