def registerWorkspace(self, guid, name):
"""
Registers a workspace.
Workspace name is the path to the workspace directory. This is assumed unique per metadb instance.
"""
# if the name ends with a / then remove it from the name.
# This is done only for consistency in workspace name
# since users could have / or not for the workspace.
name = name.rstrip('/')
workspace = self.session.query(Workspace).filter(
and_(Workspace.name == name))\
.first()
if workspace is None:
try:
workspace = Workspace(
guid=guid,
name=name
)
self.session.add(workspace)
self.session.commit()
except exc.DataError as e:
self.session.rollback()
raise ValueError("{0} : {1} ".format(str(e), guid))
return workspace
评论列表
文章目录