[Grok-dev] url() method on JSON component
Jan-Wijbrand Kolman
janwijbrand at gmail.com
Wed Nov 25 05:36:32 EST 2009
Martijn Faassen wrote:
> Jan-Wijbrand Kolman wrote:
>
>> Proposal:
>>
>> Not only the url() method is useful for JSON (and maybe even the REST)
>> components, but so are the application_url() method and the response
>> property.
>
> I think certainly we need them for the REST components too. It's very
> common one wants to generate a URL when writing a RESTful protocol.
>
>> The url() method and the response property is defined in
>> grokcore.view.View. We could split out these into a seperate baseclass.
>> grokcore.view.View will then inherit from this baseclass.
>>
>> In grok we will define a mixin class derived from this baseclass that
>> adds the application_url() method. The JSON and REST components can then
>> inherit from this mixin class.
>
> Sounds reasonable. We practically have that mixin class already in the
> form of components.View in grok. The only differences are that it's a
> mixin and doesn't have the flash() method.
Short (oh no, bikeshed alert..!) naming question:
I'm about to checkin some changes in grokcore.view and grok that will:
1) split off the response property and the url() and the redirect()
methods from grokcore.view.View into a separate "mixin" class.
2) split off the application_url() method from grok.component.View into
a separate "mixin" class.
That way JSON and XMLRPC and REST components can inherit from these
mixins and thus gain all the mentioned methods.
Now, what do I call these mixins?
So far I came up with "ViewCommonMixin" for the first. Ugh. And
ApplicationCommonMixin. Ugh Ugh. Anyone a better idea?
regards,
jw
More information about the Grok-dev
mailing list