Giter Site home page Giter Site logo

Comments (8)

papachoco avatar papachoco commented on August 22, 2024
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.

jamadden avatar jamadden commented on August 22, 2024

(FYI, code snippets are introduced with three backticks and the name, not double quotes.)

from nti.schema.

jamadden avatar jamadden commented on August 22, 2024

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.

papachoco avatar papachoco commented on August 22, 2024

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.

jamadden avatar jamadden commented on August 22, 2024

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.

papachoco avatar papachoco commented on August 22, 2024
>>> 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.

jamadden avatar jamadden commented on August 22, 2024

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.

papachoco avatar papachoco commented on August 22, 2024

Apologies ... I just saw it myself

from nti.schema.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.