[Grok-dev] what grok.JSON methods to publish?
Brandon Craig Rhodes
brandon at rhodesmill.org
Fri Jan 4 10:11:27 EST 2008
Jan-Jaap Driessen <jdriessen at thehealthagency.com> writes:
> My original goal was to find a way to exclude particular methods (of
> my class deriving from grok.JSON) from being published. Here are
> some ideas:
> * Ignore methods that start with one or more underscore. This sounds
> very pythonic (PEP8), but maybe we want something more explicit:
> * We could use a decorator to indicate a (non-)publishable method.
I find the Pythonic-ness of hiding underscore functions compelling.
There would need to be two decorators, something like "@grok.publish"
and "@grok.hide", so that people could be completely explicit if they
wanted to be; but, otherwise, auto-hiding underscore functions and
auto-publishing all others seems a completely winning strategy - a
perfect application of the principle of convention-over-configuration
with a configuration-way-out if one needs to make an exception.
> * Abstain from publishing methods altogether, but have each json
> call have it's own class, similar to grok.View. This requires an API
Brandon Craig Rhodes brandon at rhodesmill.org http://rhodesmill.org/brandon
More information about the Grok-dev