[web2py] Re: Problem w/ v2.16.1 & python3 & rest api

2018-01-04 Thread Dave S


On Thursday, January 4, 2018 at 1:07:24 PM UTC-8, Scott Hunter wrote:
>
> If I try to user curl to call the api_get_user_email function in the 
> default controller of the welcome app, using a fresh copy of web2py & under 
> python 3.6.3, the following ticket gets generated:
>
>  a bytes-like object is required, not 'str'Version
> web2py™ Version 2.16.1-stable+timestamp.2017.11.14.05.54.25Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
>
> Traceback (most recent call last):
>   File "/Users/shunter/Dropbox/web2py-v2.16.1/gluon/restricted.py", line 219, 
> in restricted
> exec(ccode, environment)
> TypeError: a bytes-like object is required, not 'str'
> [...]
>
>  

> Any guidance as to what needs to be fixed would be appreciated.
>
>
> - Scott
>

I'd say it was a place where the port to Python 3 was incomplete.  Have you 
tried using the  API url in Python 3 before?  If you set up the same test 
using a Python 2 environment, does it work?

/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] web2py gunicorn dockerfile

2018-01-04 Thread 黄祥
just wondering why gunicorn dockerfile with web2py/anyserver.py is not work 
when use with python:2.7 image
e.g.
*step i took*
cat < Dockerfile
FROM python:2.7
RUN apt update && \
 apt install -y unzip wget gunicorn
RUN groupadd -r web2py && \
 useradd -m -r -g web2py web2py
USER web2py
RUN cd /home/web2py/ && \
 wget -c http://web2py.com/examples/static/web2py_src.zip && \
 unzip -o web2py_src.zip && \
 rm -rf /home/web2py/web2py/applications/examples && \
 chmod 755 -R /home/web2py/web2py
EXPOSE 80
CMD cd ~ && python /home/web2py/web2py/anyserver.py -s gunicorn -i 0.0.0.0 
-p 80
EOF
docker build .
docker images
docker run -p 80:80 imageid

*result*
starting gunicorn on 0.0.0.0:80...
Traceback (most recent call last):
  File "/home/web2py/web2py/anyserver.py", line 365, in 
main()
  File "/home/web2py/web2py/anyserver.py", line 362, in main
options=options)
  File "/home/web2py/web2py/anyserver.py", line 314, in run
getattr(Servers, servername)(application, (ip, int(port)), 
options=options)
  File "/home/web2py/web2py/anyserver.py", line 137, in gunicorn
from gunicorn.app.base import Application
ImportError: No module named gunicorn.app.base

but it works well when using ubuntu latest image
*e.g.*
*step i took*
cat < Dockerfile
FROM ubuntu:latest
RUN apt update && \
 apt install -y python python-pip python-setuptools unzip vim wget gunicorn 
&& \
 pip install --upgrade pip && \
 pip install virtualenv && \
 virtualenv /home/site && \
 rm -rf /home/site/web2py && \
 cd /home/site/ && \
 rm -f web2py_src.zip && \
 wget -c http://web2py.com/examples/static/web2py_src.zip && \
 unzip -o web2py_src.zip && \
 rm -rf /home/site/web2py/applications/examples && \
 chmod 755 -R /home/site/web2py
EXPOSE 80 
CMD . /home/site/bin/activate && /usr/bin/python 
/home/site/web2py/anyserver.py -s gunicorn -i 0.0.0.0 -p 80
EOF
docker build .
docker images
docker run -p 80:80 imageid

all tested in https://labs.play-with-docker.com

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


[web2py] Re: How to select row based on item ID or name

2018-01-04 Thread Paul Ellis
You would still get a Rows Object though, even though there is only 1 row 
in it. 
You would need .first() .last() or [0] at the end to get just the row.
Or use the shortcut method.

db.table[id]



