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

2019-05-30 Thread Dave S


On Thursday, May 30, 2019 at 1:45:14 PM UTC-7, Vlad wrote:
>
> Oops, just found an answer here by Anthony from 8 years ago about 
> form.vars.id :)
> Thank you, Anthony! 


Thumbs up -- that you found the answer, and also because I'm often 
appreciating Anthony's efforts. 

/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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/b9e2e46e-7add-48d5-bb30-f54950240b5c%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] Re: web2py belongs if none

2019-05-30 Thread Val K

why not just:
# start to form query:
q = db.counters.c_date >= datum_od
if ...: # continue to form the query depending on conditions  
   q &=...belongs(...)

# the same with `left`
left = ...
if ...:
   left.append(...)

# and fields
if ...:
   fields = [...]
else:
   fields = [...]

# at the end
rows = db(q).select(*fields, left = left)





On Thursday, May 30, 2019 at 4:41:52 PM UTC+3, Yebach wrote:
>
> Hello
>
> I have a query where the possibility for belongs can be a set of values or 
> it can be empty. 
> In case the set is empty I want the query to act as 1=1 and not 1=0, so 
> all values would be selected.
>
> Any suggestions??
>
> Thank you
>
> This is my query
>
> selected = list(selected_values_str.split(","))
> selected_int  = tuple([int(i) for i in selected])
> rows = db((db.counters.c_date >= datum_od) &
> (db.counters.c_user_inserted.belongs(selected_int)) &
> (db.counters.c_date <= datum_do) &
> (db.machines.m_status != 
> 100)).select(#db.counters.c_machine_id,
>   db.counters.c_total,
>   db.counters.c_black,
>   db.counters.c_color,
>   db.counters.c_level1,
>   db.counters.c_level2,
>   db.counters.c_level3,
>   
> db.counters.c_a3_color,
>   db.counters.c_date,
>   
> db.counters.c_datetime,
>   
> db.counters.c_datetime_dataread,
>   db.counters.c_scans,
>   db.counters.c_note,
>db.machines.m_code,
>   
>  db.auth_user.first_name,
>   
>  db.auth_user.last_name,
>db.auth_user.email,
>   
>  left=[db.machines.on(db.counters.c_machine_id == db.machines.id),
> 
>  db.auth_user.on(db.counters.c_user_inserted== db.auth_user.id)]
>   ).as_list()
>

-- 
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/45236860-31a6-4648-8a6c-65e159d1d972%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] web2py belongs if none

2019-05-30 Thread Yebach
Hello

I have a query where the possibility for belongs can be a set of values or 
it can be empty. 
In case the set is empty I want the query to act as 1=1 and not 1=0, so all 
values would be selected.

Any suggestions??

Thank you

This is my query

selected = list(selected_values_str.split(","))
selected_int  = tuple([int(i) for i in selected])
rows = db((db.counters.c_date >= datum_od) &
(db.counters.c_user_inserted.belongs(selected_int)) &
(db.counters.c_date <= datum_do) &
(db.machines.m_status != 
100)).select(#db.counters.c_machine_id,
  db.counters.c_total,
  db.counters.c_black,
  db.counters.c_color,
  db.counters.c_level1,
  db.counters.c_level2,
  db.counters.c_level3,
  
db.counters.c_a3_color,
  db.counters.c_date,
  
db.counters.c_datetime,
  
db.counters.c_datetime_dataread,
  db.counters.c_scans,
  db.counters.c_note,
   db.machines.m_code,
  
 db.auth_user.first_name,
  
 db.auth_user.last_name,
   db.auth_user.email,
  
 left=[db.machines.on(db.counters.c_machine_id == db.machines.id),

 db.auth_user.on(db.counters.c_user_inserted== db.auth_user.id)]
  ).as_list()

-- 
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/32d92a1e-9964-4ed2-a76c-fe4b7d19fe54%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: CSV Dowload

2019-05-30 Thread Kim Cuc
Thanks so much.

On Thu, May 30, 2019 at 2:43 AM Quang Lam 
wrote:

> Hi Steve, the code mentioned in the book is only for export to CVS file.
> my situation is to download the CVS file stored in the table
>
> On Wed, May 29, 2019 at 12:01 PM 黄祥  wrote:
>
>> ref:
>>
>> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Exporting-and-importing-data
>>
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/web2py/a157283a-534f-44f9-8861-763768f0c6ca%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/CAKDykLhfGFRBZi%3DW5NmqONbynTXbfaMF966kU_QnTNkHPgvb-A%40mail.gmail.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/CADrHZPnjxw8dOdTmQrAdtsjrDUYHrd1KJyoFi%2Bgo%2B%2B-QtuWKnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web3py

2019-05-30 Thread 黄祥
just clarficiation, is it correct or it should be python3 setup.py sdist
*web3py/Makefile*
deploy: test
python setup.py sdist

*web3py/setup.py*
install_requires=[
...
],
is not same like *web3py/requirements.txt*
perhaps can create a reference that install_requires in web3py/setup.py is 
reference to web3py/requirements.txt, not sure just a suggestion

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/4bb1bedb-c3bd-41b7-8883-8f66f3e83cf1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web3py

2019-05-30 Thread 黄祥
*Dockerfile*
# please change :
# password.txt with your desire filename
# password_admin with your desire password admin
# 8000 with your available port

FROM ubuntu:latest

