url() method on JSON component

View: New views
4 Messages — Rating Filter:   Alert me  

url() method on JSON component

by Jan-Wijbrand Kolman-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Martijn recently issued:

   https://bugs.launchpad.net/grok/+bug/463469

Coincidentally, the issue came in at exactly the moment I was looking
for the url() method on the JSON components I was writing myself...


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.

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.

What do you think?


I can work on this more or less soon.

regards,
jw

_______________________________________________
Grok-dev mailing list
Grok-dev@...
https://mail.zope.org/mailman/listinfo/grok-dev

Re: url() method on JSON component

by Martijn Faassen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey,

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.

Regards,

Martijn

_______________________________________________
Grok-dev mailing list
Grok-dev@...
https://mail.zope.org/mailman/listinfo/grok-dev

Re: url() method on JSON component

by Jan-Wijbrand Kolman-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

_______________________________________________
Grok-dev mailing list
Grok-dev@...
https://mail.zope.org/mailman/listinfo/grok-dev

Re: url() method on JSON component

by Jan-Wijbrand Kolman-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jan-Wijbrand Kolman wrote:
> Now, what do I call these mixins?

I chose "ViewSupport". Is has been merged just now with the grok trunk
(and grokcore.view-1.13 and grokcore.view trunk). grokcore.view-1.13a2
has been released.

JSON, REST and XMLRPC components now gained url() and application_url()
methods and response and body properties.

regards,
jw

_______________________________________________
Grok-dev mailing list
Grok-dev@...
https://mail.zope.org/mailman/listinfo/grok-dev