[web2py] grid reloading the page and outdated flash msgs? (strange behavior...)

2018-12-27 Thread Vlad
Here is a test function in my controller: 

def test():
id = 0
try:
id = request.args(0, cast=int)
session.flash = "Here is the id: " + str(id)
except:
session.flash = "ID is not valid!"
pass
if id==0:
redirect(URL('home'))
query = db.test_table.id == id
grid = SQLFORM.grid(query, db.test_table, user_signature=False)
return locals()

Here are issues I've encountered with this (not sure if they are 
independent or related): 

1) the flash msg displays the previously passed parameters, not the latest 
one. This is weird! For example, app/home/test/1 called the first time does 
NOT display any flash msg at all.  When I call it the 2nd time - 
app/home/test/2 - the flash message displays "1", i.e. previously called 
number. At the same time, the page displays correctly - the page knows that 
the correct number is 2 indeed now. 

2) The grid behaves very strangely. Here is how: when I delete a record, 
the page silently reloads (I know this because of the flash message - which 
displays the previous id, not the current one), and in case this is my 
first call to this page, it comes out that ID is not valid and id equals 0 
EVEN THOUGH I passed the parameter through vars (app/home/test/1) it breaks 
the delete - delete never commits to the database. It does delete the row 
from the grid thought, so visually the row is gone, but the database is not 
altered. At the same time, if I remove that redirect('home') - the delete 
completes and commits to the database just fine (i.e. as long as redirect 
is not there - even though this strange reloading of the page is going on - 
it doesn't bother me - the messed up parameter only causes redirect which 
somehow breaks the delete). 

Namely, the following code (same but without redirect): 

def test():
id = 0
try:
id = request.args(0, cast=int)
session.flash = "Here is the id: " + str(id)
except:
session.flash = "ID is not valid!"
pass
query = db.test_table.id == id
grid = SQLFORM.grid(query, db.test_table, user_signature=False)
return locals()

still doesn't display flash msgs correctly, BUT it does not break grid's 
functionality - delete completes (can't fathom how this could be, as if 
request.var is incorrect - then the page should display incorrectly, but if 
request.var is somehow correct then redirect should never happen to begin 
with, how can it influence anything? And if redirect is actually called 
(and it is) on grid's delete operation, it means that the id is now 
incorrect, why doesn't it break the view of the page?? I am totally 
confused...

I hope this doesn't sound messy :) I've been going crazy for a while until 
I've isolated what I've just described... 

And, by the way, the app logic I am trying to achieve is simple: I pass the 
param through request.vars but then first check if the current user is 
authorized, and if not - I redirect. I need some custom authorization logic 
here, so usual auth decorates don't help in my situation.

3) this is more of a side issues, but I'll mention it, as I am on the grid: 
in some situations grids work just fine without user_signature=False , but 
sometimes they refuse and display error msgs like not authorized etc. I 
can't detect the difference when it's needed. This is not a big deal, I can 
just place user_signature=False whenever, but it does bother me, since I 
don't understand what exactly is causing this difference that breaks the 
functionality in some situations. 

Any suggestions are greatly appreciated 
 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] multiple grids per one page

2018-12-31 Thread Vlad
I just came across a warning that only one grid can be used per a 
controller. 

I wasn't aware of this before, and on one page I have 4 grids which work 
perfectly fine. 

Is it some specific functionality that doesn't work right with multiple 
grids? 

Also, if I specify a unique name (formname parameter?) - does this fix the 
problem or the problem is bigger than that? 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] an error while trying to combine an inner and outer joins

2018-12-28 Thread Vlad
I am taking the table cofounder and making an inner join with auth_user and 
an outer join with cofounder_proposal: 

cofounders = 
db((db.cofounder.company==company_id)&(db.cofounder.created_by==auth.user)).select(
fields=[db.auth_user.first_name.with_alias('first_name'), 
db.auth_user.last_name.with_alias('last_name'), 
db.cofounder.note, 
db.cofounder_proposal.status.with_alias('status')], 
join=db.auth_user.on(db.cofounder.cofounder==db.auth_user.id),

left=db.cofounder_proposal.on(db.cofounder_proposal.cofounder==db.cofounder.cofounder))

It gives me an error: 
 _select_wcols() got multiple values for argument 
'fields'

I can't figure it out, as I am really deining fields just once - it's not 
specified otherwise anywhere. 

Any ideas?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] "... records found' on the default grid

2018-12-27 Thread Vlad
What would be the best way to get rid of "5 records found" on the upper 
right corner of the default grid view? 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] @auth.requires_signature() vs @auth.requires_login()

2018-12-27 Thread Vlad
I generally understand how to use both, @auth.requires_signature() 
and @auth.requires_login(),
but from a practical point of view, when in real life would you prefer to 
use one vs. another? 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] ajax controller loses formatting?

2019-01-02 Thread Vlad
I am sure I am missing something very basic here, but... googling didn't 
help...

When I have a contoller which I use in ajax calls, it all works just 
perfect except that the view loses the formatting (for example, it does 
keep the links and bullets - yet loses bootstrap formatting of everything). 
I don't understand why this happens and how to fix it. After all the view 
extends layout.html which does include everything, so why would it make a 
difference if html code is direct on the page or embedded via ajax? 

For example: the following 2 controllers via ajax produce exactly same 
non-formatted html:

def test1():
return XML("Home\
   #M1M2M3")

def test2():
return XML("Home\
   M1M2M3")

In fact, even without ajax, when I allow these controllers to go through 
default views (i.e. without having a dedicated view) - this is exactly what 
happens too, but here I sort of understand it - while in a case of ajax I 
don't, because ajax is embedded into real view html and should really 
pickup all the appropriate formatting which works well on the rest the 
page. 

What am I missing? How do I fix this?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] web2py apps & github

2019-01-06 Thread Vlad
I used to pack and unpack the app between my local computer and 
pythonanywhere - was going back and forth daily. worked like a charm. 
now got t github.
Should I place the whole application/ folder in its entirety or I 
should skip some files? 
I am not sure how pack / unpack does it, i.e. if it packs everything or 
skips some computer specific content. 
I am just afraid if I blindly copy ALL the files in the applications, 
I may overwrite something that shouldn't be overwritten. 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: web2py apps & github

2019-01-16 Thread Vlad
Dave, 
you mentioned "Sanitize private/appconfig.ini" - could you please comment 
on it - 
I am not sure how this file is used by web2py, but seems that it may have 
some private info (though has some generics for me now). 
Should I just exclude it from git? Is it getting recreated by w2p or... 
What did you mean by "sanitize" in this case?

On Monday, January 7, 2019 at 7:21:55 PM UTC-5, Dave S wrote:
>
>
>
> On Sunday, January 6, 2019 at 12:45:27 PM UTC-8, Vlad wrote:
>>
>> Oh, I didn't express myself precisely: I am asking about Github - I am 
>> setting up a Github repository and wondering what exactly from the app 
>> directory should go in there - without extra files and without missing 
>> files  - to preserve complete app/set
>>
>>
> You don't want the sessions or errors folders (they'll get recreated by 
> web2py if missing, and should be cleaned out from time to time anyway).  
> You may choose to also skip the databases folder, as the table files are 
> recreated from the models.  IIRC, you're using an external database server 
> rather than sqlite3, so you have other ways of backing up the data (I 
> wouldn't backup sqlite3 to github, either).  If you have uploads, you 
> should probably back them up separately, as well.
>
> You should have all .py files, from your myapp toplevel as well as 
> controllers, models, modules, and scripts, and then your files from static 
> and views, and languages if you've updated that.  Sanitize 
> private/appconfig.ini and save is as private/sample-appconfig.ini (keep an 
> indication of how to reach your db).
>
> /dps
>
>  
>
>> On Sun, Jan 6, 2019 at 2:51 PM 黄祥  wrote:
>>
>>> for pack or unpack thing it's use tar
>>> ref:
>>> https://groups.google.com/d/msg/web2py/khiGuJYxHpo/clEEU7n3VGEJ
>>>
>>> best regards,
>>> stifan
>>>
>>> -- 
>>> 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+un...@googlegroups.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.
For more options, visit https://groups.google.com/d/optout.


[web2py] web2py dev env on chromebook?

2019-01-16 Thread Vlad
If anybody has succeeded in setting up the dev env on chromebook I would 
greatly appreciate some pointers. 
I was able to get into dev mode and install linux on it, so linux is sort 
of functional, but it's not complete. There is probably something specific 
about chromebook, but I didn't find anything by googling it. 
I simply want to have local web2py dev env on it... (My regular env is 
windows; I am not too proficient in linux - if it works I can handle it, 
but if something gets stuck, I don't know how to handle it)

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] installing web2py book from git

2019-01-19 Thread Vlad
I've cloned webpy book from git - 
looks perfectly fine - it created directory web2py-book under applications, 
with all the content, just like a few other applications over there, 
*but* the web2py admin interface doesn't see this book as an app. It sees 
all other apps located in the applications directory, except for this one - 
what could be the reason? 
I don't see anything wrong - it cloned the repository and created all the 
folders properly, as far as I can tell. 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] installing web2py book from git

2019-01-20 Thread Vlad
Oh, I've tried - renamed into TheBook. It did appear under apps, yet it 
still doesn't work. Is it supposed to work??

default/index brings up a bunch of languages - the first one being English. 
Clicking on any of them refreshes the page with the URL now staing
"http://127.0.0.1:8000/TheBook/default/index?FLASH_MSG=%3Cclass+%27ImportError%27%3E;
without actually message flashing. 

I simply cloned the whole git repository in its current state. as per the 
instructions. How can I clone it in a way that it would bring up a working 
copy, simply the latest book that actually works as an app?? 


On Sunday, January 20, 2019 at 4:01:37 AM UTC-5, Nico Zanferrari wrote:
>
> Hi,
>
> I've already noticed this behaviour (also on other applications). It 
> happens if have an application's main folder name that contains 
> non-alphabetical characters, even simple ones like dot or dash
> For example, web2py-book  or examples.20190110  have this problem.
>
> Rename the folder to 'book' or 'example' and the problem disappear  ;-)
>
> Does someone have an idea of where this bug could be hidden in the code?
>
> Nico
>
> Il giorno dom 20 gen 2019 alle ore 03:52 Vlad  > ha scritto:
>
>> I've cloned webpy book from git - 
>> looks perfectly fine - it created directory web2py-book under 
>> applications, with all the content, just like a few other applications over 
>> there, 
>> *but* the web2py admin interface doesn't see this book as an app. It 
>> sees all other apps located in the applications directory, except for this 
>> one - 
>> what could be the reason? 
>> I don't see anything wrong - it cloned the repository and created all the 
>> folders properly, as far as I can tell. 
>>
>> -- 
>> 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+un...@googlegroups.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.
For more options, visit https://groups.google.com/d/optout.


[web2py] How can I customize "Not Authorized" page, the one that comes up on @requires_membership decorator?

2019-01-15 Thread Vlad
Not AuthorizedInsufficient privileges

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How can I customize "Not Authorized" page, the one that comes up on @requires_membership decorator?

2019-01-15 Thread Vlad
Dave, 
I am probably missing something, but it seems to me that those are 2 
different pages. 404 is just 404, while not authorized is another page 
displaying the text about insufficient privileges - and really it should be 
different. It's not that a resource is not found - it's just that a user is 
not authorized at the moment, but the resource is there - 
What am I missing?  

On Tuesday, January 15, 2019 at 11:56:57 AM UTC-5, Dave S wrote:
>
>
>
> On Tuesday, January 15, 2019 at 8:16:18 AM UTC-8, Vlad wrote:
>>
>> Not AuthorizedInsufficient privileges
>>
>
> This appears to already be customized!  In the default out-of-the-box 
> welcome app, 
> file:///[..]web2py/applications/MusicBDs/static/404.html 
> is just a very simple 3=4 characters: '404\n'.
>
> If you haven't customized that file, perhaps your front end is 
> substituting its own.
>
> /dps
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] default combobox for a db field in a form (SQLFORM) - question

2019-01-15 Thread Vlad
when I use SQLFORM to create a form where one of the fields is, for 
example, a user (db.auth_user) w2p gives me a nice combo-box to select a 
user. 
this is good, but only if there are few items. 
if there are thousands, the combo-box becomes awkward. 
does webpy have some convenient alternative for that combo-box in case the 
records are too many? 
I would love to get away without custom coding for this one - 
it's actually tricky to create such a widget... 
any suggestions are greatly appreciated... 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] installing web2py book from git

2019-01-21 Thread Vlad
How do I get the latest w2p??
I mean, I just cloned one from https://github.com/web2py/web2py.git and it 
still has the earlier one: 
2.17.2-stable+timestamp.2018.10.06.11.34.06


On Monday, January 21, 2019 at 12:30:31 AM UTC-5, Nico Zanferrari wrote:
>
> It indeed works fine... but you need a recent version of web2py (> 2.5.3 
> IIRC) for py2 compatibiĺity functions.
> I'm  working on an update for avoiding this specific error.
>
> Nico
>
> Il giorno Lun 21 Gen 2019, 01:00 黄祥 > 
> ha scritto:
>
>> tested also got same result, step
>> docker pull ubuntu
>> docker run -it ubuntu /bin/bash
>>
>> apt update
>> apt install -y git unzip wget python 
>> wget -c http://web2py.com/examples/static/web2py_src.zip
>> unzip -o web2py_src.zip
>> cd web2py/applications
>> git clone https://github.com/web2py/web2py-book books
>> python ../web2py.py --nogui --no-banner -a a -i 0.0.0.0 -p 8000
>>
>> *result:*
>>
>> http://localhost:8000/books/default/index?FLASH_MSG=%3Ctype+%27exceptions.ImportError%27%3E
>>
>> *tested:*
>> - git clone https://github.com/web2py/web2py-book
>> *result*
>> not appears in admin page http://localhost:8000/admin/default/site
>>
>> - check the error on web2py book application and under admin found 
>> nothing 
>>
>> best regards,
>> stifan
>>
>> -- 
>> 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+un...@googlegroups.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.
For more options, visit https://groups.google.com/d/optout.


[web2py] synchronizing / backing up my code between local web2py & PythonAnywhere web2py

2018-12-26 Thread Vlad
What do you guys generally do as far an syncing / backup? 

I mean, right now I am going back and forth local web2py <-> PythonAnywhere 
web2py

So it's tedious to keep track what the latest thing is - I pack up my app 
locally and upload it to PA, and then pack up on PA and upload to local. 

Are there some common solutions for this? I would definitely enjoy some 
kind of synchronization which would also take care of  both - sync and a 
backup for me - 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Issue (or perhaps just a question) with routes.py (root folder vs app folder)

2018-12-26 Thread Vlad
I've created routes.py in Web2py root folder: 

default_application = 'app5'
default_controller = 'home'
default_function = 'main'

this works just fine. 

However, if I only keep one line in this file: 

default_application = 'app5'

,and create one more routes.py in Web2py/applications/app5 folder, like 
this: 

default_controller = 'home'
default_function = 'main'

It only picks up the application in the root Web2py routes.py, and it 
totally ignores the routes in the application folder. 

What am I missing? 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Using Email from inside of Web2py

2018-12-26 Thread Vlad
I've figured out how this works, but I am missing the following: 

I have a mail_settings() function in the default controller. It's setting 
up my smtp settings and other redirect settings (auth.settings.login_next 
and the like). 

All works like a charm, but it seems that I have to call this function 
every single time - somehow the system resets the settings back to the 
defaults. 

I've found a solution by simply calling this function every time in the 
default/user(), so whenever it comes to signing up, login, lost password 
and the rest of functionality - it's working correctly, because the entry 
point - user() - is setting up right. 

I don't understand though why in the world I have to set all those settings 
up every time - why the system doesn't keep those settings if I call it 
just once.

What am I missing? 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] private functions

2019-01-03 Thread Vlad
Here is a quote from THE BOOK: "Functions that take arguments or start with 
a double underscore are not publicly exposed and can only be called by 
other functions."

What about functions that take an argument which has a default value 
specified (i.e. can be called without an argument)? Would that be private 
or public? 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Customizing detail view (grid)

2019-01-04 Thread Vlad
How would I customize a details view which is brought up by the grid when 
"view/detail" button is clicked when the grid has "details=True" parameter 
set?
(I just want to add more information there, but not straight from the table 
the grid is based on)

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Load / no ajax / custom div

2019-01-10 Thread Vlad
I am using Load function (ajax=False) which creates a div it's using to 
load the context in. 

Is there an easy way to specify this div to be of a certain class? (I want 
to add "d-flex" class to it, to use flex in the html/container I am loading)

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] login_after_registration doesn't work?

2019-01-11 Thread Vlad
I am probably missing something simple:

when I explicitly go to http://127.0.0.1:8000/app/default/user/register - I 
get auto-logged in after the registration. Same if I choose "register" on 
the menu.

However, when the following gets executed: 

auth.settings.login_after_registration = True
auth.settings.long_expiration = 3600*24*30
auth.settings.remember_me_form = True
redirect(URL('app', 'default/user', 'register'))

after such a registration I am not logged in, and have to login manually. 

What's the difference?? 
How do I make it auto-login after redirecting to registration? 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: login_after_registration doesn't work?

2019-01-13 Thread Vlad
Anthony, I got it, 
but in my case the default value was auth.settings.remember_me_form=True 
anyway , so my code could possibly not work (as per your explanation), but 
didn't have a chance to not work due to this reason :)
I found out what was going on: I had redirect in ajax error code block, 
i.e. I called async ajax, and after it was done and returned an error - 
redirect was in this error thing. This is exactly when the problem 
manifested. Interestingly, that even default value didn't help - I am 
wondering what could possibly be so messed up that defaults were not 
actionable due to ajax. 
Anyway, I had no reason for ajax altogether - it was a quick and simple 
call - so I replaced it with GET, and everything now works as expected. 
I still moved the settings to the other side, to make sure that they are 
not set up in an "old" request (it affected other settings, just not 
auth.settings.remember_me_form as it was setup correctly by default 
anyway). 

Thank you! 

On Friday, January 11, 2019 at 10:59:58 PM UTC-5, Anthony wrote:
>
> On Friday, January 11, 2019 at 11:44:27 AM UTC-5, Vlad wrote:
>>
>> I am probably missing something simple:
>>
>> when I explicitly go to http://127.0.0.1:8000/app/default/user/register 
>> - I get auto-logged in after the registration. Same if I choose "register" 
>> on the menu.
>>
>> However, when the following gets executed: 
>>
>> auth.settings.login_after_registration = True
>> auth.settings.long_expiration = 3600*24*30
>> auth.settings.remember_me_form = True
>> redirect(URL('app', 'default/user', 'register'))
>>
>> after such a registration I am not logged in, and have to login manually.
>>
>
> Keep in mind that your model and controller code runs on each request. 
> Above, you set several Auth settings but then immediately redirect, which 
> initiates a new request -- so those settings never get a chance to take 
> effect. You must make those settings within the same request that is 
> handling the registration.
>
> Anthony
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: web2py apps & github

2019-01-13 Thread Vlad
Got it, 
thank you very much.
Learning git now - it's so messy and unstructured as far as learning curve 
:) I guess once I get it, it becomes quick and easy... 

On Monday, January 7, 2019 at 7:21:55 PM UTC-5, Dave S wrote:
>
>
>
> On Sunday, January 6, 2019 at 12:45:27 PM UTC-8, Vlad wrote:
>>
>> Oh, I didn't express myself precisely: I am asking about Github - I am 
>> setting up a Github repository and wondering what exactly from the app 
>> directory should go in there - without extra files and without missing 
>> files  - to preserve complete app/set
>>
>>
> You don't want the sessions or errors folders (they'll get recreated by 
> web2py if missing, and should be cleaned out from time to time anyway).  
> You may choose to also skip the databases folder, as the table files are 
> recreated from the models.  IIRC, you're using an external database server 
> rather than sqlite3, so you have other ways of backing up the data (I 
> wouldn't backup sqlite3 to github, either).  If you have uploads, you 
> should probably back them up separately, as well.
>
> You should have all .py files, from your myapp toplevel as well as 
> controllers, models, modules, and scripts, and then your files from static 
> and views, and languages if you've updated that.  Sanitize 
> private/appconfig.ini and save is as private/sample-appconfig.ini (keep an 
> indication of how to reach your db).
>
> /dps
>
>  
>
>> On Sun, Jan 6, 2019 at 2:51 PM 黄祥  wrote:
>>
>>> for pack or unpack thing it's use tar
>>> ref:
>>> https://groups.google.com/d/msg/web2py/khiGuJYxHpo/clEEU7n3VGEJ
>>>
>>> best regards,
>>> stifan
>>>
>>> -- 
>>> 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+un...@googlegroups.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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: strange footer...

2019-01-13 Thread Vlad
it was a very silly thing in the end - 
I suspected cache issues, but I cleared it up, so...
But then I noticed "clean" option in web2py interface, and after cleaning 
up the problem disappeared. I guess web2py or whatever it is behind the 
curtain does cache things sort of unpredictably... Cost me a few hours of 
stress :) 

On Wednesday, January 9, 2019 at 1:09:58 PM UTC-5, Vlad wrote:
>
> I am observing very strange behavior of the footer in my project. 
>
> on my local computer it's prefect - sticks where it has to be. 
>
> Once I transfer it to PythonAnywhere - the footer looks like it "forgot" 
> what absolute positioning means. It's initially located on the bottom of 
> the screen, as if with "fixed" attribute, but then it moves freely and is 
> in the middle of the page (once I scroll). 
>
> On my local thing it behaves perfect - sticks to the bottom of viewport - 
> exactly as it must. 
>
> Any ideas on what could possibly cause this??? 
>
> I tried adding explicit css making it absolute with bottom 0 yet nothing 
> helps - it doesn't comply. Just moves around. 
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] strange footer...

2019-01-09 Thread Vlad
I am observing very strange behavior of the footer in my project. 

on my local computer it's prefect - sticks where it has to be. 

Once I transfer it to PythonAnywhere - the footer looks like it "forgot" 
what absolute positioning means. It's initially located on the bottom of 
the screen, as if with "fixed" attribute, but then it moves freely and is 
in the middle of the page (once I scroll). 

On my local thing it behaves perfect - sticks to the bottom of viewport - 
exactly as it must. 

Any ideas on what could possibly cause this??? 

I tried adding explicit css making it absolute with bottom 0 yet nothing 
helps - it doesn't comply. Just moves around. 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] responsive collapsible menu

2019-01-09 Thread Vlad
Web2py menu is a perfect responsive collapsible menu. 

I am looking at the code - all makes sense, but I don't understand one 
thing: 

Where in web2py is it triggered that a larger view would hide the toggle 
button and make the menu visible, while the smaller view would do just the 
opposite? 

I checked html, css files, but couldn't find it. 

I mean, it works just fine, I am trying to figure out why it works - where 
the code that sets up the visibility (I guess some mediaquery somewhere? - 
where?)

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: New International Telegram Support Group

2019-03-25 Thread Vlad
Joined!
Very nice & interactive - 
There is some beauty in messenger group interaction vs. traditionally 
organized groups...

On Tuesday, March 19, 2019 at 2:49:34 PM UTC-4, Ari Lion BR Sp wrote:
>
> Oh, Great 
>
> Now I see a new link to this group:
> https://t.me/web2py_world
>
>
> Great I joined.
> That's great that Leonel Camara also joined the group!
> Now we can be sure that no doubt we have will be unanswered :-)
>
>
> Thanks!
>
>
> Em terça-feira, 19 de março de 2019 12:26:09 UTC-3, Carlos Costa escreveu:
>>
>> we noticied this group has no administrator, so we are moving to a new 
>> one, here is the link https://t.me/joinchat/DYZrfBT-bIsVhwLZc1hG8Q
>>
>> Em terça-feira, 19 de março de 2019 12:14:17 UTC-3, Carlos Costa escreveu:
>>>
>>> We have had a good experience with the brazilian telegram group 
>>> dedicated to to support web2py users.
>>>
>>> But the english speaking group is not used at.
>>>
>>> Here is the link to join it: https://t.me/web2py_en
>>>
>>> Also, here is the link to the Brazilian group (portuguese speaking and 
>>> some portunhol allowed too :D ): https://t.me/web2pybrasil
>>>
>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: error while reading browser cookies

2019-02-25 Thread Vlad
Never mind... 
It's the difference between Python 2 and Python 3. 
The books needs to be updated with the latest. 

On Monday, February 25, 2019 at 12:45:02 PM UTC-5, Vlad wrote:
>
> This is the first time I am trying to use the cookies. Following the 
> appropriate section in the book, here is the line:
>
> *if request.cookies.has_key('test_cookie'):*
> 
>
> it causes the following error: 
>
>  'SimpleCookie' object has no attribute 'has_key'
>
> what am I missing? 
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] error while reading browser cookies

2019-02-25 Thread Vlad
This is the first time I am trying to use the cookies. Following the 
appropriate section in the book, here is the line:

*if request.cookies.has_key('test_cookie'):*


it causes the following error: 

 'SimpleCookie' object has no attribute 'has_key'

what am I missing? 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] customizing submit button in SQLFORM() - works partially

2019-02-24 Thread Vlad
I have the following line in the controller:

form = SQLFORM(db.inquiry, submit_button = 'Explore').process()

the view has the following: 

   {{=form}}
   
   $('input:submit[value=Explore]').attr('style', "'width:400px; 
max-width:100%;'");
   $('input:submit[value=Explore]').attr('role', "'button'");
   $('input:submit[value=Explore]').append("");
   $('input:submit[value=Explore]').addClass('btn btn-light btn-lg 
btn-block');
   

so it works partially: the classes (the last line in the scrip) are added, 
so it displays a proper button. But everything else is not picked up - 

Any ideas on what's wrong / missing? 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] creating a db table doesn't actually create a table (sqllite)

2019-02-24 Thread Vlad
When I define a table in db.py - it's just fine. But if I create a new file 
- the admin interface picks it up, i.e. tells me that this model is 
creating the table, but the table is not actually created. What would cause 
such a difference?? It's really strange, as in other projects I define 
tables in various files, not in db, and it has never been a problem for me. 
I can't detect any difference - 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Using lambda in Field constructor for default

2019-03-15 Thread Vlad
I am missing something very simple here, but can't unstuck myself: 

This is what I want to have in the Field constructor (though it's obviously 
incorrect):

Field('link', default=lambda link, row: URL('podcast', 'episode/' + row.id, 
scheme=True, host=True))

I simply want one field to be determined by the other, in this case the 
constructed link field should depend on the id field. 

How do I accomplish this correctly? 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] A question about ajax function (passing a string parameter over)

2019-05-16 Thread Vlad
I have the following javascript in the view: 

var id = $('#CurrentCartId').text();
var description = $(this).text();
var url='{{=URL('cart','description')}}';
url += '/' + id + '/';
url += description;
ajax(url,[],':eval');

the reason I use url+= to pass parameters instead of using args in the URL 
helper is because the parameters are coming from the html itself - they are 
not known in the controller py. 

now the problem is that it changes the description and I have no way to 
recover its original value. for example, when description is "askjdf d  
 dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed string in 
this case), it comes out as "askjdf_d___dka_lskdj__3838_". Obviously, 
it needs to do this conversion in order to pass  the parameter, but I need 
to be able to recreate the original string, entered by the user. 

Is there a better way of doing this? I.e. a better way of passing a 
parameter in  a way that it could be "recreated" and stored in the database 
exactly as typed by the user? 

-- 
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/e763b31d-a8ef-494c-8b25-d4872cdcb130%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-16 Thread Vlad
Just to clarify: 

the following works perfect  for one field by ID (decrypts it back):
var encodedDescription = $("#CurrentCartDescription").text()
$("#CurrentCartDescription").html(atob(encodedDescription));

However, when I try to do it for a bunch of fields at once using class 
(instead of id), it doesn't work - doesn't touch the values: 
$(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));

I am sure I am missing something basic... Greatly appreciate suggestions - 

On Thursday, May 16, 2019 at 6:54:14 PM UTC-4, Vlad wrote:
>
> I had no clue about it - I mean never heard the terms :)
>
> Thank you very much for point to the direction. After some googling, it is 
> almost working. 
>
> Encoding is just fine (using btoa). 
>
> When I read it back and want to decode - it's not yet behaving right. I'm 
> suspecting my javascript is a problem. 
>
> There is a bunch of fields which now have encrypted values (class 
> 'EncodedDescriptionField'), and I am trying to use the following to reclaim 
> the original values: 
>
>
> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>
> What am I doing wrong? (It doesn't change the values - they remain as they 
> are, encrypted)
>
> On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:
>>
>> Have you considered base64 encoding/decoding?
>>
>> quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:
>>>
>>> I have the following javascript in the view: 
>>>
>>> var id = $('#CurrentCartId').text();
>>> var description = $(this).text();
>>> var url='{{=URL('cart','description')}}';
>>> url += '/' + id + '/';
>>> url += description;
>>> ajax(url,[],':eval');
>>>
>>> the reason I use url+= to pass parameters instead of using args in the 
>>> URL helper is because the parameters are coming from the html itself - they 
>>> are not known in the controller py. 
>>>
>>> now the problem is that it changes the description and I have no way to 
>>> recover its original value. for example, when description is "askjdf d  
>>>  dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed string in 
>>> this case), it comes out as "askjdf_d___dka_lskdj__3838_". Obviously, 
>>> it needs to do this conversion in order to pass  the parameter, but I need 
>>> to be able to recreate the original string, entered by the user. 
>>>
>>> Is there a better way of doing this? I.e. a better way of passing a 
>>> parameter in  a way that it could be "recreated" and stored in the database 
>>> exactly as typed by the user? 
>>>
>>

-- 
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/e0c0e6cd-a2cd-498a-9e42-89e6de9a3a4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-16 Thread Vlad
I had no clue about it - I mean never heard the terms :)

Thank you very much for point to the direction. After some googling, it is 
almost working. 

Encoding is just fine (using btoa). 

When I read it back and want to decode - it's not yet behaving right. I'm 
suspecting my javascript is a problem. 

There is a bunch of fields which now have encrypted values (class 
'EncodedDescriptionField'), and I am trying to use the following to reclaim 
the original values: 

$(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));

What am I doing wrong? (It doesn't change the values - they remain as they 
are, encrypted)

On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:
>
> Have you considered base64 encoding/decoding?
>
> quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:
>>
>> I have the following javascript in the view: 
>>
>> var id = $('#CurrentCartId').text();
>> var description = $(this).text();
>> var url='{{=URL('cart','description')}}';
>> url += '/' + id + '/';
>> url += description;
>> ajax(url,[],':eval');
>>
>> the reason I use url+= to pass parameters instead of using args in the 
>> URL helper is because the parameters are coming from the html itself - they 
>> are not known in the controller py. 
>>
>> now the problem is that it changes the description and I have no way to 
>> recover its original value. for example, when description is "askjdf d  
>>  dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed string in 
>> this case), it comes out as "askjdf_d___dka_lskdj__3838_". Obviously, 
>> it needs to do this conversion in order to pass  the parameter, but I need 
>> to be able to recreate the original string, entered by the user. 
>>
>> Is there a better way of doing this? I.e. a better way of passing a 
>> parameter in  a way that it could be "recreated" and stored in the database 
>> exactly as typed by the user? 
>>
>

-- 
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/1c716eaa-886a-4264-b80d-d51e035ecb55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] accessing a function in another controller

2019-05-15 Thread Vlad
this must be a very basic question; I just don't have full clarity on how 
web2py handles this: 

can code in one controller somehow access a function in another controller? 
Or I have to move such a function to model code? 

-- 
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/b9547ce4-1251-43fa-a3a8-17acd9dfad90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: updating menu without reloading the page

2019-05-15 Thread Vlad
I didn't say it precisely. By web2py controlling it I meant that it's 
dynamic and changes all the time - it's not static that I could assign 
certain id to some item... 

On Wednesday, May 15, 2019 at 7:55:26 PM UTC-4, Vlad wrote:
>
> Sometimes I need to change the menu without reloading the page. 
>
> More specifically: 
>
> response.menu = [
> .
> .
> ('Cart (' + str(howManyItemsInCart()) + ")", False, 
> URL('catalog','cart'), []),
> ]
>
> I do control the event when the cart content changes (without reloading 
> the page), so javascript can be inserted there; I just don't know how to 
> "address" that menu item, as I don't manage it - web2py does - 
>
> How would I accomplish this? ... 
>

-- 
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/a57beadc-8439-4895-ae5e-e563ed0ff1f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: updating menu without reloading the page

2019-05-15 Thread Vlad
Never mind,
Resolved...

On Wednesday, May 15, 2019 at 8:43:44 PM UTC-4, Vlad wrote:
>
> I didn't say it precisely. By web2py controlling it I meant that it's 
> dynamic and changes all the time - it's not static that I could assign 
> certain id to some item... 
>
> On Wednesday, May 15, 2019 at 7:55:26 PM UTC-4, Vlad wrote:
>>
>> Sometimes I need to change the menu without reloading the page. 
>>
>> More specifically: 
>>
>> response.menu = [
>> .
>> .
>> ('Cart (' + str(howManyItemsInCart()) + ")", False, 
>> URL('catalog','cart'), []),
>> ]
>>
>> I do control the event when the cart content changes (without reloading 
>> the page), so javascript can be inserted there; I just don't know how to 
>> "address" that menu item, as I don't manage it - web2py does - 
>>
>> How would I accomplish this? ... 
>>
>

-- 
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/b08609b3-fcbd-4087-8a04-ec588e274af4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] updating menu without reloading the page

2019-05-15 Thread Vlad
Sometimes I need to change the menu without reloading the page. 

More specifically: 

response.menu = [
.
.
('Cart (' + str(howManyItemsInCart()) + ")", False, 
URL('catalog','cart'), []),
]

I do control the event when the cart content changes (without reloading the 
page), so javascript can be inserted there; I just don't know how to 
"address" that menu item, as I don't manage it - web2py does - 

How would I accomplish this? ... 

-- 
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/30f443c1-1207-43af-b6ba-4f415851df9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Vlad
I thought so and tried: 

$(".EncodedDescriptionField").each( function(index, element ){
 var hereWeAre = $(this).text();
 var decodedString = atob(hereWeAre);
 console.error(hereWeAre);
 console.error(decodedString); 
});

this brings up an exception: 

Uncaught DOMException: Failed to execute 'atob' on 'Window': The string to 
be decoded is not correctly encoded.

I've also double-checked the values - they are correct. For example, when I 
replace with the following: 

 var decodedString = atob("Q29va2llcyBvbmU=");

it decodes just fine, and the string itself I pick right from there - 
that's the value it has when it throws exception. 

Have no slightest clue what could possibly go wrong. 


On Friday, May 17, 2019 at 7:06:54 AM UTC-4, villas wrote:
>
> Maybe you need to iterate through the class elements.  See this:
>
> https://stackoverflow.com/questions/4735342/jquery-to-loop-through-elements-with-the-same-class
>
>
>
> On Thursday, 16 May 2019 23:58:28 UTC+1, Vlad wrote:
>>
>> Just to clarify: 
>>
>> the following works perfect  for one field by ID (decrypts it back):
>> var encodedDescription = $("#CurrentCartDescription").text()
>> $("#CurrentCartDescription").html(atob(encodedDescription));
>>
>> However, when I try to do it for a bunch of fields at once using class 
>> (instead of id), it doesn't work - doesn't touch the values: 
>>
>> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>>
>> I am sure I am missing something basic... Greatly appreciate suggestions 
>> - 
>>
>> On Thursday, May 16, 2019 at 6:54:14 PM UTC-4, Vlad wrote:
>>>
>>> I had no clue about it - I mean never heard the terms :)
>>>
>>> Thank you very much for point to the direction. After some googling, it 
>>> is almost working. 
>>>
>>> Encoding is just fine (using btoa). 
>>>
>>> When I read it back and want to decode - it's not yet behaving right. 
>>> I'm suspecting my javascript is a problem. 
>>>
>>> There is a bunch of fields which now have encrypted values (class 
>>> 'EncodedDescriptionField'), and I am trying to use the following to reclaim 
>>> the original values: 
>>>
>>>
>>> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>>>
>>> What am I doing wrong? (It doesn't change the values - they remain as 
>>> they are, encrypted)
>>>
>>> On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:
>>>>
>>>> Have you considered base64 encoding/decoding?
>>>>
>>>> quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:
>>>>>
>>>>> I have the following javascript in the view: 
>>>>>
>>>>> var id = $('#CurrentCartId').text();
>>>>> var description = $(this).text();
>>>>> var url='{{=URL('cart','description')}}';
>>>>> url += '/' + id + '/';
>>>>> url += description;
>>>>> ajax(url,[],':eval');
>>>>>
>>>>> the reason I use url+= to pass parameters instead of using args in the 
>>>>> URL helper is because the parameters are coming from the html itself - 
>>>>> they 
>>>>> are not known in the controller py. 
>>>>>
>>>>> now the problem is that it changes the description and I have no way 
>>>>> to recover its original value. for example, when description is "askjdf d 
>>>>>  
>>>>>  dka;lskdj  3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed string 
>>>>> in 
>>>>> this case), it comes out as "askjdf_d___dka_lskdj__3838_". Obviously, 
>>>>> it needs to do this conversion in order to pass  the parameter, but I 
>>>>> need 
>>>>> to be able to recreate the original string, entered by the user. 
>>>>>
>>>>> Is there a better way of doing this? I.e. a better way of passing a 
>>>>> parameter in  a way that it could be "recreated" and stored in the 
>>>>> database 
>>>>> exactly as typed by the user? 
>>>>>
>>>>

-- 
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/298b3f3d-a5fe-4fdf-80a0-b0455e094744%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Vlad
I'll try to simplify it, hoping that I'll figure it out, but it's really 
very puzzling: 

this works perfect: 

var encodedDescription = $("#CurrentCartDescription").text();
$("#CurrentCartDescription").html(atob(encodedDescription));

it decodes it back just exactly from what it was encoded. 
However, the following is messed up: 

$(".EncodedDescriptionField").each( function(index, element ){
 var hereWeAre = $(this).text();
 var decodedString = atob(hereWeAre);
 console.error(hereWeAre);
 console.error(decodedString); 
});

throws an exception, even for the same very value! 

Will simplify it all now, let's see what comes out...

On Friday, May 17, 2019 at 12:20:37 PM UTC-4, Vlad wrote:
>
> It works almost, but not 100% :) 
>
> with encodeURIComponent :
>
> abc def (test)
> comes back as
> abc_def__test_
>
> a;slkdjf;l -239i4-29i23la'skfj(()))9012?  <>,.  =
> comes back as
> a_slkdjf_l_-239i4-29i23la_skfj_9012__.__=
>
> This wouldn't help me, because I want it to be exactly whatever they enter 
> - 
>
> In contrast, atob and btoa work just perfect, except that in one 
> particular situation is gets messed up by that exception... 
>
> On Friday, May 17, 2019 at 10:17:50 AM UTC-4, Anthony wrote:
>>
>> On Thursday, May 16, 2019 at 3:43:58 PM UTC-4, Vlad wrote:
>>>
>>> I have the following javascript in the view: 
>>>
>>> var id = $('#CurrentCartId').text();
>>> var description = $(this).text();
>>> var url='{{=URL('cart','description')}}';
>>> url += '/' + id + '/';
>>> url += description;
>>> ajax(url,[],':eval');
>>>
>>
>> How about putting the variables in the query string:
>>
>> const id = $('#CurrentCartId').text();
>> const description = $(this).text();
>> const url='{{=URL('cart','description')}}';
>> ajax(
>> `${url}?id=${encodeURIComponent(id)}=${encodeURIComponent(description)}`
>> , [], ':eval');
>>
>> Then in the controller, access request.vars.id and 
>> request.vars.description.
>>
>> Anthony
>>
>

-- 
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/4fc90afb-1e30-439d-b5ba-730df5bb1a34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-17 Thread Vlad
It works almost, but not 100% :) 

with encodeURIComponent :

abc def (test)
comes back as
abc_def__test_

a;slkdjf;l -239i4-29i23la'skfj(()))9012?  <>,.  =
comes back as
a_slkdjf_l_-239i4-29i23la_skfj_9012__.__=

This wouldn't help me, because I want it to be exactly whatever they enter 
- 

In contrast, atob and btoa work just perfect, except that in one particular 
situation is gets messed up by that exception... 

On Friday, May 17, 2019 at 10:17:50 AM UTC-4, Anthony wrote:
>
> On Thursday, May 16, 2019 at 3:43:58 PM UTC-4, Vlad wrote:
>>
>> I have the following javascript in the view: 
>>
>> var id = $('#CurrentCartId').text();
>> var description = $(this).text();
>> var url='{{=URL('cart','description')}}';
>> url += '/' + id + '/';
>> url += description;
>> ajax(url,[],':eval');
>>
>
> How about putting the variables in the query string:
>
> const id = $('#CurrentCartId').text();
> const description = $(this).text();
> const url='{{=URL('cart','description')}}';
> ajax(
> `${url}?id=${encodeURIComponent(id)}=${encodeURIComponent(description)}`
> , [], ':eval');
>
> Then in the controller, access request.vars.id and 
> request.vars.description.
>
> Anthony
>

-- 
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/1e9addff-674e-471b-a570-c07d05df96af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Stripe Elements don't display properly - because of some security issue in Web2py - (CSP?)

2019-05-27 Thread Vlad
I've got some security-related errors which cause Stripe elements not to 
display correctly. Some googling helped to understand that presumably 
web2py uses CSP (content security policy?) and some stripe resources need 
to be whitelisted somewhere (not sure if it's web2py-related or web 
server-related - I am using the default rocket server). 

Any ideas on how to fix this up? 

Refused to load the image 
'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
 
because it violates the following Content Security Policy directive: 
"img-src 'self' https://q.stripe.com;.

js.stripe.com/v3/controller-d87ddc0145c66826814f1428b5e7b170.html#apiKey=pk_test_SVBr0v0gb6RVYQKgghwtE5TJ=58cb6bb9-873c-4ac9-8cae-a137e3b7f446=http%3A%2F%2F127.0.0.1%3A8000=http%3A%2F%2F127.0.0.1%3A8000%2Fladore%2Fcart%2Fcredit_cards=__privateStripeController3:1
 
Refused to load the image 
'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
 
because it violates the following Content Security Policy directive: 
"img-src 'self' https://q.stripe.com;.

js.stripe.com/v3/controller-d87ddc0145c66826814f1428b5e7b170.html#apiKey=pk_test_SVBr0v0gb6RVYQKgghwtE5TJ=58cb6bb9-873c-4ac9-8cae-a137e3b7f446=http%3A%2F%2F127.0.0.1%3A8000=http%3A%2F%2F127.0.0.1%3A8000%2Fladore%2Fcart%2Fcredit_cards=__privateStripeController1:1
 
Refused to load the image 
'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
 
because it violates the following Content Security Policy directive: 
"img-src 'self' https://q.stripe.com;.

js.stripe.com/v3/controller-d87ddc0145c66826814f1428b5e7b170.html#apiKey=pk_test_SVBr0v0gb6RVYQKgghwtE5TJ=58cb6bb9-873c-4ac9-8cae-a137e3b7f446=http%3A%2F%2F127.0.0.1%3A8000=http%3A%2F%2F127.0.0.1%3A8000%2Fladore%2Fcart%2Fcredit_cards=__privateStripeController5:1
 
Refused to load the image 
'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
 
because it violates the following Content Security Policy directive: 
"img-src 'self' https://q.stripe.com;.

js.stripe.com/v3/controller-d87ddc0145c66826814f1428b5e7b170.html#apiKey=pk_test_SVBr0v0gb6RVYQKgghwtE5TJ=58cb6bb9-873c-4ac9-8cae-a137e3b7f446=http%3A%2F%2F127.0.0.1%3A8000=http%3A%2F%2F127.0.0.1%3A8000%2Fladore%2Fcart%2Fcredit_cards=__privateStripeController5:1
 