RUN apt update && \
 apt install -y git python3-pip python-pip memcached && \
 service memcached restart

RUN groupadd -r web3py && \
 useradd -m -r -g web3py web3py

USER web3py

RUN rm -rf /home/web3py/web3py && \
 cd /home/web3py/ && \
 git clone https://github.com/web2py/web3py && \
 cd web3py && \
 pip3 install pytest mechanize twine && \
 pip3 install -U -r requirements.txt && \
 make test && \
 python3 -c "from pydal.validators import CRYPT; 
open('password.txt','w').write(str(CRYPT()('password_admin' )[0] ) )" && \
 mkdir apps/examples/databases 

WORKDIR /home/web3py/web3py

EXPOSE 8000

CMD ["./web3py-start", "-p", "./password.txt", "-a", "0.0.0.0:8000", 
"./apps"]

*steps to run from Dockerfile (different from prev message)*
cat << EOF > Dockerfile
# please change :
# password.txt with your desire filename
# password_admin with your desire password admin
# 8000 with your available port

FROM ubuntu:latest

RUN apt update && \
 apt install -y git python3-pip python-pip memcached && \
 service memcached restart

RUN groupadd -r web3py && \
 useradd -m -r -g web3py web3py

USER web3py

RUN rm -rf /home/web3py/web3py && \
 cd /home/web3py/ && \
 git clone https://github.com/web2py/web3py && \
 cd web3py && \
 pip3 install pytest mechanize twine && \
 pip3 install -U -r requirements.txt && \
 make test && \
 python3 -c "from pydal.validators import CRYPT; 
open('password.txt','w').write(str(CRYPT()('password_admin' )[0] ) )" && \
 mkdir apps/examples/databases 

WORKDIR /home/web3py/web3py

EXPOSE 8000

CMD ["./web3py-start", "-p", "./password.txt", "-a", "0.0.0.0:8000", 
"./apps"]

EOF
cat Dockerfile
docker build -t test/ubuntu-web3py .
docker run -d \
 -v apps:/home/web3py/web3py/apps \
 -p 8000:8000 \
 --name ubuntu-web3py \
 test/ubuntu-web3py
docker ps 
docker run -it --privileged test/ubuntu-web3py /bin/bash

submited pr for dockerfile

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/e48d9947-2fd9-44ed-8e77-0c090d55f53c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Web3py

2019-05-30 Thread 黄祥
*suggestion for apps/_scaffold:*
*- form validation not work during login and register*
** during register : *
form field password and password (again) allow mismatched input (this case 
happen just in web form field, not in database table, when insert mismatch 
database table remain empty)
** during login : *
form validation not work allow empty email and password, while should be 
appears in web form field, the error traceback written in terminal 
*- better 'explicit than implicit' lesson learned from web2py password :*
* better to have a parameter for developer to set password complexity (min 
input, allow uppercase, numeric, etc) in password form field 
* better explicit the password hash stored in database (sha11, md5, or 
combination among them), it's ok, to have the default, but sometime when 
web2py dev want to continue the project that already have the user table, 
not sure how to face it. 
perhaps if you can have a solution for this, it will be great for web2py n 
web3py

*suggestion general*
- before release please check all the python code with bandit especially in 
web3py/web3py folders (already reported in another thread)

error found during testing _scaffold login
ERROR:root:Traceback (most recent call last):
  File "/Users/sugizo/learn/python/web3py/web3py/core.py", line 397, in 
wrapper
ret = func(*func_args, **func_kwargs)
  File "/Users/sugizo/learn/python/web3py/web3py/core.py", line 366, in 
wrapper
ret = func(*args, **kwargs)
  File "/Users/sugizo/learn/python/web3py/web3py/utils/auth.py", line 102, 
in responder
return self.action(path, request.method, request.query, request.json)
  File "/Users/sugizo/learn/python/web3py/web3py/utils/auth.py", line 131, 
in action
user, error = self.login(**vars)
TypeError: login() missing 2 required positional arguments: 'email' and 
'password'

id= 1

after successful registered in terminal got :
Mock send to a...@a.com subject "Confirm email" body:
Welcome a, click 
http://localhost:8000/_scaffold/auth/api/verify_email?token=8afa1f35-6af5-4bef-a6d1-7fe87f9beef9
 
to confirm your email

when following the url in browser got :
{
  "code": 401,
  "message": "not authoried",
  "status": "error"
}

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/e0e09b08-edf5-4d94-9c1c-5fa42ab4c3cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] python 3 / web2py 2.18.5 - Sequence of bytes expected error

2019-05-30 Thread Sundar
When I try to run the above version under Apache (2.4), welcome app screen 
comes. When I click on 'Admin' button, an error message is displayed. 
Apache log shows the error as TypeError: sequence of byte string values 
expected, value of type str found\r, referer: 
http://localhost:85/welcome/default/index. I get the same error when I try 
to invoke admin application directly too. 

The application runs OK directly under web2py on console mode.

Am I doing anything wrong? No coding has been added - other than changes in 
apache httpd conf.

-- 
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/bdc2788a-1d67-48ca-bc1f-cf987400d9bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How can I generate hash for user password like web2py

2019-05-30 Thread Константин Комков
As I understand entrant came on foot and take to operator personal data. 
After that I know entrants email and can generate link for it. Yes?

-- 
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/48148653-06ce-472c-b1a8-959b65617d07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.