Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing positional parameter #236

Open
jenstroeger opened this issue Jun 19, 2015 · 6 comments
Open

Missing positional parameter #236

jenstroeger opened this issue Jun 19, 2015 · 6 comments

Comments

@jenstroeger
Copy link
Contributor

I keep seeing this exception:

  File "/.../lib/python3.4/site-packages/colander/__init__.py", line 2174, in _unflatten_mapping
    subnode, subpaths, subfstruct)
TypeError: unflatten() missing 1 required positional argument: 'fstruct'

This is with colander 1.0.

@tseaver
Copy link
Member

tseaver commented Jun 20, 2015

Can you update to show the whole traceback?

@jenstroeger
Copy link
Contributor Author

Sure. There are actually two similar instances of this issue, both originating from the debug toolbar (latest version of Pyramid as of today).

Traceback (most recent call last):
  File "/.../lib/python3.4/site-packages/pyramid_debugtoolbar/toolbar.py", line 177, in toolbar_tween
    response = _handler(request)
  File "/.../lib/python3.4/site-packages/pyramid_debugtoolbar/panels/performance.py", line 57, in resource_timer_handler
    result = handler(request)
  File "/.../lib/python3.4/site-packages/pyramid/tweens.py", line 46, in excview_tween
    response = view_callable(exc, request)
  File "/.../lib/python3.4/site-packages/pyramid/config/views.py", line 385, in viewresult_to_response
    result = view(context, request)
  File "/.../lib/python3.4/site-packages/pyramid/tweens.py", line 21, in excview_tween
    response = handler(request)
  File "/.../lib/python3.4/site-packages/pyramid_tm/__init__.py", line 92, in tm_tween
    reraise(*exc_info)
  File "/.../lib/python3.4/site-packages/pyramid_tm/compat.py", line 13, in reraise
    raise value
  File "/.../lib/python3.4/site-packages/pyramid_tm/__init__.py", line 73, in tm_tween
    response = handler(request)
  File "/.../lib/python3.4/site-packages/pyramid/router.py", line 163, in handle_request
    response = view_callable(context, request)
  File "/.../lib/python3.4/site-packages/pyramid/config/views.py", line 596, in __call__
    return view(context, request)
  File "/.../lib/python3.4/site-packages/pyramid/config/views.py", line 329, in attr_view
    return view(context, request)
  File "/.../lib/python3.4/site-packages/pyramid/config/views.py", line 305, in predicate_wrapper
    return view(context, request)
  File "/.../lib/python3.4/site-packages/pyramid/config/views.py", line 355, in rendered_view
    result = view(context, request)
  File "/.../lib/python3.4/site-packages/pyramid/config/views.py", line 501, in _requestonly_view
    response = view(request)
  File "/.../lib/python3.4/site-packages/cornice/service.py", line 549, in wrapper
    validate_colander_schema(args['schema'], request)
  File "/.../lib/python3.4/site-packages/cornice/schemas.py", line 166, in validate_colander_schema
    _validate_fields('body', body)
  File "/.../lib/python3.4/site-packages/cornice/schemas.py", line 111, in _validate_fields
    data = webob.multidict.MultiDict(schema.unflatten(data))
  File "/.../lib/python3.4/site-packages/cornice/schemas.py", line 86, in unflatten
    return self.colander_schema.unflatten(data)
  File "/.../lib/python3.4/site-packages/colander/__init__.py", line 1885, in unflatten
    return self.typ.unflatten(self, paths, fstruct)
  File "/.../lib/python3.4/site-packages/colander/__init__.py", line 628, in unflatten
    return _unflatten_mapping(node, paths, fstruct)
  File "/.../lib/python3.4/site-packages/colander/__init__.py", line 2174, in _unflatten_mapping
    subnode, subpaths, subfstruct)
TypeError: unflatten() missing 1 required positional argument: 'fstruct'
Traceback (most recent call last):
  File "/.../lib/python3.4/site-packages/pyramid_debugtoolbar/toolbar.py", line 177, in toolbar_tween
    response = _handler(request)
  File "/.../lib/python3.4/site-packages/pyramid_debugtoolbar/panels/performance.py", line 57, in resource_timer_handler
    result = handler(request)
  File "/.../lib/python3.4/site-packages/pyramid/tweens.py", line 46, in excview_tween
    response = view_callable(exc, request)
  File "/.../lib/python3.4/site-packages/pyramid/config/views.py", line 385, in viewresult_to_response
    result = view(context, request)
  File "/.../lib/python3.4/site-packages/pyramid/tweens.py", line 21, in excview_tween
    response = handler(request)
  File "/.../lib/python3.4/site-packages/pyramid_tm/__init__.py", line 92, in tm_tween
    reraise(*exc_info)
  File "/.../lib/python3.4/site-packages/pyramid_tm/compat.py", line 13, in reraise
    raise value
  File "/.../lib/python3.4/site-packages/pyramid_tm/__init__.py", line 73, in tm_tween
    response = handler(request)
  File "/.../lib/python3.4/site-packages/pyramid/router.py", line 163, in handle_request
    response = view_callable(context, request)
  File "/.../lib/python3.4/site-packages/pyramid/config/views.py", line 596, in __call__
    return view(context, request)
  File "/.../lib/python3.4/site-packages/pyramid/config/views.py", line 329, in attr_view
    return view(context, request)
  File "/.../lib/python3.4/site-packages/pyramid/config/views.py", line 305, in predicate_wrapper
    return view(context, request)
  File "/.../lib/python3.4/site-packages/pyramid/config/views.py", line 355, in rendered_view
    result = view(context, request)
  File "/.../lib/python3.4/site-packages/pyramid/config/views.py", line 501, in _requestonly_view
    response = view(request)
  File "/.../lib/python3.4/site-packages/cornice/service.py", line 549, in wrapper
    validate_colander_schema(args['schema'], request)
  File "/.../lib/python3.4/site-packages/cornice/schemas.py", line 166, in validate_colander_schema
    _validate_fields('body', body)
  File "/.../lib/python3.4/site-packages/cornice/schemas.py", line 143, in _validate_fields
    deserialized = attr.deserialize(serialized)
  File "/.../lib/python3.4/site-packages/colander/__init__.py", line 1921, in deserialize
    appstruct = self.typ.deserialize(self, cstruct)
TypeError: deserialize() missing 1 required positional argument: 'cstruct'

@tseaver
Copy link
Member

tseaver commented Jun 20, 2015

I cannot see any way to provoke the first traceback with the schema types included in colander. Perhaps there is a type defined in cornice whose unflatten() takes an extra positional parameter?

@jenstroeger
Copy link
Contributor Author

I've used my own schema=AddSingleFileSchema with

class AddSingleFileSchema(colander.MappingSchema):                              
    filename = colander.SchemaNode(colander.String)                             
    filetype = colander.SchemaNode(                                             
        colander.String(),                                                      
        validator=colander.OneOf(['doc', 'text']),  
        )                                                                       

And depending on the request I send I can provoke different failures.

@mmerickel
Copy link
Member

What do you mean "I can provoke different failures"?

Can you provide a small code snippet showing this failing? For example schema, data = ...; schema.unflatten(data) # -> exception.

@doko123
Copy link

doko123 commented Feb 5, 2018

filename = colander.SchemaNode(colander.String()) - you should use brackets here
was: filename = colander.SchemaNode(colander.String)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants