I honestly do not know. I do not think this is a web2py specific issue.
Definitively pydal is already imported but the name is not defined in the
controller's scope. Do not know how the interpreter handles the type
annotation or where it looks them up.
On Sunday, 24 March 2019 12:17:41 UTC-7,
import pydal is required so that the function on_delete definition
with the pydal.objects.Table typing doesn't return an error.
This normal Python behavior.
But because I was assuming that web2py would import pydal automatically, I
detected that the import pydal isn't needed for the
Can you please post a minimalist project that produces the error you are
seeing?
On Friday, 15 March 2019 03:55:24 UTC-7, João Matos wrote:
>
> Apparently when importing the module, pydal is not loaded, but when
> running the function it is.
> Is this the correct behavior of web2py?
>
>
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
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
Apparently when importing the module, pydal is not loaded, but when running
the function it is.
Is this the correct behavior of web2py?
sexta-feira, 8 de Março de 2019 às 18:39:36 UTC, João Matos escreveu:
>
> I'm using Python 3.7.1. Can that explain this strange situation?
> I'm calling web2py
I'm using Python 3.7.1. Can that explain this strange situation?
I'm calling web2py with the -e command line option to see the errors and
there are none.
sexta-feira, 8 de Março de 2019 às 18:30:48 UTC, Leonel Câmara escreveu:
>
> web2py doesn't do that. This is weird. Both those lines should
web2py doesn't do that. This is weird. Both those lines should give you
errors.
--
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
Just for testing, I removed pydal.objects.Table from the function header
and changed the line inside the function from
row: pydal.objects.Row = table[rec_id]
to
row: pydal.objects.Table = table[rec_id]
without importing anything from pydal or pydal.objects, anywhere in
controllers, models or
No, I don't import pydal.objects.Row anywhere in my modules, controllers
even in models.
sexta-feira, 8 de Março de 2019 às 17:40:41 UTC, Leonel Câmara escreveu:
>
> Weird because that doesn't work for me if I don't import pydal so I'm
> guessing you have a import pydal.objects.Row somewhere
Weird because that doesn't work for me if I don't import pydal so I'm
guessing you have a import pydal.objects.Row somewhere in your models. That
said you can just use DAL.Table and DAL.Row which are imports web2py does
make for you.
--
Resources:
- http://web2py.com
- http://web2py.com/book
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
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
13 matches
Mail list logo