Commit 989cc2b2 authored by Zuul's avatar Zuul Committed by Gerrit Code Review

Merge "Migrate object to OVO (6)"

parents f2d945bc f4c96aaa
......@@ -21,6 +21,7 @@ from oslo_log import log as logging
from oslo_utils import timeutils
from designate import exceptions
from designate.objects import validation_error
from designate.schema import validators
from designate.schema import format
from designate.i18n import _
......@@ -311,10 +312,8 @@ class DesignateObject(object):
make_class_validator(self)
# NOTE(kiall): We make use of the Object registry here in order to
# avoid an impossible circular import.
ValidationErrorList = self.obj_cls_from_name('ValidationErrorList')
ValidationError = self.obj_cls_from_name('ValidationError')
ValidationErrorList = validation_error.ValidationErrorList
ValidationError = validation_error.ValidationError
errors = ValidationErrorList()
......
......@@ -22,8 +22,6 @@ from oslo_versionedobjects.base import VersionedObjectDictCompat as DictObjectMi
from designate.i18n import _
from designate.i18n import _LE
from designate.objects import fields
from designate.objects.validation_error import ValidationError
from designate.objects.validation_error import ValidationErrorList
from designate import exceptions
LOG = logging.getLogger(__name__)
......@@ -210,6 +208,10 @@ class DesignateObject(base.VersionedObject):
return self._context
def validate(self):
# NOTE(kiall, daidv): We make use of the Object registry here
# in order to avoid an impossible circular import.
ValidationErrorList = self.obj_cls_from_name('ValidationErrorList')
ValidationError = self.obj_cls_from_name('ValidationError')
self.fields = self.FIELDS
for name in self.fields:
field = self.fields[name]
......
......@@ -11,16 +11,19 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from designate.objects import base
from designate.objects import ovo_base as base
from designate.objects import fields
@base.DesignateRegistry.register
class ValidationError(base.DesignateObject):
FIELDS = {
'path': {},
'message': {},
'validator': {},
'validator_value': {},
'raw': {},
fields = {
'path': fields.AnyField(nullable=True),
'message': fields.AnyField(nullable=True),
'validator': fields.AnyField(nullable=True),
'validator_value': fields.AnyField(nullable=True),
'raw': fields.AnyField(nullable=True),
}
@classmethod
......@@ -40,5 +43,10 @@ class ValidationError(base.DesignateObject):
return e
@base.DesignateRegistry.register
class ValidationErrorList(base.ListObjectMixin, base.DesignateObject):
LIST_ITEM_TYPE = ValidationError
fields = {
'objects': fields.ListOfObjectsField('ValidationError'),
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment