Open djay opened 8 years ago
Sorry I haven't told, but I have implemented it last week (I named it on_display instead of on_open), see https://github.com/plomino/rapido.core/commit/2f88bf52ee97583050eec01801b243c37aecfbed (If it matches your needs, just close the issue).
Cool!. I think it would be good to consider some of the other ideas as well. Like controling the record and being able to insert things into the context and template.
It does it already:
context.thing = "something"
and elemnst can access ittal:content="context/something"
context.my_current_record=context.app.get_record('person1')
Test it a little bit, if you think there is something missing, tell me.
@ebrehault working on a patch now to show my ideas. The idea is instead of just on display it gets called on request and first. In the simplest case you can have no elements or template, just a single function called on_init or on_open or similar.
def on_init(context):
# tuple or list lets you create a simple response
return ("text/xml","<mycustom>response</mycustom")
or it will accept a zope response
def on_init(context):
return context.request.response
or a file
def on_init(context):
return StringIO("stream my response")
to it consistent with actions I think returning a string should redirect.
def on_init(context):
return "./myotherblock"
but if its a dict (or None) it will look the template and use that.
def on_init(context):
return dict(element1="blah", element2="something else")
and these can be used directly in a zpt (no more elements dict)
<html><body>${element1}</body></html>
These would be combined with any defined elements. The dict items returned from on_init would take precedence.
Anything else returned from on_init would give an error.
User problem
Currently a block works like this.
There are a range of issues with this
History
pyramid
Handles this by making making the python callable always the first thing called. It then produces a dict and that gets passed to the a template. but alternatively you can return whatever you want.
plone browserviews
These are classes that have an init method that always gets called with context and request. There is also the call method you can override.
Options
controller function
Make it such that you can have controller function that can direct or return custom content without the need of templates or elements.
or
or it will accept a zope response
or a file
If you want to redirect then do
but if its a dict (or None) it will look the template and use that.
and these can be used directly in a zpt (no more using ${elements/element1})