akretion / roulier

API for package delivery
http://akretion.github.io/roulier/
GNU Affero General Public License v3.0
22 stars 21 forks source link

Cerberus 1.2 #97

Closed qpeyramale closed 6 years ago

qpeyramale commented 6 years ago

Hello, I got an error when I call the api() method. I'm on Cerberus 1.2. No issue with Cerberus 1.1.

Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pprint import pprint
>>> from roulier import roulier
>>> 
>>> 
>>> laposte = roulier.get('laposte')
>>> pprint(laposte.api())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/roulier/carriers/laposte/laposte.py", line 19, in api
  File "build/bdist.linux-x86_64/egg/roulier/carriers/laposte/laposte_encoder.py", line 52, in api
  File "build/bdist.linux-x86_64/egg/roulier/api.py", line 158, in api_values
  File "build/bdist.linux-x86_64/egg/roulier/api.py", line 180, in normalize
  File "build/bdist.linux-x86_64/egg/roulier/api.py", line 133, in api_schema
  File "build/bdist.linux-x86_64/egg/roulier/carriers/laposte/laposte_api.py", line 150, in _schemas
  File "build/bdist.linux-x86_64/egg/roulier/api.py", line 116, in _schemas
  File "build/bdist.linux-x86_64/egg/roulier/api.py", line 89, in _parcels
  File "/home/quentin/.local/lib/python2.7/site-packages/cerberus/validator.py", line 593, in normalized
    self.__init_processing(document, schema)
  File "/home/quentin/.local/lib/python2.7/site-packages/cerberus/validator.py", line 548, in __init_processing
    self.schema = DefinitionSchema(self, schema)
  File "/home/quentin/.local/lib/python2.7/site-packages/cerberus/schema.py", line 69, in __init__
    self.validate(schema)
  File "/home/quentin/.local/lib/python2.7/site-packages/cerberus/schema.py", line 197, in validate
    self._validate(schema)
  File "/home/quentin/.local/lib/python2.7/site-packages/cerberus/schema.py", line 218, in _validate
    if not self.schema_validator(schema, normalize=False):
  File "/home/quentin/.local/lib/python2.7/site-packages/cerberus/validator.py", line 879, in validate
    self.__validate_unknown_fields(field)
  File "/home/quentin/.local/lib/python2.7/site-packages/cerberus/validator.py", line 912, in __validate_unknown_fields
    if not validator({field: value}, normalize=False):
  File "/home/quentin/.local/lib/python2.7/site-packages/cerberus/validator.py", line 877, in validate
    self.__validate_definitions(definitions, field)
  File "/home/quentin/.local/lib/python2.7/site-packages/cerberus/validator.py", line 940, in __validate_definitions
    result = validate_rule(rule)
  File "/home/quentin/.local/lib/python2.7/site-packages/cerberus/validator.py", line 922, in validate_rule
    return validator(definitions.get(rule, None), field, value)
  File "/home/quentin/.local/lib/python2.7/site-packages/cerberus/validator.py", line 1236, in _validate_schema
    self.__validate_schema_mapping(field, schema, value)
  File "/home/quentin/.local/lib/python2.7/site-packages/cerberus/validator.py", line 1247, in __validate_schema_mapping
    if not validator(value, update=self.update, normalize=False):
  File "/home/quentin/.local/lib/python2.7/site-packages/cerberus/validator.py", line 877, in validate
    self.__validate_definitions(definitions, field)
  File "/home/quentin/.local/lib/python2.7/site-packages/cerberus/validator.py", line 940, in __validate_definitions
    result = validate_rule(rule)
  File "/home/quentin/.local/lib/python2.7/site-packages/cerberus/validator.py", line 921, in validate_rule
    validator = self.__get_rule_handler('validate', rule)
  File "/home/quentin/.local/lib/python2.7/site-packages/cerberus/validator.py", line 338, in __get_rule_handler
    "domain.".format(rule, domain))
RuntimeError: There's no handler for 'description' in the 'validate' domain.

Thank you

hparfr commented 6 years ago

qpeyramale, Thanks for posting an issue about that.

We added 'description' field in the schema in order to document the use of the api. It has been implemented like that : https://github.com/akretion/roulier/blob/develop/roulier/api.py#L10 It seams Cerberus 1.2 has changed the way of doing that.

Do not hesitate to propose a PR. Either fixing the Cerberus version to 1.1 in a requiremens.txt or either fixing it for the new versions of cerberus.

Thanks

qpeyramale commented 6 years ago

Hello,

I am ok with that. Just a last question, do you plan to implement python 3 compatibility?

Thanks for your response Regards

hparfr commented 6 years ago

I hope so but I don't have any python 3 project yet which require this module. May be next year.

qpeyramale commented 6 years ago

Alright. Have a good day.