Refused to load the image 
'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
 
because it violates the following Content Security Policy directive: 
"img-src 'self' https://q.stripe.com;.

js.stripe.com/v3/controller-d87ddc0145c66826814f1428b5e7b170.html#apiKey=pk_test_SVBr0v0gb6RVYQKgghwtE5TJ=58cb6bb9-873c-4ac9-8cae-a137e3b7f446=http%3A%2F%2F127.0.0.1%3A8000=http%3A%2F%2F127.0.0.1%3A8000%2Fladore%2Fcart%2Fcredit_cards=__privateStripeController5:1
 
Refused to load the image 
'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
 
because it violates the following Content Security Policy directive: 
"img-src 'self' https://q.stripe.com;.

js.stripe.com/v3/controller-d87ddc0145c66826814f1428b5e7b170.html#apiKey=pk_test_SVBr0v0gb6RVYQKgghwtE5TJ=58cb6bb9-873c-4ac9-8cae-a137e3b7f446=http%3A%2F%2F127.0.0.1%3A8000=http%3A%2F%2F127.0.0.1%3A8000%2Fladore%2Fcart%2Fcredit_cards=__privateStripeController3:1
 
Refused to load the image 
'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
 
because it violates the following Content Security Policy directive: 
"img-src 'self' https://q.stripe.com;.

js.stripe.com/v3/controller-d87ddc0145c66826814f1428b5e7b170.html#apiKey=pk_test_SVBr0v0gb6RVYQKgghwtE5TJ=58cb6bb9-873c-4ac9-8cae-a137e3b7f446=http%3A%2F%2F127.0.0.1%3A8000=http%3A%2F%2F127.0.0.1%3A8000%2Fladore%2Fcart%2Fcredit_cards=__privateStripeController1:1
 
Refused to load the image 
'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
 
because it violates the following Content Security Policy directive: 
"img-src 'self' https://q.stripe.com;.

js.stripe.com/v3/controller-d87ddc0145c66826814f1428b5e7b170.html#apiKey=pk_test_SVBr0v0gb6RVYQKgghwtE5TJ=58cb6bb9-873c-4ac9-8cae-a137e3b7f446=http%3A%2F%2F127.0.0.1%3A8000=http%3A%2F%2F127.0.0.1%3A8000%2Fladore%2Fcart%2Fcredit_cards=__privateStripeController5:1
 
Refused to load the image 
'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
 
because it violates the following Content Security Policy directive: 
"img-src 'self' https://q.stripe.com;.

js.stripe.com/v3/controller-d87ddc0145c66826814f1428b5e7b170.html#apiKey=pk_test_SVBr0v0gb6RVYQKgghwtE5TJ=58cb6bb9-873c-4ac9-8cae-a137e3b7f446=http%3A%2F%2F127.0.0.1%3A8000=http%3A%2F%2F127.0.0.1%3A8000%2Fladore%2Fcart%2Fcredit_cards=__privateStripeController5:1
 
Refused to load the image 
'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
 
because it violates the following Content Security Policy directive: 
"img-src 'self' https://q.stripe.com;.


[web2py] Re: Stripe Elements don't display properly - because of some security issue in Web2py - (CSP?)

2019-05-27 Thread Vlad
After some googling I tried to add something like this




definitely not safe, but in any case doesn't help at all - 

or like this



same errors come back - and stripe elements don't show up right... 

On Monday, May 27, 2019 at 9:18:04 AM UTC-4, Vlad wrote:
>
> I've got some security-related errors which cause Stripe elements not to 
> display correctly. Some googling helped to understand that presumably 
> web2py uses CSP (content security policy?) and some stripe resources need 
> to be whitelisted somewhere (not sure if it's web2py-related or web 
> server-related - I am using the default rocket server). 
>
> Any ideas on how to fix this up? 
>
> Refused to load the image 
> 'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
>  
> because it violates the following Content Security Policy directive: 
> "img-src 'self' https://q.stripe.com;.
>
>
> js.stripe.com/v3/controller-d87ddc0145c66826814f1428b5e7b170.html#apiKey=pk_test_SVBr0v0gb6RVYQKgghwtE5TJ=58cb6bb9-873c-4ac9-8cae-a137e3b7f446=http%3A%2F%2F127.0.0.1%3A8000=http%3A%2F%2F127.0.0.1%3A8000%2Fladore%2Fcart%2Fcredit_cards=__privateStripeController3:1
>  
> Refused to load the image 
> 'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
>  
> because it violates the following Content Security Policy directive: 
> "img-src 'self' https://q.stripe.com;.
>
>
> js.stripe.com/v3/controller-d87ddc0145c66826814f1428b5e7b170.html#apiKey=pk_test_SVBr0v0gb6RVYQKgghwtE5TJ=58cb6bb9-873c-4ac9-8cae-a137e3b7f446=http%3A%2F%2F127.0.0.1%3A8000=http%3A%2F%2F127.0.0.1%3A8000%2Fladore%2Fcart%2Fcredit_cards=__privateStripeController1:1
>  
> Refused to load the image 
> 'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
>  
> because it violates the following Content Security Policy directive: 
> "img-src 'self' https://q.stripe.com;.
>
>
> js.stripe.com/v3/controller-d87ddc0145c66826814f1428b5e7b170.html#apiKey=pk_test_SVBr0v0gb6RVYQKgghwtE5TJ=58cb6bb9-873c-4ac9-8cae-a137e3b7f446=http%3A%2F%2F127.0.0.1%3A8000=http%3A%2F%2F127.0.0.1%3A8000%2Fladore%2Fcart%2Fcredit_cards=__privateStripeController5:1
>  
> Refused to load the image 
> 'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
>  
> because it violates the following Content Security Policy directive: 
> "img-src 'self' https://q.stripe.com;.
>
>
> js.stripe.com/v3/controller-d87ddc0145c66826814f1428b5e7b170.html#apiKey=pk_test_SVBr0v0gb6RVYQKgghwtE5TJ=58cb6bb9-873c-4ac9-8cae-a137e3b7f446=http%3A%2F%2F127.0.0.1%3A8000=http%3A%2F%2F127.0.0.1%3A8000%2Fladore%2Fcart%2Fcredit_cards=__privateStripeController5:1
>  
> Refused to load the image 
> 'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
>  
> because it violates the following Content Security Policy directive: 
> "img-src 'self' https://q.stripe.com;.
>
>
> js.stripe.com/v3/controller-d87ddc0145c66826814f1428b5e7b170.html#apiKey=pk_test_SVBr0v0gb6RVYQKgghwtE5TJ=58cb6bb9-873c-4ac9-8cae-a137e3b7f446=http%3A%2F%2F127.0.0.1%3A8000=http%3A%2F%2F127.0.0.1%3A8000%2Fladore%2Fcart%2Fcredit_cards=__privateStripeController5:1
>  
> Refused to load the image 
> 'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
>  
> because it violates the following Content Security Policy directive: 
> "img-src 'self' https://q.stripe.com;.
>
>
> js.stripe.com/v3/controller-d87ddc0145c66826814f1428b5e7b170.html#apiKey=pk_test_SVBr0v0gb6RVYQKgghwtE5TJ=58cb6bb9-873c-4ac9-8cae-a137e3b7f446=http%3A%2F%2F127.0.0.1%3A8000=http%3A%2F%2F127.0.0.1%3A8000%2Fladore%2Fcart%2Fcredit_cards=__privateStripeController3:1
>  
> Refused to load the image 
> 'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
>  
> because it violates the following Content Security Policy directive: 
> "img-src 'self' https://q.stripe.com;.
>
>
> js.stripe.com/v3/controller-d87ddc0145c66826814f1428b5e7b170.html#apiKey=pk_test_SVBr0v0gb6RVYQKgghwtE5TJ=58cb6bb9-873c-4ac9-8cae-a137e3b7f446=http%3A%2F%2F127.0.0.1%3A8000=http%3A%2F%2F127.0.0.1%3A8000%2Fladore%2Fcart%2Fcredit_cards=__privateStripeController1:1
>  
> Refused to load the image 
> 'data:image/gif;base64,R0lGODlhAQABAIAAAP///yH5BAEALAABAAEAAAIBRAA7'
>  
> because it violates the following Content Security Policy directive: 
> "img-src 'self' https://q.stripe.com;.
>
>
> js.stripe.com/v3/controller-d87ddc0145c66826814f1428b5e7b170.html#apiKey=pk_test_SVBr0v0gb6RVYQKgghwtE5TJ=58cb6bb9-873c-4ac9-8cae-a137e3b7f446=http%3A%2F%2F127.0.0.1%3A8000=http%3A%2F%2F127.0.0.1%3A8000%2Fladore%2Fcart%2Fcredit_cards=__privateStripeController5:1
>  
> Refused to load the

[web2py] string vs text db field question

2019-06-04 Thread Vlad
I've used a string field to keep certain info, and it works just fine, but 
I've just noticed that the strings I ended up saving in this field were 
around 1,000 characters long, sometimes even closer to 2,000. 
According to the docs, the default limit for a string field is 512. The 
limit doesn't seem to be a problem now, so I am wondering what's the nature 
of the limit. Is it safe to use longer strings because DAL handles them 
somehow? Or I'm just lucky at the moment, and should increase the size or 
switch to a text field? (I am still developing, so using sqlite for the 
time being)

-- 
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/71aba083-c255-41e5-8854-d126731cb9fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] the SQLFORM form inserting a record - how to access the new record's id??

2019-05-30 Thread Vlad
Oops, just found an answer here by Anthony from 8 years ago about form.vars.id 
:)
Thank you, Anthony! 

-- 
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/4eb83e2d-1043-4dbc-9f9b-c6982e4c7b4d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] submitting a form from a LOAD component - request.post_vars is empty

2019-05-31 Thread Vlad
I am loading a component with LOAD. the component has the form on it. the 
form is submitting via post method. 

request.post_vars is empty. the variables don't go through. 

when I copy the same very code and pasting it in the view (i.e. instead of 
the LOAD component - while taking the LOAD line out) - with not even a 
single change, just copy and paste - 
request.post_vars is correct - filled with whichever parameters are coming 
from the form. 

is this a feature or a bug? :) 

is there something subtle I am missing about those components? I've tried 
both - loading the component with ajax true and ajax false - same thing. 
And the same thing happens when I tried to submit with get method. 

Other than not having vars set - everything else functions right. The form 
is submitted... 

Any ideas? 


-- 
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/c5a44849-c79a-4718-a211-3782936fa58e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: submitting a form from a LOAD component - request.post_vars is empty

2019-05-31 Thread Vlad
sorry for keeping posting about this. I am just totally stuck. I am sure 
that I am missing something very basic. Here is the complete code: 


   Submit




[web2py] Re: submitting a form from a LOAD component - request.post_vars is empty

2019-05-31 Thread Vlad
I've narrowed down what's going on, but still stuck...

this is how the form is being submitted (from inside of the component): 

function stripeTokenHandler(token) {
  var form = document.getElementById('payment-form');
  var hiddenInput = document.createElement('input');
  hiddenInput.setAttribute('type', 'hidden');
  hiddenInput.setAttribute('name', 'stripeToken');
  hiddenInput.setAttribute('value', token.id);
  form.appendChild(hiddenInput);  
  form.submit();
}

it seems to me that document.createElement('input') doesn't create an 
element under the topmost document (I don't really understand this well, 
but when this code is in the main html - not in the component- it works 
correctly and submits the proper data to the form action url)

I just can't think of anything else here - those variables that are 
hardcoded in the form, i.e. not submitted via created on the fly in input 
fields - are passed over correctly. 

Greatly appreciate some help... 

On Friday, May 31, 2019 at 2:38:06 PM UTC-4, Vlad wrote:
>
> I am loading a component with LOAD. the component has the form on it. the 
> form is submitting via post method. 
>
> request.post_vars is empty. the variables don't go through. 
>
> when I copy the same very code and pasting it in the view (i.e. instead of 
> the LOAD component - while taking the LOAD line out) - with not even a 
> single change, just copy and paste - 
> request.post_vars is correct - filled with whichever parameters are coming 
> from the form. 
>
> is this a feature or a bug? :) 
>
> is there something subtle I am missing about those components? I've tried 
> both - loading the component with ajax true and ajax false - same thing. 
> And the same thing happens when I tried to submit with get method. 
>
> Other than not having vars set - everything else functions right. The form 
> is submitted... 
>
> Any ideas? 
>
>
>

-- 
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/2ebf7e18-a569-4c0d-91ef-ce7a3f7d1f9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] the SQLFORM form inserting a record - how to access the new record's id??

2019-05-30 Thread Vlad
form = SQLFORM(db.person)
   if form.process().accepted:
...


How can I access the id of the record inserted into the db by the form? 

-- 
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/e8984cff-ff25-4a6e-a0f1-8c859bee1d71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] how safe is it to rely on a value stored as a session variable?

2019-06-06 Thread Vlad
I don't really understand how it works internally, so wondering if it's 
safe to rely on a value stored as a session storage variable. 
More specifically, I am authorizing one user to do certain actions on 
behalf of another user, and the currently assumed user is stored in 
session.user (even if auth.user_id is somebody else). 
If somebody can hack session and change the value of session.user - it 
would be potentially dangerous situation, so if it's not safe - I would 
have to figure out something else.It's just easy and tempting to use some 
variables in a session. 
Any ideas on how safe it is? 

p.s. I don't care if somebody can read it - my only concern is that they 
shouldn't be able to overwrite it, because this would give them authority 
to perform certain actions.

-- 
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/a18247eb-05f5-4052-bb25-4d5c39160ce1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] sqlform grid search widget expression question

2019-06-05 Thread Vlad
How can I search for None values? 

For example, the search expression
   table.customer == "1"
gives me records with customer equals 1. 
I can't figure out how to search for records with customer field equals 
None. 

Tried none,NONE, None, "none", etc. Nothing helped :)

Is it possible at all? 

-- 
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/b52ea42e-ecde-4d38-83ed-782f45874b2b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] auth.settings.login_next doesn't redirect after login -

2019-06-06 Thread Vlad
What could be the reason the following code wouldn't redirect to the 
appropriate URL after login? (still brings to default/index page)

def login_to_url():
   
   auth.settings.login_next=URL(request.args(0),request.args(1))

   logger.warning(auth.settings.login_next)
   
   redirect(URL('default','user',args='login'))

I am missing something basic here, as I checked this parameter in the user 
function itself:

def user():
logger.warning(auth.settings.login_next)
return dict(form=auth())

and it's printing out default/index instead of the value I setup. I can't 
even think about what could possibly reset this variable after I assign it. 

-- 
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/15e0ef48-8e8f-440b-b0ac-724dfe4442fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] 2 domains for 2 apps on 1 web2p

2019-06-14 Thread Vlad
I've had multiple apps in one web2py with no problems, of course, but only 
up to the point I've assigned different domains to different apps 

I am on PythonAnywhere, but presumably it's the same issue on any hosting. 

I am giving 2 cnames for 2 apps, and I pointed both cnames properly. BUT 
only one domain works for bare domain - i.e. for www.domain1.com . For the 
second name I always have to specify the full path  
-www.domain2.com//app/cont/func.

I am obviously missing something, but here is why I have this problem: 

they all share one routes.py on the web2py root level. routes.py can only 
have one entry corresponding to "/" - I can point "/" to app1/cont1/func1. 
So, www.domain2.com can't be handled without a/c/f , because no matter what 
the domain is, the only proper entry for the bare domain name is "/" in 
routes.py.

How to handle this properly, i.e. to specify routing for each domain root - 
without having the 2nd web2py installation?



-- 
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/86a1e4b8-90df-4a81-b554-478d193bbaea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: 2 domains for 2 apps on 1 web2p

2019-06-14 Thread Vlad
let me be a bit more specific, as my problem is apparently in missing 
something very basic:

here is a quote from PythonAnywhere docs: "...for each additional domain 
name, you need to set up another PythonAnywhere web app from the web tab. 
This time though, you should choose "manual configuration". Then, go and 
edit your WSGI file. You should make it into a copy of the WSGI file for 
the first web2py application, so that both domains point at the same web2py 
installation. Then the web2py routes.py should work."

So this is perfect, and routes.py works indeed. However, it doesn't work 
fully for the root domains: 

routes.py can only have only entry corresponding to "/", for example: 

routes_in = (
   ( '/' ,' /app1/cont1/func1'),
   
 )

This will take care of www.domain1.com .

Now, if I want to point www.domain2.com to /app2/conf2/func2 - I have no 
way to handle this (unless I am missing something very basic here). I would 
at least need to specify something like this:
 ( '/app2', '/app2/conf2/func2' ) which will take care of 
www.domain2.com/app2 but the root www.domain2.com will still be redirecting 
to /app1/cont1/func1, as per the only "/" entry in routes.py, as "/" 
doesn't distinguish between domains. 

What am I missing? How can I handle this properly?? 

On Friday, June 14, 2019 at 2:23:21 PM UTC-4, Vlad wrote:
>
> I've had multiple apps in one web2py with no problems, of course, but only 
> up to the point I've assigned different domains to different apps 
>
> I am on PythonAnywhere, but presumably it's the same issue on any hosting. 
>
> I am giving 2 cnames for 2 apps, and I pointed both cnames properly. BUT 
> only one domain works for bare domain - i.e. for www.domain1.com . For 
> the second name I always have to specify the full path  -
> www.domain2.com//app/cont/func.
>
> I am obviously missing something, but here is why I have this problem: 
>
> they all share one routes.py on the web2py root level. routes.py can only 
> have one entry corresponding to "/" - I can point "/" to app1/cont1/func1. 
> So, www.domain2.com can't be handled without a/c/f , because no matter 
> what the domain is, the only proper entry for the bare domain name is "/" 
> in routes.py.
>
> How to handle this properly, i.e. to specify routing for each domain root 
> - without having the 2nd web2py installation?
>
>
>
>

-- 
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/3da3ff6e-c29d-4a8e-a235-1b18c6df4cbc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] switching to postgres [RuntimeError: No driver of supported ones ('psycopg2',) is available]

2019-06-16 Thread Vlad
I've got 50% of the answer. They require ssh tunnel to be used and don't 
allow any direct connection. I understand that there is security reason for 
that, yet I am at loss on how to handle this better. 

Keeping ssh tunnel alive is problematic (for development it's fine, but for 
production...) 

So the only feasible solution for production environment to have "internal" 
db, i.e. hosted in the same very web2py server environment locally to avoid 
using tunnels. I mean, I am talking about cloud postgres providers - I 
don't think it's practical for me to become a postgres expert quickly and 
take care of its hosting by myself to allow a direct connection. 

Is this correct? 

But regardless of tunnels, I have a problem with PythonAnywhere thing, 
because there I use PA postgress and no tunnel required in such a 
configuration. So, while this opens a valid connection: 

import psycopg2
connection = psycopg2.connect(database="test_db", user="test", password=
"x", host="xxx-994.postgres.pythonanywhere-services.com", port=10994)

web2py reports a connection error (i.e. when I specify db in appconfig 
instead of opening a connection manually as above):

psycopg2.OperationalError: FATAL: password authentication failed for user 
"test"

So exact same settings fail when in web2py ( postgres://test:x?!@
xxx-994.postgres.pythonanywhere-services.com:10994/test_db )

Greatly appreciate some pointers to the db direction. I am at loss on how 
to handle this gracefully. SQLite has served perfect up until now, when I 
have to get to a real db... 




On Sunday, June 16, 2019 at 10:41:22 AM UTC-4, Vlad wrote:
>
> Okay, I recreated it in a simplest form, to get rid of any extra 
> parameters. Can't make it working neither on windows nor on linux. Here is 
> exactly what's going on: 
>
> *on linux: *
>
> the following code
> import psycopg2
> connection = psycopg2.connect(database="test_db", user="test", password=
> "x", host="xxx-994.postgres.pythonanywhere-services.com", port=10994)
> executes perfect. a valid connection is received. 
>
> However, when I specify exactly same in the appconfig 
> ( postgres://test:x?!@
> xxx-994.postgres.pythonanywhere-services.com:10994/test_db ) it fails 
> with the following error:
> psycopg2.OperationalError: FATAL: password authentication failed for user 
> "test"
>
> The user and the password are correct though - besides creating a 
> connection successfully by the code above, I've also verified in postgres 
> itself, to make sure that the user was created successfully and that the 
> permissions were given correctly. So it makes no sense that password 
> authentication fails. 
>
> *and here is what I have on windows: *
>
> the code above doesn't even create a valid connection. Here is the error: 
> "OperationalError(could not connect to server: Connection timed out 
> (0x274C/10060) Is the server running on host "
> xxx-994.postgres.pythonanywhere-services.com" (10.0.0.70) and accepting 
> TCP/IP connections on port 10994? )"
>
> and when I specify the db in appconfig, it's a similar error (just coming 
> from web2py wrapper, I guess): "psycopg2.OperationalError: could not 
> connect to server: Connection timed out (0x274C/10060) Is the server 
> running on host "xxx-994.postgres.pythonanywhere-services.com" 
> (10.0.0.70) and accepting TCP/IP connections on port 10994?"
>
> *So psycopg2 at this point is present and found by Python *(not even sure 
> what was the problem before, when it couldn't be found on windows), but *on 
> windows connection fails, while on linux password authentication fails*.
>
> Greatly appreciate any ideas. 
>
>
>
> On Sunday, June 16, 2019 at 7:54:20 AM UTC-4, Vlad wrote:
>>
>> On this one I run web2py on Windows. Using web2py from source. No idea 
>> what virtualenv is, so presumably not using it. Installed psycopg2 with 
>> pip3 specifically, to make sure it goes into the right Python. (I am not 
>> too familiar with this, but anything I install with pip goes to Python 2, 
>> and pip3 puts everything under Python 3 which I use for web2py). And yes, 
>> this is my development computer, so I restart web2py every time. 
>>
>> On Sun, Jun 16, 2019, 7:21 AM Val K  wrote:
>>
>>> Did you restart web2py after installation? 
>>>
>>> -- 
>>> 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 

[web2py] please help: sycopg2.OperationalError: FATAL: password authentication failed for user "test"

2019-06-16 Thread Vlad
I'm bringing this from another post, because I've narrowed down the problem 
considerably, and it no longer corresponds neither to the headline nor to 
the content of that post. 

the following works fine, creating a valid connection:

connection = psycopg2.connect(database="test_db", user="test", 
password="xx", host="-994.postgres.pythonanywhere-services.com", 
port=10994)

the following fails: 

db = 
DAL("postgres://test:xx?!@-994.postgres.pythonanywhere-services.com:10994/test_db",
 pool_size=configuration.get('db.pool_size'),
 migrate_enabled=configuration.get('db.migrate'),
 check_reserved=['all'])

 Failure to connect, tried 5 times: Traceback (most 
recent call last): File 
"/home/vladtseytkin/web2py/gluon/packages/dal/pydal/base.py", line 457, in 
__init__ self._adapter = adapter(**kwargs) File 
"/home/vladtseytkin/web2py/gluon/packages/dal/pydal/adapters/postgres.py", 
line 27, in __call__ return AdapterMeta.__call__(cls, *args, **kwargs) File 
"/home/vladtseytkin/web2py/gluon/packages/dal/pydal/adapters/__init__.py", 
line 39, in __call__ obj = super(AdapterMeta, cls).__call__(*args, 
**kwargs) File 
"/home/vladtseytkin/web2py/gluon/packages/dal/pydal/adapters/postgres.py", 
line 54, in __init__ driver_args, adapter_args, do_connect, 
after_connection) File 
"/home/vladtseytkin/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
369, in __init__ super(SQLAdapter, self).__init__(*args, **kwargs) File 
"/home/vladtseytkin/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
53, in __init__ self.reconnect() File 
"/home/vladtseytkin/web2py/gluon/packages/dal/pydal/helpers/classes.py", 
line 181, in _reconnect_and_configure self._connection_reconnect() File 
"/home/vladtseytkin/web2py/gluon/packages/dal/pydal/connection.py", line 
174, in reconnect self.connection = self.connector() File 
"/home/vladtseytkin/web2py/gluon/packages/dal/pydal/adapters/postgres.py", 
line 118, in connector return self.driver.connect(**self.driver_args) File 
"/home/vladtseytkin/.local/lib/python3.7/site-packages/psycopg2/__init__.py", 
line 126, in connect conn = _connect(dsn, 
connection_factory=connection_factory, **kwasync) 
psycopg2.OperationalError: FATAL: password authentication failed for user 
"test"

The password is correct. It can't possibly fail. Besides the password 
working in the db itself, t's the same very password that also works in 
psycopg2.connect() call above. 

How can I debug it further? What am I missing? What could be the reason?

I am getting exactly same problem (working for psycopg2.connect and not 
working for DAL constructor with exactly same error) when 1) doing it from 
web2py under PythonAnywhere and 2) web2py under my local windows PC (when 
local, running the ssh tunnel, as prescribed elsewhere). 

Please help! 

-- 
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/fdc66dd4-9846-4d4f-bb1c-490868f3e8a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: please help: sycopg2.OperationalError: FATAL: password authentication failed for user "test"

2019-06-16 Thread Vlad
here is the full traceback, just in case:

Version
web2py™ Version 2.18.5-stable+timestamp.2019.04.08.04.22.03Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.

Traceback (most recent call last):
  File "/home/vladtseytkin/web2py/gluon/restricted.py", line 219, in restricted
exec(ccode, environment)
  File "/home/vladtseytkin/web2py/applications/test/controllers/default.py" 
<https://www.ladore.me/admin/edit/test/controllers/default.py>, line 72, in 

  File "/home/vladtseytkin/web2py/gluon/globals.py", line 421, in 
self._caller = lambda f: f()
  File "/home/vladtseytkin/web2py/applications/test/controllers/default.py" 
<https://www.ladore.me/admin/edit/test/controllers/default.py>, line 19, in 
index
check_reserved=['all'])
  File "/home/vladtseytkin/web2py/gluon/packages/dal/pydal/base.py", line 171, 
in __call__
obj = super(MetaDAL, cls).__call__(*args, **kwargs)
  File "/home/vladtseytkin/web2py/gluon/packages/dal/pydal/base.py", line 477, 
in __init__
"Failure to connect, tried %d times:\n%s" % (attempts, tb)
RuntimeError: Failure to connect, tried 5 times:
Traceback (most recent call last):
  File "/home/vladtseytkin/web2py/gluon/packages/dal/pydal/base.py", line 457, 
in __init__
self._adapter = adapter(**kwargs)
  File 
"/home/vladtseytkin/web2py/gluon/packages/dal/pydal/adapters/postgres.py", line 
27, in __call__
return AdapterMeta.__call__(cls, *args, **kwargs)
  File 
"/home/vladtseytkin/web2py/gluon/packages/dal/pydal/adapters/__init__.py", line 
39, in __call__
obj = super(AdapterMeta, cls).__call__(*args, **kwargs)
  File 
"/home/vladtseytkin/web2py/gluon/packages/dal/pydal/adapters/postgres.py", line 
54, in __init__
driver_args, adapter_args, do_connect, after_connection)
  File "/home/vladtseytkin/web2py/gluon/packages/dal/pydal/adapters/base.py", 
line 369, in __init__
super(SQLAdapter, self).__init__(*args, **kwargs)
  File "/home/vladtseytkin/web2py/gluon/packages/dal/pydal/adapters/base.py", 
line 53, in __init__
self.reconnect()
  File "/home/vladtseytkin/web2py/gluon/packages/dal/pydal/helpers/classes.py", 
line 181, in _reconnect_and_configure
self._connection_reconnect()
  File "/home/vladtseytkin/web2py/gluon/packages/dal/pydal/connection.py", line 
174, in reconnect
self.connection = self.connector()
  File 
"/home/vladtseytkin/web2py/gluon/packages/dal/pydal/adapters/postgres.py", line 
118, in connector
return self.driver.connect(**self.driver_args)
  File 
"/home/vladtseytkin/.local/lib/python3.7/site-packages/psycopg2/__init__.py", 
line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL:  password authentication failed for user 
"test"


On Sunday, June 16, 2019 at 5:47:57 PM UTC-4, Vlad wrote:
>
> I'm bringing this from another post, because I've narrowed down the 
> problem considerably, and it no longer corresponds neither to the headline 
> nor to the content of that post. 
>
> the following works fine, creating a valid connection:
>
> connection = psycopg2.connect(database="test_db", user="test", 
> password="xx", host="-994.postgres.pythonanywhere-services.com", 
> port=10994)
>
> the following fails: 
>
> db = DAL("postgres://test:xx?!@
> -994.postgres.pythonanywhere-services.com:10994/test_db",
>  pool_size=configuration.get('db.pool_size'),
>  migrate_enabled=configuration.get('db.migrate'),
>  check_reserved=['all'])
>
>  Failure to connect, tried 5 times: Traceback (most 
> recent call last): File 
> "/home/vladtseytkin/web2py/gluon/packages/dal/pydal/base.py", line 457, in 
> __init__ self._adapter = adapter(**kwargs) File 
> "/home/vladtseytkin/web2py/gluon/packages/dal/pydal/adapters/postgres.py", 
> line 27, in __call__ return AdapterMeta.__call__(cls, *args, **kwargs) File 
> "/home/vladtseytkin/web2py/gluon/packages/dal/pydal/adapters/__init__.py", 
> line 39, in __call__ obj = super(AdapterMeta, cls).__call__(*args, 
> **kwargs) File 
> "/home/vladtseytkin/web2py/gluon/packages/dal/pydal/adapters/postgres.py", 
> line 54, in __init__ driver_args, adapter_args, do_connect, 
> after_connection) File 
> "/home/vladtseytkin/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
> 369, in __init__ super(SQLAdapter, self).__init__(*args, **kwargs) File 
> "/home/vladtseytkin/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
> 53, in __init__ self.reconnec

Re: [web2py] switching to postgres [RuntimeError: No driver of supported ones ('psycopg2',) is available]

2019-06-16 Thread Vlad
Yes, it was a typo. There were quite a few things that went wrong and I missed 
this one even after looking at it dozens of times, checking each character... 

It's perfect now.

Thank you very much

-- 
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/47f795e0-0768-429a-89b3-f7941f33fa72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Hiding grid's columns (SQLFORM.grid) for smaller screen sizes

2019-06-11 Thread Vlad
how would I hide certain fields of the grid generated by SQLFORM.grid() 
depending on a screen size? 
normally I would use media breakpoints, but I am not sure how to manage it 
with SQLFORM.grid, as grid doesn't seem to expose any widgets explicitly... 

-- 
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/b9433a94-2203-4712-964c-e0d14cecb016%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: managing users with no email

2019-06-11 Thread Vlad
sounds like a perfect solution
thank you!

p.s. I've made one enhancement: instead of fake email I created a catch-all 
email for the domain, and will instruct the admin to specify a "real" email 
for a new customer (like "customer.first_name.last_n...@mydomain.com") - it 
will be a fake, of course, but for all practical purposes it will forward 
all the invoices and receipts and whatever to the default inbox), so this 
will create a useful illusion for the admin that he is creating a "real" 
email for the customer... 

On Tuesday, June 11, 2019 at 3:11:53 PM UTC-4, Val K wrote:
>
> As far as I remember, it is possible add extra fields to auth_user table 
> +  you can make your own login form (phone/password)
> + you can retrieve record (and email that could be a fake) from  
> auth_user, using extra field (phone number) - db(auth_user.phone == 
> form.vars.phone).select(auth_user.email)
> + and you can login user using auth.login_bare(email, password)
>
> On Tuesday, June 11, 2019 at 9:41:40 PM UTC+3, Vlad wrote:
>>
>> seems to me that the ideal solution would be to allow an email field in 
>> auth_user to contain something other than email (for example, a phone 
>> number). but besides that I am not sure how to relax this requirement on 
>> the email field in auth_user, this solution seems to be politically 
>> incorrect, as this field is really expected to be an email (i.e. in a way 
>> how auth functions?) - 
>> so I am wondering what's the best way to make the thing to alternate 
>> between an email and a phone number for users as a unique account 
>> identifier...
>> greatly appreciate ideas... hope there is a simple and easy way to 
>> achieve this... 
>>
>> On Tuesday, June 11, 2019 at 2:37:23 PM UTC-4, Vlad wrote:
>>>
>>> Trying to figure out how to manage the following: 
>>>
>>> some users will manage themselves. this means that they have email and 
>>> they log into the system and do whatever they want. 
>>>
>>> other users don't use email (and generally aren't online altogether). so 
>>> I want an admin to manage them, i.e. they would call in or walk in and the 
>>> admin would do whatever needs to be done for them.
>>>
>>> the challenge is the email field. I don't want an admin to create a 
>>> unique email account for each user (simply because in real life they don't 
>>> use email and have no email account - though those always have a phone 
>>> number instead of email, if that helps), so an admin should be able to 
>>> create a customer who would never login by himself, but the admin would 
>>> manage what's going on in their account on their behalf. 
>>> What's the best way to handle it? 
>>>
>>>
>>>

-- 
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/c8a03de0-eaf5-427c-8d16-e025ed67c82a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: managing users with no email

2019-06-11 Thread Vlad
seems to me that the ideal solution would be to allow an email field in 
auth_user to contain something other than email (for example, a phone 
number). but besides that I am not sure how to relax this requirement on 
the email field in auth_user, this solution seems to be politically 
incorrect, as this field is really expected to be an email (i.e. in a way 
how auth functions?) - 
so I am wondering what's the best way to make the thing to alternate 
between an email and a phone number for users as a unique account 
identifier...
greatly appreciate ideas... hope there is a simple and easy way to achieve 
this... 

On Tuesday, June 11, 2019 at 2:37:23 PM UTC-4, Vlad wrote:
>
> Trying to figure out how to manage the following: 
>
> some users will manage themselves. this means that they have email and 
> they log into the system and do whatever they want. 
>
> other users don't use email (and generally aren't online altogether). so I 
> want an admin to manage them, i.e. they would call in or walk in and the 
> admin would do whatever needs to be done for them.
>
> the challenge is the email field. I don't want an admin to create a unique 
> email account for each user (simply because in real life they don't use 
> email and have no email account - though those always have a phone number 
> instead of email, if that helps), so an admin should be able to create a 
> customer who would never login by himself, but the admin would manage 
> what's going on in their account on their behalf. 
> What's the best way to handle it? 
>
>
>

-- 
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/eea8bc7c-a5a8-4393-ba43-bccf97690d87%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] managing users with no email

2019-06-11 Thread Vlad
Trying to figure out how to manage the following: 

some users will manage themselves. this means that they have email and they 
log into the system and do whatever they want. 

other users don't use email (and generally aren't online altogether). so I 
want an admin to manage them, i.e. they would call in or walk in and the 
admin would do whatever needs to be done for them.

the challenge is the email field. I don't want an admin to create a unique 
email account for each user (simply because in real life they don't use 
email and have no email account - though those always have a phone number 
instead of email, if that helps), so an admin should be able to create a 
customer who would never login by himself, but the admin would manage 
what's going on in their account on their behalf. 
What's the best way to handle it? 


-- 
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/b8b9e3eb-78a2-44a9-8c09-d08df2c72efb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] intercepting login & logout events

2019-06-17 Thread Vlad
What would be the simplest way to intercept login and logout? 
(i.e. I'd like to perform some additional tasks when a user is logged in, 
and when a user is logged out.)
web2py elegantly hides the functionality in default.user under form=auth() 
and {{=form}} and somehow I can't think of a simple way to be notified 
about successful login and logout actions... 

-- 
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/b9dbb7bb-4500-48b2-82fd-cd8ea644f1fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] intercepting login & logout events

2019-06-17 Thread Vlad
Yoel, where could I look up how this works about the exception 303? Because 
I don't understand that part at all - I am not aware of exception being 
raised, why, and how it works in the flow - could you please point me to 
the direction where it's explained? 

On Monday, June 17, 2019 at 10:16:58 AM UTC-4, Yoel Benitez Fonseca wrote:
>
> no, it is not.
>
> The first time the default/user is called - in the login process for 
> example - there not a HTTP(303) (redirect) exception, and the user get the 
> form.
> The second time, in this scenery, the call to auth() will cause a redirect 
> (HTTP exception) and the user is effectively logged into the system.
>
> The same goes for the logout, but there is not a form in the middle.
>
> El lun., 17 jun. 2019 a las 9:57, Vlad (>) 
> escribió:
>
>> but isn't such a scenario catching a user in a process of logging in or 
>> logging out, but before actual login/logout?
>>
>> On Monday, June 17, 2019 at 9:44:10 AM UTC-4, Yoel Benitez Fonseca wrote:
>>>
>>> I think you can do it in the default/user function. Having in account 
>>> that the call to auth() probably raises a HTTP exceptiong in case of a 
>>> success. This example is only a proof of concept:
>>>
>>> def user():
>>> form = CAT()
>>> 
>>> try:
>>> form = auth()
>>> except HTTP as e:
>>> if e.status == 303'login' in request.args:
>>> if ('login' in request.args) and auth.user:
>>> # probably a success, u can test if auth.user is o not None
>>> do_your_loging_event_here() 
>>> elif 'logout' if request.args:
>>> do_your_logout_event_here()
>>> 
>>> return dict(form=form)
>>>
>>>
>>>
>>> El lun., 17 jun. 2019 a las 9:19, Vlad () escribió:
>>>
>>>> What would be the simplest way to intercept login and logout? 
>>>> (i.e. I'd like to perform some additional tasks when a user is logged 
>>>> in, and when a user is logged out.)
>>>> web2py elegantly hides the functionality in default.user under 
>>>> form=auth() and {{=form}} and somehow I can't think of a simple way to be 
>>>> notified about successful login and logout actions... 
>>>>
>>>> -- 
>>>> 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 web...@googlegroups.com.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/web2py/b9dbb7bb-4500-48b2-82fd-cd8ea644f1fe%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/web2py/b9dbb7bb-4500-48b2-82fd-cd8ea644f1fe%40googlegroups.com?utm_medium=email_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>> -- 
>>> Msc. Yoel Benítez Fonseca
>>>
>>>
>>>
>>>
>>>
>>>
>>> -- 
>> 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 web...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/ee8abe78-346c-44dd-b8a6-e9b243e4eb90%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/web2py/ee8abe78-346c-44dd-b8a6-e9b243e4eb90%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
> Msc. Yoel Benítez Fonseca
>
>
>
>
>
>
>

-- 
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/237c7ee1-72d9-4f3b-a3f5-f09fd34459ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] intercepting login & logout events

2019-06-17 Thread Vlad
but isn't such a scenario catching a user in a process of logging in or 
logging out, but before actual login/logout?

On Monday, June 17, 2019 at 9:44:10 AM UTC-4, Yoel Benitez Fonseca wrote:
>
> I think you can do it in the default/user function. Having in account that 
> the call to auth() probably raises a HTTP exceptiong in case of a success. 
> This example is only a proof of concept:
>
> def user():
> form = CAT()
> 
> try:
> form = auth()
> except HTTP as e:
> if e.status == 303'login' in request.args:
> if ('login' in request.args) and auth.user:
> # probably a success, u can test if auth.user is o not None
> do_your_loging_event_here() 
> elif 'logout' if request.args:
> do_your_logout_event_here()
> 
> return dict(form=form)
>
>
>
> El lun., 17 jun. 2019 a las 9:19, Vlad (>) 
> escribió:
>
>> What would be the simplest way to intercept login and logout? 
>> (i.e. I'd like to perform some additional tasks when a user is logged in, 
>> and when a user is logged out.)
>> web2py elegantly hides the functionality in default.user under 
>> form=auth() and {{=form}} and somehow I can't think of a simple way to be 
>> notified about successful login and logout actions... 
>>
>> -- 
>> 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 web...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/b9dbb7bb-4500-48b2-82fd-cd8ea644f1fe%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/web2py/b9dbb7bb-4500-48b2-82fd-cd8ea644f1fe%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
> Msc. Yoel Benítez Fonseca
>
>
>
>
>
>
>

-- 
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/ee8abe78-346c-44dd-b8a6-e9b243e4eb90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: orderby=['alias'] - works in sqlite, but not in postgres

2019-06-18 Thread Vlad
Anthony, it works like a charm, thank you very much!! 

(Val's solution with also worked great, but it felt awkward to use the 
whole thing when an alias was created, so emotionally this solution with 
alias feels better :)

On a side note, for SQLite orderby=['~shares'] works perfect - it indeed 
sorts it out properly. Just in case I've verified it again now. 

By the way, Val's solution was orderby=[~db.cart_sharing.stats.count()] - 
with tilda, and it worked even in Postgres. Somehow tilda doesn't work 
specifically with an alias - but without an alias it's just fine on both 
dbs. 

But in any case, orderby=['shares DESC'] works everywhere flawlessly and 
feels good too, so it's a winner :)

Thank you! 



On Tuesday, June 18, 2019 at 10:41:21 AM UTC-4, Anthony wrote:
>
> In SQLite, the tilde (~) is a unary operator used for bitwise negation. If 
> used as a prefix for an order by column, SQLite will not throw an error (as 
> it is a valid operator), but nor will sort they way you expect. In 
> Postgres, the tilde is not a unary operator but a regular expression 
> operator, so when used in this way, it will throw an error. In any case, in 
> SQL, "DESC" is used to indicate descending order ("ASC" for ascending).
>
> So, you can do:
>
> orderby='shares DESC'
>
> Anthony
>
> On Monday, June 17, 2019 at 11:48:51 PM UTC-4, Vlad wrote:
>>
>> This works perfect in SQLite:
>>
>>rows = db(query).select(db.cart_sharing.created_by.with_alias('sharer'
>> ),
>>db.cart_sharing.stats.count().with_alias(
>> 'carts'),
>>db.cart_sharing.stats.sum().with_alias(
>> 'shares'),
>>groupby=db.cart_sharing.created_by,
>>orderby=['~shares'])
>>
>>
>> 'shares' is alias to sum(), and sqlite understands exactly what's needed 
>> - sorts by the number of shares. 
>>
>> Posgres doesn't like it: 
>>column "shares" does not exist 
>> LINE 1: ...NULL) GROUP BY "cart_sharing"."created_by" ORDER BY ~shares; ^
>>
>> What's the proper DAL syntax for such a thing compatible with Postgres? 
>>
>>
>>

-- 
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/d60f3d51-92ec-4ca7-a7e8-36fed3b1185d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: sqlform grid to show a field entirely, without cutting off the text

2019-06-18 Thread Vlad
works like a charm!!

thank you Annet!!!
thank you Anthony!!!



On Tuesday, June 18, 2019 at 3:11:08 PM UTC-4, Annet wrote:
>
> I think Anthony answered this question in this post:
>
> https://groups.google.com/forum/?fromgroups=#!topic/web2py/okMVqyQPKV8
>
> hope he did ;-)
>
>
> Regards,
>
> Annet
>

-- 
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/57a5c65f-f04f-4981-8a1f-f17df593daf7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] sqlform grid to show a field entirely, without cutting off the text

2019-06-18 Thread Vlad
Is there an easy way to force the SQLFORM grid to show one specific column 
entirely, without cutting it off, even if the row would have to be extended 
vertically, just whatever it takes to see the full text content? 

-- 
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/d32caca2-7920-4c7a-9fd3-6227f9300067%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] orderby=['alias'] - works in sqlite, but not in postgres

2019-06-17 Thread Vlad
This works perfect in SQLite:

   rows = db(query).select(db.cart_sharing.created_by.with_alias('sharer'),
   db.cart_sharing.stats.count().with_alias('carts'
),
   db.cart_sharing.stats.sum().with_alias('shares'),
   groupby=db.cart_sharing.created_by,
   orderby=['~shares'])


'shares' is alias to sum(), and sqlite understands exactly what's needed - 
sorts by the number of shares. 

Posgres doesn't like it: 
   column "shares" does not exist 
LINE 1: ...NULL) GROUP BY "cart_sharing"."created_by" ORDER BY ~shares; ^

What's the proper DAL syntax for such a thing compatible with Postgres? 


-- 
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/c3bfb0ea-6c29-48d8-85a3-3e4e21242b9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] intercepting login & logout events

2019-06-17 Thread Vlad
thank you ! 

On Monday, June 17, 2019 at 11:02:13 AM UTC-4, Yoel Benitez Fonseca wrote:
>
> Vlad, in the book:
>
>
> http://www.web2py.com/books/default/chapter/29/04/the-core#HTTP-and-redirect
>
> And i can comment out +/- the code:
>
> def user():
>
> # just a way to ensure form allways have a value
> form = CAT()
> 
> try:
>
> # the call to auth can return a lot of things
>
> # it can be a form (a login form for example or a registration form)
>
> # it can raise a redirect - for exple if the login is correct
>
> # it can be the login form with erros if the password is incorrect
>
> # etc
> form = auth()
> except HTTP as e:
> if e.status == 303'login' in request.args:
> if ('login' in request.args) and auth.user:
> # probably a success, the user has logged in
> do_your_loging_event_here() 
>
> # ensuere u do the redirect, for example a raise shoul do it
> elif 'logout' if request.args:
> do_your_logout_event_here()
> 
> # give the form to the view, can be register form, login form, etc
> return dict(form=form)
>
>
>
> El lun., 17 jun. 2019 a las 10:31, Vlad ( >) escribió:
>
>> Yoel, where could I look up how this works about the exception 303? 
>> Because I don't understand that part at all - I am not aware of exception 
>> being raised, why, and how it works in the flow - could you please point me 
>> to the direction where it's explained? 
>>
>> On Monday, June 17, 2019 at 10:16:58 AM UTC-4, Yoel Benitez Fonseca wrote:
>>>
>>> no, it is not.
>>>
>>> The first time the default/user is called - in the login process for 
>>> example - there not a HTTP(303) (redirect) exception, and the user get the 
>>> form.
>>> The second time, in this scenery, the call to auth() will cause a 
>>> redirect (HTTP exception) and the user is effectively logged into the 
>>> system.
>>>
>>> The same goes for the logout, but there is not a form in the middle.
>>>
>>> El lun., 17 jun. 2019 a las 9:57, Vlad () escribió:
>>>
>>>> but isn't such a scenario catching a user in a process of logging in or 
>>>> logging out, but before actual login/logout?
>>>>
>>>> On Monday, June 17, 2019 at 9:44:10 AM UTC-4, Yoel Benitez Fonseca 
>>>> wrote:
>>>>>
>>>>> I think you can do it in the default/user function. Having in account 
>>>>> that the call to auth() probably raises a HTTP exceptiong in case of a 
>>>>> success. This example is only a proof of concept:
>>>>>
>>>>> def user():
>>>>> form = CAT()
>>>>> 
>>>>> try:
>>>>> form = auth()
>>>>> except HTTP as e:
>>>>> if e.status == 303'login' in request.args:
>>>>> if ('login' in request.args) and auth.user:
>>>>> # probably a success, u can test if auth.user is o not 
>>>>> None
>>>>> do_your_loging_event_here() 
>>>>> elif 'logout' if request.args:
>>>>> do_your_logout_event_here()
>>>>> 
>>>>> return dict(form=form)
>>>>>
>>>>>
>>>>>
>>>>> El lun., 17 jun. 2019 a las 9:19, Vlad () 
>>>>> escribió:
>>>>>
>>>>>> What would be the simplest way to intercept login and logout? 
>>>>>> (i.e. I'd like to perform some additional tasks when a user is logged 
>>>>>> in, and when a user is logged out.)
>>>>>> web2py elegantly hides the functionality in default.user under 
>>>>>> form=auth() and {{=form}} and somehow I can't think of a simple way to 
>>>>>> be 
>>>>>> notified about successful login and logout actions... 
>>>>>>
>>>>>> -- 
>>>>>> 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&quo

[web2py] emailing the content of the current page

2019-06-19 Thread Vlad
I'd like to send an email with html content - the current page:

mail.send('y...@example.com', 'Message subject', 'html body')

How do I make the html body available in python code? (i.e. how do I pass 
it from the view to the python code?)

to get it in js easy - document.documentElement.outerHTML - but it's a long 
thing, just args and vars presumably won't work. 

what would be the best way to pass it over / to make it available in the 
code in order to send by email? 

p.s. I don't want to render page the again, as it has been already 
rendered; otherwise response.render would be an option... 

-- 
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/6745391f-8699-4042-b36d-065c27aedfa9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] form's field having special characters transmitted via request.post_vars

2019-06-20 Thread Vlad
I have a form with an input text field. 

The form is submitted via POST. 

The vars value is read and passed over into response.js to run some action. 

All works perfect until that field has special characters, like " and the 
like. Javascript does't like it. It doesn't see that as a string, but 
rather as a part of the js code so it breaks. 

How do I encode / convert that field's value so that it wouldn't affect 
html/js on the output? 

-- 
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/6bba47cd-aa85-4839-9efd-4ebcc3f45597%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] redirecting domain

2019-06-20 Thread Vlad
what's the most efficient way to redirect domain to another domain entirely 
on a level of web2py?


-- 
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/9a361343-728e-40f0-8b17-40b80abe3747%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: emailing the content of the current page

2019-06-20 Thread Vlad
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 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/f5c3795e-b9fa-45dd-af81-a853248af0d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] switching to postgres [RuntimeError: No driver of supported ones ('psycopg2',) is available]

2019-06-15 Thread Vlad
I am getting the following error:
RuntimeError: No driver of supported ones ('psycopg2',) is available

I used "pip3 install psycopg2"  and pip now reports that psycopg2 is 
installed. 

What am I still missing? What's the best (quickest, easiest, and 
hassle-free) way to use postgres from web2py? That is to say, I don't want 
to become a postgres expert - simply want to point to the postgres database 
and web2py to take care of the rest - this is exactly what DAL is about, 
isn't it? Ideally it should work out of the box, just like SQLite does...


-- 
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/0d2f5773-bc1b-439a-a390-a40a05d446e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] making a secure db connection on top of already existing SSL for the site

2019-06-15 Thread Vlad
Here is a quote from the web2py docs: 

"Making a secure connection
Sometimes it is necessary (and advised) to connect to your database using 
secure connection, especially if your database is not on the same server as 
your application. In this case you need to pass additional parameters to 
the database driver. You should refer to database driver documentation for 
details.
For PostgreSQL with psycopg2 it should look like this:
DAL('postgres://user_name:user_password@server_addr/db_name',
driver_args={'sslmode': 'require', 'sslrootcert': 'root.crt',
 'sslcert': 'postgresql.crt', 'sslkey': 'postgresql.key'})"
<>

I am wondering if this feature is still necessary for a secure db 
connection in case I anyway use SSL for the site. 

Does this secure postgres feature need to be used on top of existing SSL 
connection? Or it's rather for non-ssl site to make a db connection secure? 

-- 
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/80a95bc2-94d3-49b0-af02-9f9681b7651e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Web2py/DAL equivalent of "not in [a table]"

2019-05-14 Thread Vlad
What would be an equivalent of the following?

SELECT ID, Name 
FROM   Table1 
WHERE  ID NOT IN (SELECT ID FROM Table2)

-- 
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/84c4ac19-b87d-4e6f-8d3a-edea8ee21188%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-18 Thread Vlad
Oops, I still don't know how to achieve it. Here is why: 

This is from the javascript code on the page: 

var description = $(this).text();
var 
url='{{=URL('cart','description'),args=[id],vars=[dict(description=description)]}}';

So, the variable description belongs to javascript, and it's presumably 
impossible to access it in {{...}} sections, unless I am missing something. 
Any code in {{...}} is executed and built on the server side, and then 
delivered to the browser, so while on the server, those javascript 
variables are inaccessible. OR is there a way to somehow access them 

Of this is this case, then I am stuck to having var 
url='{{=URL('cart','description')}} and then url += description, hence I 
now have to use encoding/decoding solution... 

Is there a way to solve this without encoding / decoding??? 

On Saturday, May 18, 2019 at 9:55:22 PM UTC-4, Vlad wrote:
>
> Here is a test I've just run: 
>
> def test():
> url = URL('cart','test2',args=['a b c 1 3 2 $ % ( ) 
> !'],vars={'oops':'1 3 5  a s i t ! @ #  $ %'})
> redirect(url)
>
> def test2():
> str1 = request.args[0]
> str2 = request.vars['oops']
> return locals()
>
> Here is what it displays as a result: 
>
> {{extend 'layout.html'}}
> {{=str1}}
> 
> {{=str2}}
>
> a_b_c_1_3_2__ 
> 1 3 5 a s i t ! @ # $ % 
>
> Obviously, this proves that you're right, and my mistake in the beginning 
> was that I didn't try vars - I simply tried args, and saw right away that 
> args distorts the string. I mistakenly assumed that vars works the same way 
> - and didn't even try it. This is how I got into conversion business...  
>
> Anyway, thank you very much for all your help and for patience! 
>
> On Fri, May 17, 2019 at 7:44 PM Anthony  wrote:
>
>> On Friday, May 17, 2019 at 5:17:09 PM UTC-4, Vlad wrote:
>>>
>>> Also, I think it would be nice if URL helper would have ability to 
>>> handle this, without a need to figure out the encoding/decoding subject... 
>>>
>>
>> You don't need the encoding -- just put the values in the query string.
>>
>> Anthony
>>
>> -- 
>> 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/cyiquWAQU4w/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/e8fba811-0792-4789-b057-da6690053432%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/web2py/e8fba811-0792-4789-b057-da6690053432%40googlegroups.com?utm_medium=email_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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/f820d967-bbfe-4a24-aab6-c8a80b8cec3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: A question about ajax function (passing a string parameter over)

2019-05-18 Thread Vlad
Okay, done :) 
(Assuming that Python code in {{...}} can't access anything from Javascript 
on the page - and here encode URI came into play, as per your earlier 
advice)

var id = $('#CurrentCartId').text();
var description = $(this).text();
var url='{{=URL('cart','description')}}';
url += '/' + id + '/';
url += "?description="+description;
url=encodeURI(url);
ajax(url,[],':eval');


On Saturday, May 18, 2019 at 10:45:02 PM UTC-4, Vlad wrote:
>
> Oops, I still don't know how to achieve it. Here is why: 
>
> This is from the javascript code on the page: 
>
> var description = $(this).text();
> var 
> url='{{=URL('cart','description'),args=[id],vars=[dict(description=description)]}}';
>
> So, the variable description belongs to javascript, and it's presumably 
> impossible to access it in {{...}} sections, unless I am missing something. 
> Any code in {{...}} is executed and built on the server side, and then 
> delivered to the browser, so while on the server, those javascript 
> variables are inaccessible. OR is there a way to somehow access them 
>
> Of this is this case, then I am stuck to having var 
> url='{{=URL('cart','description')}} and then url += description, hence I 
> now have to use encoding/decoding solution... 
>
> Is there a way to solve this without encoding / decoding??? 
>
> On Saturday, May 18, 2019 at 9:55:22 PM UTC-4, Vlad wrote:
>>
>> Here is a test I've just run: 
>>
>> def test():
>> url = URL('cart','test2',args=['a b c 1 3 2 $ % ( ) 
>> !'],vars={'oops':'1 3 5  a s i t ! @ #  $ %'})
>> redirect(url)
>>
>> def test2():
>> str1 = request.args[0]
>> str2 = request.vars['oops']
>> return locals()
>>
>> Here is what it displays as a result: 
>>
>> {{extend 'layout.html'}}
>> {{=str1}}
>> 
>> {{=str2}}
>>
>> a_b_c_1_3_2__ 
>> 1 3 5 a s i t ! @ # $ % 
>>
>> Obviously, this proves that you're right, and my mistake in the beginning 
>> was that I didn't try vars - I simply tried args, and saw right away that 
>> args distorts the string. I mistakenly assumed that vars works the same way 
>> - and didn't even try it. This is how I got into conversion business...  
>>
>> Anyway, thank you very much for all your help and for patience! 
>>
>> On Fri, May 17, 2019 at 7:44 PM Anthony  wrote:
>>
>>> On Friday, May 17, 2019 at 5:17:09 PM UTC-4, Vlad wrote:
>>>>
>>>> Also, I think it would be nice if URL helper would have ability to 
>>>> handle this, without a need to figure out the encoding/decoding subject... 
>>>>
>>>
>>> You don't need the encoding -- just put the values in the query string.
>>>
>>> Anthony
>>>
>>> -- 
>>> 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/cyiquWAQU4w/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/e8fba811-0792-4789-b057-da6690053432%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/web2py/e8fba811-0792-4789-b057-da6690053432%40googlegroups.com?utm_medium=email_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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/87ff379a-31a3-40a8-8d00-51d289a58182%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] IS_NOT_EMPTY() "takes away" a dropbox with a list of items referenced by a foreign key -

2019-05-18 Thread Vlad
In the following table - 

db.define_table('products_group_content',
Field('products_group','reference 
products_group',requires=[IS_NOT_EMPTY()]),
Field('product','reference product'),
auth.signature)

when I add a record (using grid functionality or in the admin interface) - 
the products_group field doesn't have a drop box with a list of groups (it 
has a regular text edit field), even though this field is referencing 
another table. 
on the other hand, the product field does have a drop box with a list of 
products to pick from. 

Why the difference? Seems to me, in both cases the drop box should be in 
place. I have no clue why requires parameter makes any difference at all. 
What am I missing?? 

-- 
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/8cb5682c-8e67-4317-a87f-f51f05f586ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: IS_NOT_EMPTY() "takes away" a dropbox with a list of items referenced by a foreign key -

2019-05-19 Thread Vlad
got it, that makes sense - 
Thank you very much! 

On Sunday, May 19, 2019 at 10:16:58 PM UTC-4, Anthony wrote:
>
> The default validator for a reference field is IS_EMPTY_OR(IS_IN_DB(...)). 
> When SQLFORM encounters a field without an explicit "widget" specified but 
> with an IS_IN_SET or IS_IN_DB validator, it automatically generates a 
> select widget with options derived from the validator.
>
> In your case, you have replaced the default validator with your own, so 
> you no longer get the default select widget.
>
> Instead, try just use an IS_IN_DB() validator, which will require the 
> selection of a value.
>
> Anthony
>
> On Sunday, May 19, 2019 at 1:38:10 AM UTC-4, Vlad wrote:
>>
>> In the following table - 
>>
>> db.define_table('products_group_content',
>> Field('products_group','reference 
>> products_group',requires=[IS_NOT_EMPTY()]),
>> Field('product','reference product'),
>> auth.signature)
>>
>> when I add a record (using grid functionality or in the admin interface) 
>> - the products_group field doesn't have a drop box with a list of groups 
>> (it has a regular text edit field), even though this field is referencing 
>> another table. 
>> on the other hand, the product field does have a drop box with a list of 
>> products to pick from. 
>>
>> Why the difference? Seems to me, in both cases the drop box should be in 
>> place. I have no clue why requires parameter makes any difference at all. 
>> What am I missing?? 
>>
>

-- 
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/2bd2ddab-3cbb-4e25-bf6e-eeda65bbce0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: IS_NOT_EMPTY() "takes away" a dropbox with a list of items referenced by a foreign key -

2019-05-19 Thread Vlad
Got it working - 
Thank you! 

On Sunday, May 19, 2019 at 7:16:40 AM UTC-4, John Bannister wrote:
>
> Hi Vlad,
>
> I think I have come across this issue as well some time ago. Can you try 
> IS_NOT_EMPY() OR IS_IN_DB(id ...)
>
> This should hopefully bring back your drop down list.
>
> BR
> John
>

-- 
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/a39e64d3-0e98-4fd4-b1de-547d4cd3d7ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] SQL ALL & ANY operators - ?

2019-05-20 Thread Vlad
Does Web2py / DAL have an equivalent of ALL and ANY SQL operators? 

-- 
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/e5581c3f-95ab-455e-9d31-8a4302ba05db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] javascript from ajax with :eval question

2019-05-21 Thread Vlad
I am calling ajax function with :eval and setting up some javascript [from 
the controller] to be executed [as per :eval option js is executed in the 
end], something like this: 

result = "$('#DebugID').append('"
result += "CONTENT"
result += "');"
return result

Now, this works, and it displays CONTENT at the right place. 

But here is a catch: instead of "CONTENT" I want it to display an object, 
for example Rows object which is returned by db.select. 
In other words, whatever comes out when {{=rows}} is specified in html 
view, I want to send via javascript. 

Obviously, the following 2 options are grossly incorrect and don't work, 
for obvious reasons:  
   result += XML(rows)
   result += "={{rows}}"

So, how do I make the stuff display properly as passed over vial 
javascript? 
 

-- 
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/b5c204f4-6e99-4503-ab74-508d2d3a8bca%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: javascript from ajax with :eval question

2019-05-21 Thread Vlad
ALMOST :)

