This is valid Python code.
table and rec_id are defined in the on_delete function arguments (it's the
function used in the ondelete argument of a grid).
def on_delete(table: pydal.objects.Table, rec_id: str):
row is the variable name.
pydal.objects.Row is the variable type.
I'm using Python 3.7.1 and using Python typing.
What I'm doing is reading a single record passed by the grid's ondelete.
pydal is not auto imported by web2py when the function is defined, but it
is auto imported by web2py when the function runs, because If I remove the
typing from the function header, but keep the typing from the function
body, everything works.
My question is if this is web2py correct behavior (pydal is not auto
imported by web2py when the function is defined, but it is auto imported by
web2py when the function runs).
segunda-feira, 18 de Março de 2019 às 02:42:09 UTC, Massimo Di Pierro
escreveu:
>
> I do not understand. this:
>
> row: pydal.objects.Row = table[rec_id]
>
>
> is not a valid Python code. Also, as you say pydal is not imported.
> Moreover Row is an internal class, you should not try redefine it.
> Can you explain what you are trying to achieve? Maybe there is a better
> way.
>
> On Friday, 8 March 2019 09:12:21 UTC-8, João Matos wrote:
>>
>> Didn't know that, will correct auth.requires_login with auth.is_logged_in.
>>
>> No I did not import pydal.
>>
>> If I remove the type specification from the function header it works,
>> even when I'm also mentioning pydal inside the function in the line
>>
>> row: pydal.objects.Row = table[rec_id]
>> which means pydal is imported by web2py.
>>
>>
>>
>>
>> sexta-feira, 8 de Março de 2019 às 17:06:38 UTC, Leonel Câmara escreveu:
>>>
>>> Note that requires_login is meant to be used as a decorator, you should
>>> be using auth.is_logged_in()
>>>
>>> Did you import pydal?
>>>
>>
--
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].
For more options, visit https://groups.google.com/d/optout.