On Thursday, 4 January 2018 18:24:26 UTC+1, Dave S wrote:
>
>
>
> On Wednesday, January 3, 2018 at 10:48:32 PM UTC-8, Maurice Waka wrote:
>>
>>
>>
>>
>>
>>
>>
>> I have the following code for my DB:
>> dbmyhealth.define_table("health", 
>> Field('name', 'string'),
>> Field('definition', 'text', length= 100,),
>> Field('abnval', 'text', length= 100,),
>> Field('normval', 'text', length= 100,),
>> Field('administration', 'text', length= 
>> 100,),
>> Field('screening', 'text', length= 100,),
>> Field('causes', 'text', length= 100,),
>> migrate = False)
>>
>> rows  = dbmyhealth().select(dbmyhealth.health.ALL)
>> for row in rows: 
>> location0 = row.name
>> location1 = row.definition
>> location2 = row.abnvalinterpret
>> location3 = row.normvalinterpret
>> location4 = row.administration
>> location5 = row.screening
>> location6 = row.causes
>> corpus = [location1 , location2, location3, location4, location5, 
>> location6]
>>
>> I want to select an item, including all the fields from the abnval to the 
>> causes,not randomly but based on the ID or the name. If I use the limitby 
>> constraint,I can get either the first, second, or last item based on the 
>> selection used. If I use the below code, I get only the first item, which 
>> is everything based on obesity. I want to select any item with every query 
>> using either an ID or the names below e.g.
>> A code like: 
>> for row in rows:
>> if id == 2
>> code..
>>corpus = [location1 , location2, location3, location4, 
>> location5, location6]in this case my corpus will have everything on 
>> cardiomyopathy using the table details below.
>>
>> id name
>> 0. diabetes
>> 1. hypertension
>> 2. cardiomyopathy
>> 3. copd
>> 4. obesity
>>
>> So how do I code it to obtain my answer
>> Kind regards
>>
>>
> Wouldn't that be either of
>
>   rows = dbmyhealth(dbmyhealth.health.id == 2).select()
>
>
>
> or (if you were doing more with the query)
>
>   query = dbmyhealth.health.id == 2
>   rows  = dbmyhealth(query).select()
>
>
> ?
> (I didn't put in a first() because there's only 1 row with id == 2.)
>
>  http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Query--Set--Rows
> >
>
> /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] Re: execute web2py modules in terminal on 2.16.1

2018-01-04 Thread 黄祥
it works well now, thanks alex and anthony

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


[web2py] Requesting button names for grid and smartgrid

2018-01-04 Thread Paul Ellis
Would it be possible to name the grid buttons and smartgrid table links?

This would make it pretty easy to tweak the buttons.
For example. I would like to change the Delete button to red.
I can do it like this:
rowBtns = grid.elements('div', _class = 'row_buttons')
if rowBtns:
   for row in rowBtns:
  row[-1].update(_class = 'button btn btn-danger')

But when I am changing a table link in a smartgrid there needs to be extra 
code to change the table link in the grid and in any forms which are 
created by it.

It could be something like this:
delBtns = grid.elements('a', _name = deleteBtn)
if delBtns:
for delBtn.update(_class = 'button btn btn-danger')

and then whenever this button is being used by the grid / forms etc it will 
appear correctly. Also highlighting a specific button becomes easier. 
Select TR by id and button by name.

names for the table links could be:
if multi_links:
name = [tablename]_[fieldname] + 'Btn'
else:
name = [tablename] + 'Btn'

the other grid button names, I think, should hold roughly with the function 
argument names that control them.
'createBtn', 'detailsBtn', 'editBtn'

-- 
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: execute web2py modules in terminal on 2.16.1

2018-01-04 Thread Anthony
On Thursday, January 4, 2018 at 11:47:18 AM UTC-5, Alex Beskopilny wrote:
>
> Hi! 
> replace print "install"
> with print ("install")
>

The reason you now need to use the print() function instead of the print 
statement when running code via the web2py shell (even with Python 2), is 
that in the gluon.shell module, the print function is imported from 
__future__.

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.


[web2py] Problem w/ v2.16.1 & python3 & rest api

2018-01-04 Thread Scott Hunter
If I try to user curl to call the api_get_user_email function in the 
default controller of the welcome app, using a fresh copy of web2py & under 
python 3.6.3, the following ticket gets generated:

 a bytes-like object is required, not 'str'Version
web2py™ Version 2.16.1-stable+timestamp.2017.11.14.05.54.25Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.

Traceback (most recent call last):
  File "/Users/shunter/Dropbox/web2py-v2.16.1/gluon/restricted.py", line 219, 
in restricted
exec(ccode, environment)
TypeError: a bytes-like object is required, not 'str'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/shunter/Dropbox/web2py-v2.16.1/gluon/restricted.py", line 141, 
in __init__
self.traceback = traceback.format_exc()
AttributeError: 'NoneType' object has no attribute 'strip'

