Hi Sam,
I ran into this same problem. The easy way to fix it was to use the
decorator module to preserve method signature. If you look at some of
the builtin decorators with Pylons like @jsonify and @validate, this
is how they do it - check pylons/decorators/__init__.py.
Here is jsonify with decorator applied after function definition.
from decorator import decorator
def jsonify(func, *args, **kwargs):
"""Action decorator that formats output for JSON
Given a function that will return content, this decorator will
turn the result into JSON, with a content-type of 'text/
javascript'
and output it.
"""
pylons.response.headers['Content-Type'] = 'text/javascript'
data = func(*args, **kwargs)
if isinstance(data, list):
msg = "JSON responses with Array envelopes are susceptible to
" \
"cross-site data leak attacks, see " \
"http://pylonshq.com/warnings/JSONArray"
warnings.warn(msg, Warning, 2)
log.warning(msg)
log.debug("Returning JSON wrapped action output")
return simplejson.dumps(data)
jsonify = decorator(jsonify)
On Feb 17, 1:33 pm, SamDonaldson <[EMAIL PROTECTED]> wrote:
> Hello,
>
> My pylons actions are setup such that a decorator passes in the *args,
> **kw request params coming from the user. The problem is when
> spurious args are passed in. I get an AttributeError exception since
> the signature of these actions don't take some of those arguments.
> How do I make is so that I can take care of this case without having
> to pass **kw to every action signature sort of like a catch-all. Is
> there a way to get details on the python function about to get called
> and to modify the arguments to only pass those that correspond to the
> signature?
>
> Thanks,
>
> Sam.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---