result += ASSIGNJS(cart=cart)
result += "$('#Debug_Discount').append(''+cart+'');"

this comes out as [object Object]

But generated Javascript (as far as the object's content is concerned) 
seems right - I think I am missing the final touch, some javascript trick 
that would print it fully.

Here is actual Javascript generated:

$('#Debug_Discount').append('');
var cart = [{"id": 125, "cart": 40, "product": 161, "quantity": 1, "price": 
3000, "imported": null, "is_active": true, "created_on": "2019-05-17 
15:47:52", "created_by": 1, "modified_on": "2019-05-17 15:47:52", 
"modified_by": 1}];
$('#Debug_Discount').append(''+cart+'');. 

Good ideas on final touch? 

On Tuesday, May 21, 2019 at 11:34:54 AM UTC-4, villas wrote:
>
> Maybe this:  ASSIGNJS
>
> http://www.web2py.com/books/default/chapter/29/05/the-views#ASSIGNJS
>
>
>
> On Tuesday, 21 May 2019 15:43:25 UTC+1, Vlad wrote:
>>
>> I am calling ajax function with :eval and setting up some javascript 
>> [from the controller] to be executed [as per :eval option js is executed in 
>> the end], something like this: 
>>
>> result = "$('#DebugID').append('"
>> result += "CONTENT"
>> result += "');"
>> return result
>>
>> Now, this works, and it displays CONTENT at the right place. 
>>
>> But here is a catch: instead of "CONTENT" I want it to display an object, 
>> for example Rows object which is returned by db.select. 
>> In other words, whatever comes out when {{=rows}} is specified in html 
>> view, I want to send via javascript. 
>>
>> Obviously, the following 2 options are grossly incorrect and don't work, 
>> for obvious reasons:  
>>result += XML(rows)
>>result += "={{rows}}"
>>
>> So, how do I make the stuff display properly as passed over vial 
>> javascript? 
>>  
>>
>

-- 
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/e69e8fd8-8a75-4d00-8c65-3b299ee6e80c%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: updating menu without reloading the page

2019-05-16 Thread Vlad
Yes sure: 

My issue was the menu item with "Cart (X)" menu item where X indicated how 
many items were currently in the cart. Since the cart was updated with ajax 
calls - I needed to update that menu item. 

This is what I've changed in the menu construction in the layout.html :

  
  {{if _item[0].startswith('Cart ('):}}
  {{=_item[0]}}
  {{else:}}
  {{=_item[0]}}
  {{pass}}
  

This if-else logic takes care of giving a proper ID to the element I need 
to update. 

The menu.py got a small addition to its response.menu += part:

('Cart (' + str(howManyItemsInCart()) + ")", False, URL('cart','show'), []),

Where howManyItemsInCart() is communicating with the database and is 
located in the model file.

The catalog view got the following in the table of products:

Add/Remove
{{=isInCartRep(aBunch,item['product.id'])}}

Clicking Add/Remove adds an item to the cart when it's not there 
beforehand, and removes it if it's already there. 

The function plus() which is ajax-called from the view (on Add/Remove 
click) returns some javascript to be executed (this allows to update 
multiple targets - the beauty of :eval option in ajax function):

final_result = "document.getElementById('CartMenuItem').innerHTML='Cart 
(" + \
   str(CartCount())+ \
   ")';document.getElementById('" + \
   target + \
   "').innerHTML='"+result+"';"

So this updates the status (eiher 'added' or 'removed') and also the menu 
item text to the current cart quantity. 

It's pretty straightforward, but somehow it took me time to figure out how 
to address that menu item as it's created dynamically... 

This kind of stuff makes our work enjoyable :)

Thank you for the inquiry! 

On Thursday, May 16, 2019 at 7:24:45 AM UTC-4, villas wrote:
>
> Hi Vlad,
> It is great that you resolved this problem.  
> Many of us use this group to search and learn from each other's 
> experiences, and it can be frustrating to read a thread of messages and 
> then simply see 'resolved' at the bottom. 
> If you have time, it would be interesting and helpful to know briefly what 
> you did.  I mean just an executive summary.  
> Many thanks!
>
>
> On Thursday, 16 May 2019 01:58:26 UTC+1, Vlad wrote:
>>
>> Never mind,
>> Resolved...
>>
>> On Wednesday, May 15, 2019 at 8:43:44 PM UTC-4, Vlad wrote:
>>>
>>> I didn't say it precisely. By web2py controlling it I meant that it's 
>>> dynamic and changes all the time - it's not static that I could assign 
>>> certain id to some item... 
>>>
>>> On Wednesday, May 15, 2019 at 7:55:26 PM UTC-4, Vlad wrote:
>>>>
>>>> Sometimes I need to change the menu without reloading the page. 
>>>>
>>>> More specifically: 
>>>>
>>>> response.menu = [
>>>> .
>>>> .
>>>> ('Cart (' + str(howManyItemsInCart()) + ")", False, 
>>>> URL('catalog','cart'), []),
>>>> ]
>>>>
>>>> I do control the event when the cart content changes (without reloading 
>>>> the page), so javascript can be inserted there; I just don't know how to 
>>>> "address" that menu item, as I don't manage it - web2py does - 
>>>>
>>>> How would I accomplish this? ... 
>>>>
>>>

-- 
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/fdf23dd9-b813-4115-8807-e8a91dcd9f9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Rows class constructor question

2019-05-20 Thread Vlad
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/5f43ccff-089c-4490-92fe-46c0c803fce5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Online store with Web2py

2019-05-06 Thread Vlad
By any chance, is there a template-like online store available? I am sure 
plenty stores have been built with web2py already...
Shouldn't be a big deal to build it, but would be nice to have something 
functional to begin with... 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Using db.table.format (i.e. format attr outside of table definition)

2019-07-03 Thread Vlad
Using the following

db.table.format = lambda row: 'test'

before SQLFORM.grid creation doesn't seem to work.

What's the proper way to set record representation outside of table definition? 

-- 
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/4b0f5f9c-ef15-4b21-8c95-c521f4b4a1d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] customizing menu items when MENU helper is used

2019-07-30 Thread Vlad
what would be the best way to specify a background color (different for 
each menu item, depending on some database-driven data) when I build the 
menu with menu.append(...) in menu.py? 

I would love to have something like this: 

menu.append([description, False, 
URL('catalog','regimen',args=[id]),[]],_style='background-color:red;')

but of course, this doesn't work this way - 


-- 
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/bbc8c801-a94e-4ce2-acb7-c3ba493278a9%40googlegroups.com.


[web2py] specifying an id of an ajax component (LOAD)

2019-06-30 Thread Vlad
I am using the LOAD helper in the view: 

{{=LOAD(c='customer',f='testimonials',extension='load',ajax=True,ajax_trap=True,content='loading
 
testimonials...',*_id='TESTIMONIALS_HERE'*)}}

The id (_id) is specified explicitly. 

However, it ignores the id parameter and produces the following: 

loading testimonials... 

What am I missing? 

-- 
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/4a07a293-6296-4aa4-b760-2643d44b13c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] switching to postgres [RuntimeError: No driver of supported ones ('psycopg2',) is available]

2019-06-16 Thread Vlad
Okay, I recreated it in a simplest form, to get rid of any extra 
parameters. Can't make it working neither on windows nor on linux. Here is 
exactly what's going on: 

*on linux: *

the following code
import psycopg2
connection = psycopg2.connect(database="test_db", user="test", password=
"x", host="xxx-994.postgres.pythonanywhere-services.com", port=10994)
executes perfect. a valid connection is received. 

However, when I specify exactly same in the appconfig 
( 
postgres://test:x?!@xxx-994.postgres.pythonanywhere-services.com:10994/test_db
 
) it fails with the following error:
psycopg2.OperationalError: FATAL: password authentication failed for user 
"test"

The user and the password are correct though - besides creating a 
connection successfully by the code above, I've also verified in postgres 
itself, to make sure that the user was created successfully and that the 
permissions were given correctly. So it makes no sense that password 
authentication fails. 

*and here is what I have on windows: *

the code above doesn't even create a valid connection. Here is the error: 
"OperationalError(could not connect to server: Connection timed out 
(0x274C/10060) Is the server running on host 
"xxx-994.postgres.pythonanywhere-services.com" (10.0.0.70) and accepting 
TCP/IP connections on port 10994? )"

and when I specify the db in appconfig, it's a similar error (just coming 
from web2py wrapper, I guess): "psycopg2.OperationalError: could not 
connect to server: Connection timed out (0x274C/10060) Is the server 
running on host "xxx-994.postgres.pythonanywhere-services.com" (10.0.0.70) 
and accepting TCP/IP connections on port 10994?"

*So psycopg2 at this point is present and found by Python *(not even sure 
what was the problem before, when it couldn't be found on windows), but *on 
windows connection fails, while on linux password authentication fails*.

Greatly appreciate any ideas. 



On Sunday, June 16, 2019 at 7:54:20 AM UTC-4, Vlad wrote:
>
> On this one I run web2py on Windows. Using web2py from source. No idea 
> what virtualenv is, so presumably not using it. Installed psycopg2 with 
> pip3 specifically, to make sure it goes into the right Python. (I am not 
> too familiar with this, but anything I install with pip goes to Python 2, 
> and pip3 puts everything under Python 3 which I use for web2py). And yes, 
> this is my development computer, so I restart web2py every time. 
>
> On Sun, Jun 16, 2019, 7:21 AM Val K  wrote:
>
>> Did you restart web2py after installation? 
>>
>> -- 
>> 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/UINJvjQAyZk/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/f86e442f-924a-4c97-b773-7865277006c4%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/594aed4f-eda6-48c0-8119-66efc93cf7ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Using db.table.format (i.e. format attr outside of table definition)

2019-07-07 Thread Vlad
Please help! Any way to use this format property outside of a table definition? 

-- 
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/361da361-d199-4d83-af90-89a8a8524a2a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] auth_membership grid with both, group id and group roles displayed when adding a new record

2019-10-07 Thread Vlad
the following line works perfectly: 

grid = SQLFORM.grid(db.auth_membership)

by "perfect" in the context, I mean that when I click "add record", the 
group id field contains both values, group id and group role (for example, 
"Manager (4)", "Loyal customer (9)", ... 

However, I want to limit what kind of membership a user can create, so here 
is what I do: 

   ids = [1,3,5]
   db.auth_membership.group_id.requires = IS_IN_SET(ids)
   grid = SQLFORM.grid(db.auth_membership)

This indeed limits group id field value that a user can specify when 
creating a new record. When clicking "Add record", the group id field is 
represented by a drop-down with the values "1, 3, 5", as expected. 

The problem is that now when limited to 1, 3, and 5, no roles are 
displayed. Only group id integer values are (to reiterate, without this 
limitation to 1,3,5 the drop-down contains both, group id and group role 
for each line, for all the groups). 

How can I ensure that the roles are also displayed, in addition to group 
ids, on add record, when using  requires=IS_IN_SET ? 

-- 
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/bbc19ca8-7701-43c3-a14d-2ac36639dbfe%40googlegroups.com.


[web2py] Re: auth_membership grid with both, group id and group roles displayed when adding a new record

2019-10-07 Thread Vlad
I don't fully understand it - will play with it to figure it out. 
Annet's suggestion worked right away, but still I really want to understand 
what's going on...
thank you!  

On Monday, October 7, 2019 at 6:38:24 AM UTC-4, villas wrote:
>
> By specifying requires = IS_IN_SET(ids), you are also overriding the 
> represent 
> too.
>
> See below, I hope it will point you in the right direction:
>
> mygroupdict = {1:'Public',2:'Private',3:'Admin'}
> db.auth_membership.group_id.requires = IS_IN_SET(mygroupdict,zero=None))
> db.auth_membership.group_id.represent = lambda group_id, row: mygroupdict[
> group_id]
>
>

-- 
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/678ca1e7-d349-4d10-bcb7-a6414746ab91%40googlegroups.com.


[web2py] Re: auth_membership grid with both, group id and group roles displayed when adding a new record

2019-10-07 Thread Vlad
thank you very much! 
works like a charm! 

On Monday, October 7, 2019 at 6:36:02 AM UTC-4, Annet wrote:
>
> Use IS_IN_DB()
>
>ids = [1,3,5]
>>
>
>
> db.auth_membership.group_id.requires = 
> IS_IN_DB(db(db.auth_group.id.belongs(ids)), 'auth_group.id', '%(role)s')
>
>
> Best,
>
> Annet
>

-- 
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/92ac0728-e22d-4411-b13d-520909dc37d1%40googlegroups.com.


  1   2   3   >