In file: 
/Users/shunter/Dropbox/web2py-v2.16.1/applications/welcome/controllers/default.py

1.

 at 0x109a970c0, file 
"/Users/shunter/Dropbox/web2py-v2.16.1/applications/welcome/controllers/default.py",
 line 8>



As I haven't introduced any code to this setup, either there is a bug or I 
am calling this incorrectly; here's the curl command:

curl --user username:password 
http://127.0.0.1:8000/welcome/default/api_get_user_email


Any guidance as to what needs to be fixed would be appreciated.


- Scott

-- 
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: {Disarmed} Re: [web2py] Date widget seems boroken on 2.16.1

2018-01-04 Thread Yoel Benítez Fonseca
no problem, it took me a time to get it right, sorry don't have enough 
time to put a PR.


On Thu, Jan 4, 2018 at 3:14 PM, Carlos Cesar Caballero Díaz 
 wrote:
Thanks Yoel, the issue is in the Welcome app Spanish translation, in 
the released 2.16.1 version and in the master branch, I will try to 
submit a PR with the fix asap.


Greetings.

El 04/01/18 a las 13:14, Yoel Benítez Fonseca escribió:
Go to the languages/*.py and search for a translatión of the date 
format. Also edit


web2py_ajax.html


It is posible have being edited/modified.

On Wed, Jan 3, 2018 at 12:20 PM, Carlos Cesar Caballero Díaz 
 wrote:
Hi guys, is just me, or the date widget seems broken on 2.16.1 (see 
attached image)?



Greetings.

--
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 MailScanner ha detectado un intento de 
fraude en la siguiente página web "groups.google.com". No confíe 
en esta página web: MailScanner ha detectado un intento de fraude 
en la siguiente p�gina web "groups.google.com". No conf�e en 
esta p�gina web: 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 MailScanner ha detectado un intento de 
fraude en la siguiente página web "groups.google.com". No confíe 
en esta página web: MailScanner ha detectado un intento de fraude 
en la siguiente p�gina web "groups.google.com". No conf�e en 
esta p�gina web: 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.


--
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: smartgrid - limit dropdown menu items in edit form

2018-01-04 Thread Paul Ellis
Your assumption is correct and the solution worked perfectly. I didn't
realise I could use the requires method in that way. I have now read more
about it.

Thanks

On Tue, Jan 2, 2018 at 3:25 PM, Jim S  wrote:

> I'm assuming you have a company_id added to your auth_user table to
> identify which company a user belongs to.
>
> If that is correct, then I'd add the following ahead of the
> SQLFORM.smartgrid call
>
> db.offer.user_id.requires = IS_IN_DB(db(db.auth_user.company_id == auth.
> user.company_id), db.auth_user, '%(first_name)s %(last_name)s', zero='Select
> User...')
>
> ...or something like that.  I didn't test the solution.  Read more about
> it here http://web2py.com/books/default/chapter/29/07/forms-
> and-validators#Database-validators
>
>
> Another option would be to add a common filter, possibly in your db.py
> file to apply this rule to the entire site.
>
> http://web2py.com/books/default/chapter/29/06/the-
> database-abstraction-layer?search=common+filter#Common-filters
>
>
>
> On Monday, January 1, 2018 at 4:51:33 PM UTC-6, Paul Ellis wrote:
>>
>> I want to start using a smartgrid to browse a couple of tables as an
>> admin tool.
>> There are a couple of companies using the same database.
>> When an admin edits an 'Offer' I want them to be able to change the
>> user_id. Effectively assigning the offer to a different staff member in the
>> event of staff changes or holidays etc.
>>
>> The problem is the drop down menu shows all users in the database, not
>> just the users which belong to the company in question.
>>
>> db.define_table(
>> 'offer',
>> Field('offer_number', 'integer', unique=True, label = T('Offer
>> Number')),
>> Field('user_id','reference auth_user', label = T('Created By'),
>> ondelete = 'SET NULL'),
>> Field('customer_id','reference customer', requires=IS_NOT_EMPTY(),
>> label = T('Customer Name')),
>> Field('reseller_id','reference reseller', requires=IS_NOT_EMPTY(),
>> label = T('Business Name')),
>> Field('created_on', 'datetime', default=request.now, writable=False,
>> label=T('Created On')),
>> Field('updated_on', 'datetime', default=request.now, writable=False,
>> label=T('Updated On')),
>> singular = T('Offer'),
>> plural = T('Offers'),
>> )
>>
>> db.define_table(
>> 'remarks',
>> Field('offer_id', 'reference offer', requires=IS_NOT_EMPTY()),
>> Field('remorder', 'integer', label=T('Postion')),
>> Field('remark', 'text', label=T('Remarks')),
>> singluar = T('Remark'),
>> plural = T('Remarks'),
>> )
>>
>>
>> and the grid:
>> @auth.requires_membership('business leader')
>> def offers():
>> pagetitle = 'offers'
>> buttongroup = []
>>
>>
>> db.offer.offer_number.writable = False
>> db.offer.reseller_id.writable = False
>> db.offer.reseller_id.readable = False
>> # db.offer.user_id.writable = False
>>
>> pagecontent = SQLFORM.smartgrid(
>> db.offer,
>> details = False,
>> constraints = {
>> 'offer' : db.offer.reseller_id == session.auth.user.
>> reseller_id,
>> },
>> linked_tables = [
>> 'offer',
>> 'remarks',
>> ],
>> fields = {
>> 'offer' : [
>> db.offer.offer_number,
>> db.offer.user_id,
>> db.offer.customer_id,
>> db.offer.created_on,
>> db.offer.updated_on,
>> ],
>> },
>> )
>>
>> response.view = 'tooladmin_core.html'
>> return dict(
>> pagetitle = pagetitle,
>> buttongroup = buttongroup,
>> pagecontent = pagecontent,
>> )
>>
>>
>>
>>
>> --
> 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/3VwXtWiCqP8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@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.


{Disarmed} Re: [web2py] Date widget seems boroken on 2.16.1

2018-01-04 Thread Carlos Cesar Caballero Díaz
Thanks Yoel, the issue is in the Welcome app Spanish translation, in the 
released 2.16.1 version and in the master branch, I will try to submit a 
PR with the fix asap.


Greetings.


El 04/01/18 a las 13:14, Yoel Benítez Fonseca escribió:
Go to the languages/*.py and search for a translatión of the date 
format. Also edit


web2py_ajax.html


It is posible have being edited/modified.

On Wed, Jan 3, 2018 at 12:20 PM, Carlos Cesar Caballero Díaz 
 wrote:
Hi guys, is just me, or the date widget seems broken on 2.16.1 (see 
attached image)? Greetings.

--
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 
*MailScanner ha detectado un intento de fraude en la siguiente p�gina 
web "groups.google.com". /No/ conf�e en esta p�gina web:* 
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 *MailScanner ha detectado un intento de fraude 
en la siguiente p�gina web "groups.google.com". /No/ conf�e en esta 
p�gina web:* 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.


Re: [web2py] Re: How to select row based on item ID or name

2018-01-04 Thread Yoel Benítez Fonseca

You can get algo a row by ID by:

row = db.model_name(ID)

Where ID stand for the actual record id.

On Thu, Jan 4, 2018 at 1:13 PM, Maurice Waka  
wrote:

Second option is better for me

On 4 Jan 2018 8:24 PM, "Dave S"  wrote:



On Wednesday, January 3, 2018 at 10:48:32 PM UTC-8, Maurice Waka 
wrote:







I have the following code for my DB:
dbmyhealth.define_table("health",
Field('name', 'string'),
	Field('definition', 'text', length= 
100,),
	Field('abnval', 'text', length= 
100,),
	Field('normval', 'text', length= 
100,),
	Field('administration', 'text', 
length= 100,),
	Field('screening', 'text', length= 
100,),
	Field('causes', 'text', length= 
100,),

migrate = False)

rows  = dbmyhealth().select(dbmyhealth.health.ALL)
for row in rows:
location0 = row.name
location1 = row.definition
location2 = row.abnvalinterpret
location3 = row.normvalinterpret
location4 = row.administration
location5 = row.screening
location6 = row.causes
corpus = [location1 , location2, location3, location4, 
location5, location6]


I want to select an item, including all the fields from the abnval 
to the causes,not randomly but based on the ID or the name. If I 
use the limitby constraint,I can get either the first, second, or 
last item based on the selection used. If I use the below code, I 
get only the first item, which is everything based on obesity. I 
want to select any item with every query using either an ID or the 
names below e.g.

A code like:
for row in rows:
if id == 2
code..
   corpus = [location1 , location2, location3, location4, 
location5, location6]in this case my corpus will have 
everything on cardiomyopathy using the table details below.


id name
0. diabetes
1. hypertension
2. cardiomyopathy
3. copd
4. obesity

So how do I code it to obtain my answer
Kind regards



Wouldn't that be either of

  rows = dbmyhealth(dbmyhealth.health.id == 2).select()



or (if you were doing more with the query)

  query = dbmyhealth.health.id == 2
  rows  = dbmyhealth(query).select()


?
(I didn't put in a first() because there's only 1 row with id == 2.)



/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 a topic in 
the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/web2py/5DWqynKI_-g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
web2py+unsubscr...@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.


--
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] Date widget seems boroken on 2.16.1

2018-01-04 Thread Yoel Benítez Fonseca
Go to the languages/*.py and search for a translatión of the date 
format. Also edit


web2py_ajax.html


It is posible have being edited/modified.

On Wed, Jan 3, 2018 at 12:20 PM, Carlos Cesar Caballero Díaz 
 wrote:
Hi guys, is just me, or the date widget seems broken on 2.16.1 (see 
attached image)?



Greetings.

--
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.


--
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: How to select row based on item ID or name

2018-01-04 Thread Maurice Waka
Second option is better for me

On 4 Jan 2018 8:24 PM, "Dave S"  wrote:

>
>
> On Wednesday, January 3, 2018 at 10:48:32 PM UTC-8, Maurice Waka wrote:
>>
>>
>>
>>
>>
>>
>>
>> I have the following code for my DB:
>> dbmyhealth.define_table("health",
>> Field('name', 'string'),
>> Field('definition', 'text', length= 100,),
>> Field('abnval', 'text', length= 100,),
>> Field('normval', 'text', length= 100,),
>> Field('administration', 'text', length=
>> 100,),
>> Field('screening', 'text', length= 100,),
>> Field('causes', 'text', length= 100,),
>> migrate = False)
>>
>> rows  = dbmyhealth().select(dbmyhealth.health.ALL)
>> for row in rows:
>> location0 = row.name
>> location1 = row.definition
>> location2 = row.abnvalinterpret
>> location3 = row.normvalinterpret
>> location4 = row.administration
>> location5 = row.screening
>> location6 = row.causes
>> corpus = [location1 , location2, location3, location4, location5,
>> location6]
>>
>> I want to select an item, including all the fields from the abnval to the
>> causes,not randomly but based on the ID or the name. If I use the limitby
>> constraint,I can get either the first, second, or last item based on the
>> selection used. If I use the below code, I get only the first item, which
>> is everything based on obesity. I want to select any item with every query
>> using either an ID or the names below e.g.
>> A code like:
>> for row in rows:
>> if id == 2
>> code..
>>corpus = [location1 , location2, location3, location4,
>> location5, location6]in this case my corpus will have everything on
>> cardiomyopathy using the table details below.
>>
>> id name
>> 0. diabetes
>> 1. hypertension
>> 2. cardiomyopathy
>> 3. copd
>> 4. obesity
>>
>> So how do I code it to obtain my answer
>> Kind regards
>>
>>
> Wouldn't that be either of
>
>   rows = dbmyhealth(dbmyhealth.health.id == 2).select()
>
>
>
> or (if you were doing more with the query)
>
>   query = dbmyhealth.health.id == 2
>   rows  = dbmyhealth(query).select()
>
>
> ?
> (I didn't put in a first() because there's only 1 row with id == 2.)
>
>  database-abstraction-layer#Query--Set--Rows>
>
> /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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/5DWqynKI_-g/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@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: web2py 2.16.1 is OUT

2018-01-04 Thread tim . nyborg
My interim solution for computed fields is to set writable=False.  It's 
fixed problems with form submission.

On Tuesday, 2 January 2018 19:02:30 UTC, José Leite wrote:
>
> It seems that compute fields are not working anymore with web2py 2.16.1.
> Can not generate thumbnails anymore.
>
> Is there a fix for that?
>
> terça-feira, 14 de Novembro de 2017 às 05:59:52 UTC, Massimo Di Pierro 
> escreveu:
>>
>> web2py 2.16.1 is OUT
>>
>> Lots of bugs fixes contributed by the community. Thanks Leonel, Paolo, 
>> Giovanni, and all those who contributed.
>>
>> the most visible changes are:
>>
>> - welcome now defaults to bootstrap 4
>> - lots of cleanup in the welcome app and new examples in default.py
>> - simplified layout.html
>>
>> Massimo 
>>
>>
>>
>>

-- 
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 to select row based on item ID or name

2018-01-04 Thread Dave S


On Wednesday, January 3, 2018 at 10:48:32 PM UTC-8, Maurice Waka wrote:
>
>
>
>
>
>
>
> I have the following code for my DB:
> dbmyhealth.define_table("health", 
> Field('name', 'string'),
> Field('definition', 'text', length= 100,),
> Field('abnval', 'text', length= 100,),
> Field('normval', 'text', length= 100,),
> Field('administration', 'text', length= 
> 100,),
> Field('screening', 'text', length= 100,),
> Field('causes', 'text', length= 100,),
> migrate = False)
>
> rows  = dbmyhealth().select(dbmyhealth.health.ALL)
> for row in rows: 
> location0 = row.name
> location1 = row.definition
> location2 = row.abnvalinterpret
> location3 = row.normvalinterpret
> location4 = row.administration
> location5 = row.screening
> location6 = row.causes
> corpus = [location1 , location2, location3, location4, location5, 
> location6]
>
> I want to select an item, including all the fields from the abnval to the 
> causes,not randomly but based on the ID or the name. If I use the limitby 
> constraint,I can get either the first, second, or last item based on the 
> selection used. If I use the below code, I get only the first item, which 
> is everything based on obesity. I want to select any item with every query 
> using either an ID or the names below e.g.
> A code like: 
> for row in rows:
> if id == 2
> code..
>corpus = [location1 , location2, location3, location4, 
> location5, location6]in this case my corpus will have everything on 
> cardiomyopathy using the table details below.
>
> id name
> 0. diabetes
> 1. hypertension
> 2. cardiomyopathy
> 3. copd
> 4. obesity
>
> So how do I code it to obtain my answer
> Kind regards
>
>
Wouldn't that be either of

  rows = dbmyhealth(dbmyhealth.health.id == 2).select()



or (if you were doing more with the query)

  query = dbmyhealth.health.id == 2
  rows  = dbmyhealth(query).select()


?
(I didn't put in a first() because there's only 1 row with id == 2.)



/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] Re: execute web2py modules in terminal on 2.16.1

2018-01-04 Thread Alex Beskopilny
Hi! 
replace print "install"
with print ("install")


On Tuesday, January 2, 2018 at 10:06:31 PM UTC+3, 黄祥 wrote:
>
> cant execute from terminal web2py modules while in previous version is 
> work fine
> *step on local machine (terminal)*
> python -V
> Python 2.7.10
> cd
> rm -rf ~/web2py/applications/test
> cp -R ~/web2py/applications/welcome/ ~/web2py/applications/test
> rsync -zavr ~/git/web2py/test ~/web2py/applications/
> rsync -zavur ~/git/web2py/test ~/web2py/applications/
> python ~/web2py/web2py.py --nogui --no-banner -S test -M -R 
> ~/web2py/applications/test/modules/test_install.py
>
> *modules/test_install.py*
> #!/usr/bin/env python
> # coding: utf8
> from gluon.contrib.webclient import WebClient
> *print "Install" # temporary solution is comment this line but it work 
> fine in web2py previous version*
> install = WebClient('http://127.0.0.1:8000/test/install/',
> postbacks = True)
> install.get('index')
>
> *error traceback on localhost*
> Traceback (most recent call last):
>   File "/Users/MacBookPro/project/python/web2py/gluon/shell.py", line 274, 
> in run
> execfile(startfile, _env)
>   File 
> "/Users/MacBookPro/project/python/web2py/applications/test/modules/test_install.py",
>  
> line 4
> print "Install"
>   ^
> SyntaxError: invalid syntax
>
> tested the same code in docker (https://labs.play-with-docker.com) same 
> result but different error traceback
> *error traceback on docker*
> Traceback (most recent call last):
>   File "/home/web2py/web2py/gluon/restricted.py", line 219, in restricted
> exec(ccode, environment)
>   File "applications/init/models/db.py", line 36, in 
> check_reserved=['all'])
>   File "/home/web2py/web2py/gluon/packages/dal/pydal/base.py", line 169, 
> in __call__
> obj = super(MetaDAL, cls).__call__(*args, **kwargs)
>   File "/home/web2py/web2py/gluon/packages/dal/pydal/base.py", line 474, 
> 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/web2py/web2py/gluon/packages/dal/pydal/base.py", line 454, 
> in __init__
> self._adapter = adapter(**kwargs)
>   File 
> "/home/web2py/web2py/gluon/packages/dal/pydal/adapters/__init__.py", line 
> 40, in __call__
> obj = super(AdapterMeta, cls).__call__(*args, **kwargs)
>   File "/home/web2py/web2py/gluon/packages/dal/pydal/adapters/base.py", 
> line 368, in __init__
> super(SQLAdapter, self).__init__(*args, **kwargs)
>   File "/home/web2py/web2py/gluon/packages/dal/pydal/adapters/base.py", 
> line 52, in __init__
> self.reconnect()
>   File "/home/web2py/web2py/gluon/packages/dal/pydal/connection.py", line 
> 152, in reconnect
> self.connection = self.connector()
>   File "/home/web2py/web2py/gluon/packages/dal/pydal/adapters/sqlite.py", 
> line 42, in connector
> return self.driver.Connection(self.dbpath, **self.driver_args)
> OperationalError: unable to open database file
>
> The command '/bin/sh -c python /home/web2py/web2py/web2py.py --nogui 
> --no-banner -S init -M 
> -R/home/web2py/web2py/applications/init/modules/test_install.py' returned a 
> non-zero code: 1
>
> *step on docker (https://labs.play-with-docker.com 
> )*
> cat < Dockerfile
> FROM python:2.7
> RUN apt update && \
>  apt install -y unzip wget
> RUN groupadd -r web2py && \
>  useradd -m -r -g web2py web2py
> USER web2py
> RUN cd /home/web2py/ && \
>  wget -c http://web2py.com/examples/static/web2py_src.zip && \
>  unzip -o web2py_src.zip && \
>  rm -rf /home/web2py/web2py/applications/examples && \
>  cp -R /home/web2py/web2py/applications/welcome 
> /home/web2py/web2py/applications/init && \
>  chmod 755 -R /home/web2py/web2py
> COPY . /home/web2py/web2py/applications/init/
> RUN python /home/web2py/web2py/web2py.py --nogui --no-banner -S init -M -R 
> /home/web2py/web2py/applications/init/modules/test_install.py
> EXPOSE 8000
> CMD cd ~ && python /home/web2py/web2py/web2py.py --nogui --no-banner -a 
> 'a' -i 0.0.0.0 -p 8000
> EOF
> cat Dockerfile
> docker build .
> docker images
> docker run -p 8000:8000 image_id  
>
> any idea how to make it work in web2py latest version ?
> just an idea why not put Dockerfile or docker-compose.yml in 
> web2py/scripts/ as a template
>
> thanks and 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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Custom Register Page

2018-01-04 Thread Val K
Hi!
You can use CRYPT 

validator:
password_err = CRYPT()(request.vars.password)
password_err[0] # - LazyCrypt object (if password_err[1] == None) that will 
be calculated while insert(). Call str(password) to get a hash-string, but 
it's redundant
password_err[1] # - Error if validation failed




On Tuesday, January 2, 2018 at 7:43:54 PM UTC+3, David Cabeza wrote:
>
> Hello,
>
> I am making a register page because in my system, users are registered by 
> certain users (administrators) with that permission.
>
> I can't use web2py custom register form because when I place 
> auth.register() in the controller I'm being sent to index (because I am 
> logged in)
>
> The thing is that I receive password in plain text via 
> request.vars.password and I am trying to apply to the password the 
> algorithm that web2py uses to insert registered user directly in auth_user 
> table.
>
> This is what I tried
>
> from gluon.contrib.pbkdf2 import pbkdf2_hex
> from hashlib import sha512
>
> @auth.requires(lambda: check_role())
> def register():
>
>   if request.vars and request.vars.register == "do_register":
> db.auth_user.insert(first_name=request.vars.first_name, 
>   last_name=request.vars.last_name, email=request.vars.email, 
>   password=pbkdf2_hex(request.vars.password, 'salt', iterations=1000, 
> keylen=20, hashfunc=sha512))
>
> What is the best way to do this?
>
> Thank you.
>

-- 
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.