[Grok-dev] what grok.JSON methods to publish?
Jan-Jaap Driessen
jdriessen at thehealthagency.com
Fri Jan 4 10:51:02 EST 2008
Some details where lost in writing my last email:
> The __*__ methods of grok.JSON classes are registered as views.
A solution, similar to RESTGrokker and XMLRPCGrokker, is to ignore
names with leading double underscores.
The RESTGrokker and XMLRPCGrokker have the following comment:
# XXX We should really not make __FOO__ methods available to
# the outside -- need to discuss how to restrict such things.
Is the solution suggested by Brandon applicable for REST and XMLRPC?
On Jan 4, 2008, at 4:11 PM, Brandon Craig Rhodes wrote:
> 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.
>
> +1 !
>
>> * Abstain from publishing methods altogether, but have each json
>> call have it's own class, similar to grok.View. This requires an API
>> change.
>
> Ugh. -1.
>
> --
> Brandon Craig Rhodes brandon at rhodesmill.org http://rhodesmill.org/brandon
More information about the Grok-dev
mailing list