Re: [web2py] Re: Rows class constructor question

2019-05-21 Thread Eliezer (Vlad) Tseytkin
Got it,
Thank you very much!

On Tue, May 21, 2019, 2:09 PM Leonel Câmara  wrote:

> It basically has to do with python namespaces. You did not import Rows
> into your current namespace. The definition is there in the context where
> the select rows were created but in your namespace you could have another
> Rows definition that is quite different or none at all. Web2py imports a
> lot of stuff automatically so I can see how that can create confusion when
> something isn't automatically available but that's just the way regular
> python works.
>
>
> https://code.tutsplus.com/tutorials/what-are-python-namespaces-and-why-are-they-needed--cms-28598
>
> --
> 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/C31RurYvstc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/4155af72-1560-4c72-8567-1481329b6e4a%40googlegroups.com
> 
> .
> 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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CABZ%2BKCBnVEh%2BonWcFKVaMLrXjwG87KmuxZAgkpd1oYOnGH7C7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Rows class constructor question

2019-05-21 Thread Leonel Câmara
It basically has to do with python namespaces. You did not import Rows into 
your current namespace. The definition is there in the context where the 
select rows were created but in your namespace you could have another Rows 
definition that is quite different or none at all. Web2py imports a lot of 
stuff automatically so I can see how that can create confusion when 
something isn't automatically available but that's just the way regular 
python works.

https://code.tutsplus.com/tutorials/what-are-python-namespaces-and-why-are-they-needed--cms-28598

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/4155af72-1560-4c72-8567-1481329b6e4a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Rows class constructor question

2019-05-21 Thread Vlad
Yeah, I am just trying to understand why it doesn't work without explicit 
import. Missing basics here:
if rows=db.select() works and rows is known to be an instance of the class 
Rows, and Rows is recognized as a class and can be used to some extent 
(obviously, I am using it already, in rows=db.select() and beyond, without 
importing explicitly), what does it mean then that I can't use it? I mean, 
it's either visible or invisible. If it's already visible as a specific 
class, without being imported, why are its methods still invisible and 
require explicit import statement? I am suspecting that I am missing 
something very basic about namespaces. Earlier Leonel explained it, but I 
didn't understand the explanation. 

On Tuesday, May 21, 2019 at 11:52:23 AM UTC-4, villas wrote:
>
> rows = pydal.objects.Rows()
>
>
> On Tuesday, 21 May 2019 04:14:45 UTC+1, Vlad wrote:
>>
>> I must be missing something very basic here... 
>>
>> Want to create an empty Rows object, and then to append to it sets of 
>> rows from various sql queries with the same structure of the result sets. 
>>
>> The first line in the code (in a controller) is
>>  rows = Rows()
>> with an intention of creating an empty Rows object. 
>>
>> This gives an error:  name 'Rows' is not defined
>>
>> Why is that? Why can't I create an empty Rows object? 
>>
>>
>>
>>

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/8101cfd8-6754-44f2-9345-f89c076b6936%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Rows class constructor question

2019-05-21 Thread villas
rows = pydal.objects.Rows()


On Tuesday, 21 May 2019 04:14:45 UTC+1, Vlad wrote:
>
> I must be missing something very basic here... 
>
> Want to create an empty Rows object, and then to append to it sets of rows 
> from various sql queries with the same structure of the result sets. 
>
> The first line in the code (in a controller) is
>  rows = Rows()
> with an intention of creating an empty Rows object. 
>
> This gives an error:  name 'Rows' is not defined
>
> Why is that? Why can't I create an empty Rows object? 
>
>
>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/0be8456d-3d39-4929-98e1-0751a4bb7c74%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Rows class constructor question

2019-05-21 Thread Vlad
Leonel,
in your example, if "import peartree" doesn't bring in Pear (and thus Pear 
needs to be imported explicitly) - then... How is Pear accessible at all? I 
mean, if Pear is not accessible - then what's the difference between direct 
usage and indirect usage? I guess I am missing something basic on how 
namespaces work, but it seems straightforward to me: if rows=db.select() 
works and rows is known to be an instance of the class Rows, and Rows is 
recognized as a class and can be used, just... not directly??? I mean, it 
should be either visible or invisible, and if it's visible - everything 
about it is visible, and if it's invisible - everything about it should be 
invisible... So, how can it be that it's visible and recognized as a class, 
yet the details of this class are hidden - so it can be used partially but 
not fully?? I am mystified.  
Thank you for your patience :) 

On Tuesday, May 21, 2019 at 9:22:53 AM UTC-4, Leonel Câmara wrote:
>
> If you have a module called peartree.py which has only this
>
> class Pear:
> pass
>
>
> def shake():
> return Pear()
>
>
> If in another module you do:
>
> import peartree
>
>
> mypear = peartree.shake()
>
>
> mypear will be an instance of Pear, however Pear is not defined in this 
> context and you cannot use the class directly without going through the 
> peartree namespace. 
>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/646b59a4-a583-4850-9d08-e091120cc274%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Rows class constructor question

2019-05-21 Thread Leonel Câmara
If you have a module called peartree.py which has only this

class Pear:
pass


def shake():
return Pear()


If in another module you do:

import peartree


mypear = peartree.shake()


mypear will be an instance of Pear, however Pear is not defined in this 
context and you cannot use the class directly without going through the 
peartree namespace. 

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/b0b754cf-b87a-4b8c-9885-d4fc674fb9f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Rows class constructor question

2019-05-21 Thread Eliezer (Vlad) Tseytkin
Oops, I thought that if DAL is used extensively and all works already, all
the proper classes are already imported by the environment (otherwise how
can I run queries and do other db-related stuff without importing those
classes explicitly??) How can rows=db.select work and return 'rows', which
is an instance of the class Rows, if the class Rows is not imported and
thus not defined?? What am I missing?


On Tue, May 21, 2019, 8:31 AM Leonel Câmara  wrote:

> You need to import Rows from pydal.objects
>
> --
> 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/C31RurYvstc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/6ea3bcf5-d419-453d-8a5d-837af3d661f9%40googlegroups.com
> 
> .
> 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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CABZ%2BKCD3WHacUFg2ug1z8DGTvmJiA2PD-QvvFXBPy9KWhn%2B3jA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Rows class constructor question

2019-05-21 Thread Leonel Câmara
You need to import Rows from pydal.objects

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/6ea3bcf5-d419-453d-8a5d-837af3d661f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.