515 :param: the newly created or just completed relation schema |
515 :param: the newly created or just completed relation schema |
516 """ |
516 """ |
517 rdef.name = rdef.name.lower() |
517 rdef.name = rdef.name.lower() |
518 rdef.subject = bw_normalize_etype(rdef.subject) |
518 rdef.subject = bw_normalize_etype(rdef.subject) |
519 rdef.object = bw_normalize_etype(rdef.object) |
519 rdef.object = bw_normalize_etype(rdef.object) |
520 super(CubicWebSchema, self).add_relation_def(rdef) |
520 if super(CubicWebSchema, self).add_relation_def(rdef): |
521 try: |
521 try: |
522 self._eid_index[rdef.eid] = (self.eschema(rdef.subject), |
522 self._eid_index[rdef.eid] = (self.eschema(rdef.subject), |
523 self.rschema(rdef.name), |
523 self.rschema(rdef.name), |
524 self.eschema(rdef.object)) |
524 self.eschema(rdef.object)) |
525 except AttributeError: |
525 except AttributeError: |
526 pass # not a serialized schema |
526 pass # not a serialized schema |
527 |
527 |
528 def del_relation_type(self, rtype): |
528 def del_relation_type(self, rtype): |
529 rschema = self.rschema(rtype) |
529 rschema = self.rschema(rtype) |
530 self._eid_index.pop(rschema.eid, None) |
530 self._eid_index.pop(rschema.eid, None) |
531 super(CubicWebSchema, self).del_relation_type(rtype) |
531 super(CubicWebSchema, self).del_relation_type(rtype) |
904 """ |
904 """ |
905 schemacls = CubicWebSchema |
905 schemacls = CubicWebSchema |
906 SchemaLoader.file_handlers.update({'.rel' : CubicWebRelationFileReader, |
906 SchemaLoader.file_handlers.update({'.rel' : CubicWebRelationFileReader, |
907 }) |
907 }) |
908 |
908 |
909 def load(self, config, path=()): |
909 def load(self, config, path=(), **kwargs): |
910 """return a Schema instance from the schema definition read |
910 """return a Schema instance from the schema definition read |
911 from <directory> |
911 from <directory> |
912 """ |
912 """ |
913 self.lib_directory = config.schemas_lib_dir() |
913 self.lib_directory = config.schemas_lib_dir() |
914 return super(BootstrapSchemaLoader, self).load( |
914 return super(BootstrapSchemaLoader, self).load( |
915 path, config.appid, register_base_types=False) |
915 path, config.appid, register_base_types=False, **kwargs) |
916 |
916 |
917 def _load_definition_files(self, cubes=None): |
917 def _load_definition_files(self, cubes=None): |
918 # bootstraping, ignore cubes |
918 # bootstraping, ignore cubes |
919 for filepath in self.include_schema_files('bootstrap'): |
919 for filepath in self.include_schema_files('bootstrap'): |
920 self.info('loading %s', filepath) |
920 self.info('loading %s', filepath) |
928 class CubicWebSchemaLoader(BootstrapSchemaLoader): |
928 class CubicWebSchemaLoader(BootstrapSchemaLoader): |
929 """cubicweb specific schema loader, automatically adding metadata to the |
929 """cubicweb specific schema loader, automatically adding metadata to the |
930 application's schema |
930 application's schema |
931 """ |
931 """ |
932 |
932 |
933 def load(self, config): |
933 def load(self, config, **kwargs): |
934 """return a Schema instance from the schema definition read |
934 """return a Schema instance from the schema definition read |
935 from <directory> |
935 from <directory> |
936 """ |
936 """ |
937 self.info('loading %s schemas', ', '.join(config.cubes())) |
937 self.info('loading %s schemas', ', '.join(config.cubes())) |
938 if config.apphome: |
938 if config.apphome: |
939 path = reversed([config.apphome] + config.cubes_path()) |
939 path = reversed([config.apphome] + config.cubes_path()) |
940 else: |
940 else: |
941 path = reversed(config.cubes_path()) |
941 path = reversed(config.cubes_path()) |
942 return super(CubicWebSchemaLoader, self).load(config, path=path) |
942 return super(CubicWebSchemaLoader, self).load(config, path=path, **kwargs) |
943 |
943 |
944 def _load_definition_files(self, cubes): |
944 def _load_definition_files(self, cubes): |
945 for filepath in (self.include_schema_files('bootstrap') |
945 for filepath in (self.include_schema_files('bootstrap') |
946 + self.include_schema_files('base') |
946 + self.include_schema_files('base') |
947 + self.include_schema_files('workflow') |
947 + self.include_schema_files('workflow') |