Extracted DB API layer
Extracted DB operations on Project and Story objects to a separate access layer. That'll help to control SQLA operation more granullary. This approach is used among most of OpenStack projects. Change-Id: I0bde262eabb71c0613fcc06b93aefc70326269b7
This commit is contained in:
0
storyboard/common/__init__.py
Normal file
0
storyboard/common/__init__.py
Normal file
46
storyboard/common/exception.py
Normal file
46
storyboard/common/exception.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# Copyright (c) 2014 Mirantis Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
class StoryboardException(Exception):
|
||||
"""Base Exception for the project
|
||||
|
||||
To correctly use this class, inherit from it and define
|
||||
the 'message' property.
|
||||
"""
|
||||
|
||||
message = "An unknown exception occurred"
|
||||
|
||||
def __str__(self):
|
||||
return self.message
|
||||
|
||||
def __init__(self):
|
||||
super(StoryboardException, self).__init__(self.message)
|
||||
|
||||
|
||||
class NotFound(StoryboardException):
|
||||
message = "Object not found"
|
||||
|
||||
def __init__(self, message=None):
|
||||
if message:
|
||||
self.message = message
|
||||
|
||||
|
||||
class DuplicateEntry(StoryboardException):
|
||||
message = "Database object already exists"
|
||||
|
||||
def __init__(self, message=None):
|
||||
if message:
|
||||
self.message = message
|
||||
Reference in New Issue
Block a user