Comments (8)
class InvalidValue(sch_interfaces.InvalidValue):
"""
InvalidValue(*args, field=None, value=None)
Adds a field specifically to carry the value that is invalid.
.. deprecated:: 1.4.0
This is now just a convenience wrapper around
:class:`zope.schema.interfaces.InvalidValue` that calls
:meth:`.zope.schema.interfaces.ValidationError.with_field_and_value`
before returning the exception. You should always catch
:class:`zope.schema.interfaces.InvalidValue`.
"""
# We can't write the syntax we want to in Python 2.
def __init__(self, *args, **kwargs):
field = kwargs.pop('field', None)
value = kwargs.pop('value', None)
if kwargs:
raise TypeError("Too many kwargs for function InvalidValue")
**super(InvalidValue, self).__init__(self, *args)**
self.with_field_and_value(field, value)
from nti.schema.
(FYI, code snippets are introduced with three backticks and the name, not double quotes.)
from nti.schema.
Can you provide an edited traceback? I can't reproduce any problems in a test.
def test_subclass_constructor(self):
from nti.schema.interfaces import InvalidValue
class InvalidData(InvalidValue):
"""
Invalid Value
"""
i18n_message = None
def __str__(self):
if self.i18n_message:
return translate(self.i18n_message)
return super(InvalidData, self).__str__()
def doc(self):
if self.i18n_message:
return self.i18n_message
return self.__class__.__doc__
class EmailAddressInvalid(InvalidData):
"""
Invalid email address.
"""
i18n_message = "The email address you have entered is not valid."
def __init__(self, address):
super(EmailAddressInvalid, self).__init__(address, value=address)
EmailAddressInvalid('foo')
from nti.schema.
I think the problem is in line 158 of nti.schema.interfaces.py
class InvalidValue(sch_interfaces.InvalidValue):
"""
InvalidValue(*args, field=None, value=None)
Adds a field specifically to carry the value that is invalid.
.. deprecated:: 1.4.0
This is now just a convenience wrapper around
:class:`zope.schema.interfaces.InvalidValue` that calls
:meth:`.zope.schema.interfaces.ValidationError.with_field_and_value`
before returning the exception. You should always catch
:class:`zope.schema.interfaces.InvalidValue`.
"""
# We can't write the syntax we want to in Python 2.
def __init__(self, *args, **kwargs):
field = kwargs.pop('field', None)
value = kwargs.pop('value', None)
if kwargs:
raise TypeError("Too many kwargs for function InvalidValue")
super(InvalidValue, self).__init__(self, *args)
self.with_field_and_value(field, value)
when calling the super constructor.. (there seems to be an extra self)
from nti.schema.
Yeah, that would mess up the .args
property, but I don't see a recursion issue there just constructing the object. Can you post an edited traceback?
from nti.schema.
>>> from nti.dataserver.users.interfaces import EmailAddressInvalid
>>> EmailAddressInvalid('foo')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/csanchez/Documents/workspace/nti.dataserver-buildout/eggs/zope.schema-4.6.1-py2.7.egg/zope/schema/_bootstrapinterfaces.py", line 69, in __repr__
', '.join(repr(arg) for arg in self.args))
File "/Users/csanchez/Documents/workspace/nti.dataserver-buildout/eggs/zope.schema-4.6.1-py2.7.egg/zope/schema/_bootstrapinterfaces.py", line 69, in <genexpr>
', '.join(repr(arg) for arg in self.args))
File "/Users/csanchez/Documents/workspace/nti.dataserver-buildout/eggs/zope.schema-4.6.1-py2.7.egg/zope/schema/_bootstrapinterfaces.py", line 69, in __repr__
....
....
File "/Users/csanchez/Documents/workspace/nti.dataserver-buildout/eggs/zope.schema-4.6.1-py2.7.egg/zope/schema/_bootstrapinterfaces.py", line 69, in <genexpr>
', '.join(repr(arg) for arg in self.args))
RuntimeError: maximum recursion depth exceeded while calling a Python object
from nti.schema.
There it is. You're printing the repr
, and reprs
include .args
by default. This should be more of a test issue than anything else (of course it should still be fixed).
from nti.schema.
Apologies ... I just saw it myself
from nti.schema.
Related Issues (20)
- UnboundLocalError Exception ; Variant class _validate field HOT 8
- Update tox.ini
- Update travis.yml
- Drop explicit support for Python 3.4
- Stop omitting tests from coverage measurement
- Updates for zope.schema 4.6.0 HOT 2
- make nti.schema.interfaces.InvalidValue a class again
- assert in FieldValidationMixin._reraise_validation_error HOT 6
- nti.schema.jsonschema should turn abstract collections into concrete values HOT 1
- Add support for ``IFromBytes``
- Return title/description in JsonSchemafier
- Return nested schemas in JsonSchemafier HOT 1
- Extensible UI Type tags HOT 6
- Use IField subclasses to expose more/better schema information
- Nested field schema should use JsonSchemafier HOT 2
- SchemaConfigured may be slower than necessary, especially when creating many of the same type object HOT 2
- Incorrect plurality in some cases for fields with min length HOT 1
- DeprecationWarning: InvalidValue: Use zope.schema.interfaces.InvalidValue.with_field_and_value.
- Poor handling of Dict objects missing a key/value type inside a Variant -> AttributeError
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nti.schema.