#pretty decorator
def with_email_to(addr):
def inner(f):
def emailer():
ret = f()
html = response.render(ret)
... # send html to addr by email
return html
return emailer
return inner
@with_email_to('[email protected]')
def foo():
...
On Thursday, June 20, 2019 at 8:39:45 PM UTC+3, Val K wrote:
>
> I mean the following logic:
> def foo():
> ...
> ret = dict(...)
> if email_required:
> html = response.render(ret)
> ... # send html by email
> return html
> return ret
>
>
>
> On Thursday, June 20, 2019 at 8:26:33 PM UTC+3, Vlad wrote:
>>
>> I couldn't figure out how this woks, so just rendered it again. Not a big
>> deal - just a matter of convenience. The email requests come occasionally,
>> so this extra render doesn't cause trouble.
>>
>> Thank you, Val!
>>
>> On Thursday, June 20, 2019 at 6:23:55 AM UTC-4, Val K wrote:
>>>
>>> I think you can try to yield rendered view from controller just by
>>> 'return rendered_response'. If controller returns string (not dict) it will
>>> be sent as is
>>>
>>
On Thursday, June 20, 2019 at 8:48:58 PM UTC+3, Vlad wrote:
>
> oops
> got it!
> changing it right now!
> simple and brilliant, as always :)
>
> On Thu, Jun 20, 2019 at 1:39 PM Val K <[email protected] <javascript:>>
> wrote:
>
>> I mean the following logic:
>> def foo():
>> ...
>> ret = dict(...)
>> if email_required:
>> html = response.render(ret)
>> ... # send html by email
>> return html
>> return ret
>>
>>
>>
>> On Thursday, June 20, 2019 at 8:26:33 PM UTC+3, Vlad wrote:
>>>
>>> I couldn't figure out how this woks, so just rendered it again. Not a
>>> big deal - just a matter of convenience. The email requests come
>>> occasionally, so this extra render doesn't cause trouble.
>>>
>>> Thank you, Val!
>>>
>>> On Thursday, June 20, 2019 at 6:23:55 AM UTC-4, Val K wrote:
>>>>
>>>> I think you can try to yield rendered view from controller just by
>>>> 'return rendered_response'. If controller returns string (not dict) it
>>>> will
>>>> be sent as is
>>>>
>>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/web2py/kb42uKUVs6E/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected] <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/web2py/da397328-7304-49f7-a6a6-c9588f54d8ba%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/web2py/da397328-7304-49f7-a6a6-c9588f54d8ba%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/833e8180-b48e-44de-80db-78e91a15a4a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.