Re: [web2py] How do I upload the .w2py file?

2018-04-03 Thread Marco Mansilla
Is it an app or a plugin?, What's the original file name?.

Marco.

El mié., 4 de abr. de 2018 01:28, Alejandra Montiel Saavedra <
alemontiels...@gmail.com> escribió:

>
> Yes, I'm wrong with the name of the format, but how can I install it in
> web2py, what happens is that they passed me a file.w2p and I reinstalled it
> in web2py because it generated an error "unabled to install application" .
>
> 2018-04-03 22:38 GMT-05:00 Marco Mansilla :
>
>> The file name should be  myFile.w2p not w2py. It is just a tar.gz file.
>>
>> Marco
>>
>> El mar., 3 de abr. de 2018 22:45, Alejandra Montiel Saavedra <
>> alemontiels...@gmail.com> escribió:
>>
>>>
>>> I have a file of .w2py format, I uploaded it in web2py and generated an
>>> error "Unable to install application". Could you help me upload it or can I
>>> open or view the folders inside the .w2py, please.
>>>
>>> --
>>> 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.
>>
>
> --
> 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] How do I upload the .w2py file?

2018-04-03 Thread 黄祥
like marco said, it's just tar.gz file, think you can extract it in 
web2py/applications folder with the command (not tested)
tar -xzvf web2py_file.w2p 

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.


Re: [web2py] How do I upload the .w2py file?

2018-04-03 Thread Alejandra Montiel Saavedra
Yes, I'm wrong with the name of the format, but how can I install it in
web2py, what happens is that they passed me a file.w2p and I reinstalled it
in web2py because it generated an error "unabled to install application" .

2018-04-03 22:38 GMT-05:00 Marco Mansilla :

> The file name should be  myFile.w2p not w2py. It is just a tar.gz file.
>
> Marco
>
> El mar., 3 de abr. de 2018 22:45, Alejandra Montiel Saavedra <
> alemontiels...@gmail.com> escribió:
>
>>
>> I have a file of .w2py format, I uploaded it in web2py and generated an
>> error "Unable to install application". Could you help me upload it or can I
>> open or view the folders inside the .w2py, please.
>>
>> --
>> 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.
>

-- 
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] How do I upload the .w2py file?

2018-04-03 Thread Marco Mansilla
The file name should be  myFile.w2p not w2py. It is just a tar.gz file.

Marco

El mar., 3 de abr. de 2018 22:45, Alejandra Montiel Saavedra <
alemontiels...@gmail.com> escribió:

>
> I have a file of .w2py format, I uploaded it in web2py and generated an
> error "Unable to install application". Could you help me upload it or can I
> open or view the folders inside the .w2py, please.
>
> --
> 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.


[web2py] Re: seperate the request.args() with the extension

2018-04-03 Thread 黄祥
pardon, my bad, i misunderstood the place of extension, the extension 
should be after the function name, not the args one, so the above is work 
well, when put it like:
curl -X GET -i http://127.0.0.1:8000/test/api/rows_as_list 
.xml 
/table0/1 

curl -X GET -i http://127.0.0.1:8000/test/api/rows_as_list 
.json 
/table0/1 


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] How do I upload the .w2py file?

2018-04-03 Thread Alejandra Montiel Saavedra

I have a file of .w2py format, I uploaded it in web2py and generated an 
error "Unable to install application". Could you help me upload it or can I 
open or view the folders inside the .w2py, please.

-- 
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: seperate the request.args() with the extension

2018-04-03 Thread Dave S


On Tuesday, April 3, 2018 at 5:18:53 PM UTC-7, 黄祥 wrote:
>
> *controllers/api.py*
> def rows_as_list():
> tablename = request.args(0)
> #id = request.args(1)
> id, ext = request.args(1).split('.')
> if int(id) > 0 :
> query = (db[tablename]['id'] == id)
> else:
> query = (db[tablename]['id'] > 0)
> #query = (db.table0.id > 0)
> rows = db(query).select().as_list()
> return dict(rows = rows)
>
> *# not work*
> curl -X GET -i http://127.0.0.1:8000/test/api/rows_as_list/table0/1
>
> *# traceback*
> Traceback (most recent call last):
>   File "/Users/MacBookPro/project/python/web2py/gluon/restricted.py", line 
> 219, in restricted
> exec(ccode, environment)
>   File 
> "/Users/MacBookPro/project/python/web2py/applications/test/controllers/api.py",
>  
> line 470, in 
>   File "/Users/MacBookPro/project/python/web2py/gluon/globals.py", line 
> 419, in 
> self._caller = lambda f: f()
>   File 
> "/Users/MacBookPro/project/python/web2py/applications/test/controllers/api.py",
>  
> line 218, in rows_as_list
> id, ext = request.args(1).split('.')
> ValueError: need more than 1 value to unpack
>
>
That's why I added the comment about regexp.
 

> *# not work, no errors occured but the result is not expected (not match 
> with the format (xml or json) )*
> curl -X GET -i http://127.0.0.1:8000/test/api/rows_as_list/table0/1.xml
> curl -X GET -i http://127.0.0.1:8000/test/api/rows_as_list/table0/1.json
>
>
So what do you get.  What do you have on the console when you print id + " 
  " + ext  right after the split? 

> any idea how to achieve it using web2py way?
>
>
I think this is it.
 

> thx n best regards,
> stifan
>

/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: seperate the request.args() with the extension

2018-04-03 Thread 黄祥
*controllers/api.py*
def rows_as_list():
tablename = request.args(0)
#id = request.args(1)
id, ext = request.args(1).split('.')
if int(id) > 0 :
query = (db[tablename]['id'] == id)
else:
query = (db[tablename]['id'] > 0)
#query = (db.table0.id > 0)
rows = db(query).select().as_list()
return dict(rows = rows)

*# not work*
curl -X GET -i http://127.0.0.1:8000/test/api/rows_as_list/table0/1

*# traceback*
Traceback (most recent call last):
  File "/Users/MacBookPro/project/python/web2py/gluon/restricted.py", line 
219, in restricted
exec(ccode, environment)
  File 
"/Users/MacBookPro/project/python/web2py/applications/test/controllers/api.py", 
line 470, in 
  File "/Users/MacBookPro/project/python/web2py/gluon/globals.py", line 
419, in 
self._caller = lambda f: f()
  File 
"/Users/MacBookPro/project/python/web2py/applications/test/controllers/api.py", 
line 218, in rows_as_list
id, ext = request.args(1).split('.')
ValueError: need more than 1 value to unpack

*# not work, no errors occured but the result is not expected (not match 
with the format (xml or json) )*
curl -X GET -i http://127.0.0.1:8000/test/api/rows_as_list/table0/1.xml
curl -X GET -i http://127.0.0.1:8000/test/api/rows_as_list/table0/1.json

any idea how to achieve it using web2py way?

thx n 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: seperate the request.args() with the extension

2018-04-03 Thread Dave S


On Tuesday, April 3, 2018 at 4:35:11 PM UTC-7, 黄祥 wrote:
>
> is it possible to seperate the request.args() with the extension?
> *e.g.*
> *controllers/api.py*
> def rows_as_list():
> tablename = request.args(0)
> id = request.args(1)
> if int(id) > 0 :
> query = (db[tablename]['id'] == id)
> else:
> query = (db[tablename]['id'] > 0)
> #query = (db.table0.id > 0)
> rows = db(query).select().as_list()
> return dict(rows = rows)
>
> *# work*
> curl -X GET -i http://127.0.0.1:8000/test/api/rows_as_list/table0/1
>
> *# not work*
> curl -X GET -i http://127.0.0.1:8000/test/api/rows_as_list/table0/1.xml
> curl -X GET -i http://127.0.0.1:8000/test/api/rows_as_list/table0/1.json
>
> *traceback*
> Traceback (most recent call last):
>   File "/Users/MacBookPro/project/python/web2py/gluon/restricted.py", line 
> 219, in restricted
> exec(ccode, environment)
>   File 
> "/Users/MacBookPro/project/python/web2py/applications/test/controllers/api.py",
>  
> line 471, in 
>   File "/Users/MacBookPro/project/python/web2py/gluon/globals.py", line 
> 419, in 
> self._caller = lambda f: f()
>   File 
> "/Users/MacBookPro/project/python/web2py/applications/test/controllers/api.py",
>  
> line 220, in rows_as_list
> if int(id) > 0 :
> ValueError: invalid literal for int() with base 10: '1.xml'
>
> *question*
> how can i seperate the request.args(1) with the extension, so that i can 
> use the curl with the extension?
>
> thx and best regards,
> stifan
>

 How about:   id, ext = request.args(1).split('.')  ???

/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: login, redirects, and multiple apps

2018-04-03 Thread Dave S


On Wednesday, March 28, 2018 at 9:35:22 AM UTC-7, Massimo Di Pierro wrote:
>
> This is all very strange since web2py uses different cookie names, session 
> id, and session folders for different apps. Therefore I do not see how 
> things can get mixed up.
> The only thing I can think of is if something in routes is accidentally 
> redirecting form app1 to app2 or vice versa. This would not still not cause 
> any session mixed up but it may cause you to see the profile of app1 while 
> you think you are seeing the profile of app2 (assuming you were logged in 
> both).
>
> Can you email me your routes.py? Also, it there any way I can try this 
> myself or reproduce it?
>
> massimo
>
>
I started with the sample routes.py, and tweaked this part:

#  This simple router set overrides only the default application name,
#  but provides full rewrite functionality.

routers = dict(

# base router
BASE=dict(
default_application='myapp1',
root_static = ['favicon.ico', 'robots.txt'],
),
)


The logins I was trying to do were for privileged accounts, and I don't yet 
have a handy demo site for the issue.

The browser I was using when getting confused was Firefox (on W10), 59.0.1 
(or a recent predecessor).
Moving the 2nd login to Chrome resolved the issue.

(FWIW:  For a site that's not mine, but for a service provider we use to 
manage some provisioning needs, I had to go from one browser with two 
logins to two browser with one login each; again, FF was the browser where 
the two stopped working, and Chrome the browser I moved one of the logins 
to.  Each login was to a different portal, similar to having 2 identical 
apps with separate databases.  So FF's cookie management might have 
changed.)

/dps

 

>
>
>
> On Thursday, 15 March 2018 21:17:40 UTC-5, Dave S wrote:
>>
>> I have a server with one web2py instance  (fronted by nginx/uwsgi), two 
>> apps, and a routes.py that says app1 is default.
>>
>> I recently (that is, last night) added a new function to app2, protected 
>> (as usual) with @auth.requires_membship('innercircle').  In addition, I had 
>> to create a new user 'goodguy' and add it to 'innercircle'.  I tested from 
>> a browser instance that also had routine use of app1.   I spent a lot of 
>> time that was supposed to be for testing the form in trying to get logged 
>> in correctly.  I eventually tried .../user/profile, and found I was not 
>> getting logged in as 'goodguy', I was getting logged in as 'ordinaryjoe', 
>> an id that existed in both app1 and app2 (independent DBs, both sqlite3).  
>> Also, even though I was specifying 'host:app2/default/newfunc,' I was being 
>> redirected to 'host:user/login?next=newfunc', which looks like (when login 
>> doesn't fail) it ends up trying to find newfunc in app1.  Being explicit 
>> about 'host:/app2/default/user/login?next=app2/default/newfunc' didn't seem 
>> to help.
>>
>> I finally opened a tab in a different browser, and was able to get to the 
>> right place, but it seemed like a lot of Sturm und Drang by that time.  For 
>> the record, server web2py 2.15.4, python 2.7.13, aws linux; clients Firefox 
>> 58.0.2, Chrome 63.0.3239.132, on W10. Also, the successful effort was on 
>> Chrome, and today I used the dev tools to record the network activity for 
>> the form submit (I'm preparing to use curl to submit the form), and I could 
>> see from the request headers that there was session id cookie for both app1 
>> and app2 (yes, I've used app1 on that browser, also).
>>  
>> Should I be doing something in routes.py to make all this work better, or 
>> are the user functions problematic in the 1x web2py 2x apps scenario, or 
>> was I just a victim of browser caches?
>>
>> Dave S
>> /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] seperate the request.args() with the extension

2018-04-03 Thread 黄祥
is it possible to seperate the request.args() with the extension?
*e.g.*
*controllers/api.py*
def rows_as_list():
tablename = request.args(0)
id = request.args(1)
if int(id) > 0 :
query = (db[tablename]['id'] == id)
else:
query = (db[tablename]['id'] > 0)
#query = (db.table0.id > 0)
rows = db(query).select().as_list()
return dict(rows = rows)

*# work*
curl -X GET -i http://127.0.0.1:8000/test/api/rows_as_list/table0/1

*# not work*
curl -X GET -i http://127.0.0.1:8000/test/api/rows_as_list/table0/1.xml
curl -X GET -i http://127.0.0.1:8000/test/api/rows_as_list/table0/1.json

*traceback*
Traceback (most recent call last):
  File "/Users/MacBookPro/project/python/web2py/gluon/restricted.py", line 
219, in restricted
exec(ccode, environment)
  File 
"/Users/MacBookPro/project/python/web2py/applications/test/controllers/api.py", 
line 471, in 
  File "/Users/MacBookPro/project/python/web2py/gluon/globals.py", line 
419, in 
self._caller = lambda f: f()
  File 
"/Users/MacBookPro/project/python/web2py/applications/test/controllers/api.py", 
line 220, in rows_as_list
if int(id) > 0 :
ValueError: invalid literal for int() with base 10: '1.xml'

*question*
how can i seperate the request.args(1) with the extension, so that i can 
use the curl with the extension?

thx 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: direct upload in directory

2018-04-03 Thread Dave S


On Tuesday, April 3, 2018 at 4:45:43 AM UTC-7, Anthony wrote:
>
> On Tuesday, April 3, 2018 at 6:09:36 AM UTC-4, Dave S wrote:
>>
>> On Monday, April 2, 2018 at 12:50:38 PM UTC-7, Diego Tostes wrote:
>>>
>>> Hi,
>>>
>>> I already use this:
>>>
>>> stream = open("/teste_en.pdf", 'rb')
>>> db.ensaios.insert(codigo_registro="novo ensaio",
>>>   en_pdf=stream 
>>> )
>>>
>>>
>> You're using this to read the file into the uploads table?  You haven't 
>> set "uploadfield=True" on your upload fields, so the model is expecting the 
>> file to be stored in the uploads directory, and a filename to be filled in 
>> as the field value.
>>
>
> The above is correct -- you can pass a stream directly to .insert() and 
> the DAL will store the file in the filesystem and the (transformed) 
> filename in the database field. See 
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#More-on-uploads
> .
>
> Anthony
>

I've read that section before, so it's strange that I don't recognize that 
part.  Maybe I'll learn it the second^Wthird time around.
 

/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: Caching DAL Selects - only cache.ram works?

2018-04-03 Thread Brian M
Further investigation shows that cache.redis plays nicely with pyodbc *as 
long as you have all uniquely named fields in your select*. The selects 
that I was working with involved multiple tables that each had a "Name" 
field that was being selected. If I add .with_alias() to provide unique 
names then caching worked but that's also not really convenient. Is this 
the way it is supposed to work?

On Tuesday, April 3, 2018 at 2:16:30 PM UTC-5, Anthony wrote:
>
> You can also see what happens if you do not set cacheable=True.
>
> On Tuesday, April 3, 2018 at 3:15:55 PM UTC-4, Anthony wrote:
>>
>> It should work. Could be a bug specific to using pyodbc. Have you tried 
>> it with other databases/drivers? Feel free to file a PyDAL issue.
>>
>> Anthony
>>
>> On Tuesday, April 3, 2018 at 12:40:50 PM UTC-4, Brian M wrote:
>>>
>>> I've been playing with caching and looking through the mailing list and 
>>> have a bit of confusion about whether or not you can actually cache DAL 
>>> Selects with anything other than cache.ram due to issues with what 
>>> can/cannot be pickled. When I use 
>>>
>>> db(...).select(...,cache=(cache.disk, 300), cacheable=True)
>>>
>>> Caching works just fine. But if I try it with cache.disk or cache.redis 
>>> instead then I get errors which seem to be related to not being able to 
>>> unpickle the cached select results. 
>>>
>>> type 'exceptions.TypeError'> ("cannot create 'pyodbc.Row' instances", 
>>> , )
>>>
>>>
>>> This, admittedly old, post seems to suggest that cache.redis should be 
>>> pretty much drop-in for cache.ram but that's not my experience. 
>>> https://groups.google.com/forum/?fromgroups#!searchin/web2py/caching$20model$20data/web2py/Tn4TiLPScII/jtMR1KtT4V8J
>>>
>>>
>>> So does the ability to cache DAL Selects really only exist for cache.ram 
>>> or am I missing something?
>>>
>>>
>>> Brian
>>>
>>

-- 
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: UnicodeDecodeError "'utf-8' codec can't decode..." when inserting a blob in database (python 3.6.3)

2018-04-03 Thread alexandre . henry
Thank you Mathieu,

I found the place to create issue... Actually, I wanted to better qualify 
the issue before open it, restarting from a clean project, and I cannot 
reproduce the very first issue!
I encounter some other issues related to binary encoding but now I prefer 
triple check before speaking!

Le lundi 2 avril 2018 16:36:59 UTC+2, Mathieu Clabaut a écrit :
>
> Alexandre,
>
> just go to : https://github.com/web2py/web2py/issues/new
>
> And fill in the issue withe the information given in your mail.
>
> Le ven. 30 mars 2018 à 16:50,  a 
> écrit :
>
>> Sure! Let me see how to do that and I will. Thank you
>>
>>
>> Le mercredi 28 mars 2018 18:49:08 UTC+2, Massimo Di Pierro a écrit :
>>
>>> I think this is. Can you please open an issue about it?
>>>
>>> On Tuesday, 27 March 2018 13:32:15 UTC-5, alexand...@gmail.com wrote:

 Hello All,

 I'm an absolute newbie with web2py so I'm not sure if the issue lies in 
 web2py/3.6 or my own mistakes... My apologies in advance.

 I encounter this error in a db.my_table.update_or_insert(..)

 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfe in position 
 96328: invalid start byte'


 What I'm trying to do:
 I have a text file that is the representation of a datamodel in a 
 specific COTS format.
 I want to parse it, list the tables to be created and create them 
 actually.
 I know that the file countains non-utf-8 characters, that's why I open 
 it in binary:

dpm_file = gzip.open(filepath,'rb')

 ... parse it using binary regex: (I imported the 'regex' module)
 regexp = regex.compile(b':columns 
 (\(((?>[^()]+)|(?1))*\))',regex.DOTALL)
 header_classes = regexp.findall(one_format_text)[0]

 ... and insert the results in db blob fields: (the error occurs here)
 db.dpm_header.update_or_insert(db.dpm_header.dpm == my_dpm_id, dpm 
 = my_dpm_id, header_classes  = header_classes, header_objects  = 
 header_objects)

 I defined blob fields because I thought that it was the way to write 
 directly in binary in database.
 I really wanted to use binary preciselly to avoid to manage the 
 encoding/decoding issues.

 In addition, this project is an attempt to transport in web2py an older 
 project that was working perfectly in pure python 3.6.3 (unix and windows) 
 (except that instead of creating tables in a DB, I created text files in a 
 filer...).
 Is it a issue on web2py/python 3.6? Or my misunderstanding on database 
 management...

 Thank you for your help!

 Here is the trace

 Traceback (most recent call last):
   File "D:\web\zz\web2py\gluon\restricted.py", line 219, in restricted
 exec(ccode, environment)
   File "D:/web/zz/web2py/applications/dpm_manager/controllers/default.py" 
 ,
  line 175, in 
   File "D:\web\zz\web2py\gluon\globals.py", line 419, in 
 self._caller = lambda f: f()
   File "D:\web\zz\web2py\gluon\tools.py", line 3982, in f
 return action(*a, **b)
   File "D:/web/zz/web2py/applications/dpm_manager/controllers/default.py" 
 ,
  line 131, in analyze
 header_classes  = header_classes)
   File "D:\web\zz\web2py\gluon\packages\dal\pydal\objects.py", line 811, 
 in update_or_insert
 record = self(_key)
   File "D:\web\zz\web2py\gluon\packages\dal\pydal\objects.py", line 565, 
 in __call__
 orderby_on_limitby=False).first()
   File "D:\web\zz\web2py\gluon\packages\dal\pydal\objects.py", line 2250, 
 in select
 return adapter.select(self.query, fields, attributes)
   File "D:\web\zz\web2py\gluon\packages\dal\pydal\adapters\sqlite.py", 
 line 82, in select
 return super(SQLite, self).select(query, fields, attributes)
   File "D:\web\zz\web2py\gluon\packages\dal\pydal\adapters\base.py", line 
 762, in select
 return self._select_aux(sql, fields, attributes, colnames)
   File "D:\web\zz\web2py\gluon\packages\dal\pydal\adapters\base.py", line 
 741, in _select_aux
 return processor(rows, fields, colnames, cacheable=cacheable)
   File "D:\web\zz\web2py\gluon\packages\dal\pydal\adapters\base.py", line 
 305, in parse
 for row in rows
   File "D:\web\zz\web2py\gluon\packages\dal\pydal\adapters\base.py", line 
 302, in 
 self._parse(
   File "D:\web\zz\web2py\gluon\packages\dal\pydal\adapters\base.py", line 
 231, in _parse
 value = self.parse_value(value, fit, ft, blob_decode)
   File "D:\web\zz\web2py\gluon\packages\dal\pydal\adapters\base.py", line 
 198, in parse_value
 return self.parser.parse(value, field_itype, field_type)
 

Re: [web2py] Re: prevent multiple session at the same time

2018-04-03 Thread Anthony
On Tuesday, April 3, 2018 at 10:20:41 AM UTC-4, AlighaThor wrote:
>
> I would do not perform the database check in every request (and I think 
> Massimo did'nt mean that :)), only during the the second (or more) attempt 
> to log in with the same user. 
>
> Let's say you have the X user logged in. You stored the uuid in the 
> auth_user.uuid field as mentioned. Then in another session there is an 
> attempt to log in with those same credentials. You generate a second uuid, 
> and validate that new uuid against the older stored in the user record.
>
> If the auth_user.uuid field is blank, there have been no session with that 
> user. So you proceed to log in.
> If it exists, but it is different from the stored one, the user is already 
> logged in, so you must prevent the second one.
>

That is a possible alternative approach, but could create problems. Someone 
can log in on one machine and not explicitly log out. It will then be 
impossible to log in from any other machine at least until login expires on 
the first one. If you allow extended logins (e.g., 30 days), you would have 
to wait 30 days. Massimo's approach avoids this problem by letting the 
second login take precedence and force the first login to become 
invalidated.

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] Re: Error on migrate=True

2018-04-03 Thread Anthony
Probably you don't have *.table files indicating the current status of the 
database schema. First, without the new column in the code, run a request 
with fake_migrate_all=True, which will create an updated set of *.table 
files. Then add the new column, and the migration should work.

Anthony

On Tuesday, April 3, 2018 at 12:14:30 PM UTC-4, Stephan wrote:
>
> I am getting an "tables already exist" error after adding column to an 
> existing table in db.py  and setting migrate from false to true. It's 
> connected to a mysql. Application is running in version 2.8.2. Is there 
> some cahce to be cleared? thx
>

-- 
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: Caching DAL Selects - only cache.ram works?

2018-04-03 Thread Anthony
You can also see what happens if you do not set cacheable=True.

On Tuesday, April 3, 2018 at 3:15:55 PM UTC-4, Anthony wrote:
>
> It should work. Could be a bug specific to using pyodbc. Have you tried it 
> with other databases/drivers? Feel free to file a PyDAL issue.
>
> Anthony
>
> On Tuesday, April 3, 2018 at 12:40:50 PM UTC-4, Brian M wrote:
>>
>> I've been playing with caching and looking through the mailing list and 
>> have a bit of confusion about whether or not you can actually cache DAL 
>> Selects with anything other than cache.ram due to issues with what 
>> can/cannot be pickled. When I use 
>>
>> db(...).select(...,cache=(cache.disk, 300), cacheable=True)
>>
>> Caching works just fine. But if I try it with cache.disk or cache.redis 
>> instead then I get errors which seem to be related to not being able to 
>> unpickle the cached select results. 
>>
>> type 'exceptions.TypeError'> ("cannot create 'pyodbc.Row' instances", 
>> , )
>>
>>
>> This, admittedly old, post seems to suggest that cache.redis should be 
>> pretty much drop-in for cache.ram but that's not my experience. 
>> https://groups.google.com/forum/?fromgroups#!searchin/web2py/caching$20model$20data/web2py/Tn4TiLPScII/jtMR1KtT4V8J
>>
>>
>> So does the ability to cache DAL Selects really only exist for cache.ram 
>> or am I missing something?
>>
>>
>> Brian
>>
>

-- 
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: Caching DAL Selects - only cache.ram works?

2018-04-03 Thread Anthony
It should work. Could be a bug specific to using pyodbc. Have you tried it 
with other databases/drivers? Feel free to file a PyDAL issue.

Anthony

On Tuesday, April 3, 2018 at 12:40:50 PM UTC-4, Brian M wrote:
>
> I've been playing with caching and looking through the mailing list and 
> have a bit of confusion about whether or not you can actually cache DAL 
> Selects with anything other than cache.ram due to issues with what 
> can/cannot be pickled. When I use 
>
> db(...).select(...,cache=(cache.disk, 300), cacheable=True)
>
> Caching works just fine. But if I try it with cache.disk or cache.redis 
> instead then I get errors which seem to be related to not being able to 
> unpickle the cached select results. 
>
> type 'exceptions.TypeError'> ("cannot create 'pyodbc.Row' instances", 
> , )
>
>
> This, admittedly old, post seems to suggest that cache.redis should be 
> pretty much drop-in for cache.ram but that's not my experience. 
> https://groups.google.com/forum/?fromgroups#!searchin/web2py/caching$20model$20data/web2py/Tn4TiLPScII/jtMR1KtT4V8J
>
>
> So does the ability to cache DAL Selects really only exist for cache.ram 
> or am I missing something?
>
>
> Brian
>

-- 
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] Confused about web2py sessions handling in the filesystem, versus the db handling.

2018-04-03 Thread AlighaThor
Hi. I'm experimenting for the first time (but I'm quite a bit old using 
this amazing framework :)) storing sessions in the DB instead the 
filesystem, as I always did. I'm monitoring those two behaviours and 
somehow it feels (at least for me) that the DB session handling is far away 
more efficient/manteinable than the filesystem session handling.

Look at this:

*When using the filesystem handling:*

1 - I go to my login form. A session file is created (for the form key I 
suposse.).





2 - Then I finally log in. Another session file is created.




3 - Next I log out. A new file is created or somehow "moved" or "deleted" 
from the directory "165".



4 - Next I log in again. This time my form action did not create any new 
file, but a new one after the log in.




5 - Everything is repeated again. I log out, then a new file is created.


*Now let's see the DB behaviour:*


1 - Login form. A session record is created.





2 - I log in. The same record remains, but instead, as we expect, the 
unique_key is updated.



3 - I log out. Again, the record remains and the unique_key field is 
updated.






Whatever I do, only one record is stored according my session origin (IP, 
Browser, etc) and this remains true until my session expires or is deleted.

Maybe I'm talking nonesenses, but it is feel "better" to me, having a "true 
one instance per session", using the DB, that many files/folders created 
over and over again related to the same origin using the filesystem.

What I am missing here? 
Is this the normal/expected behaviour when the default FS session handling 
is used? 
Can we consider that is more performant using the DB alternative that the 
FS one?

BTW: It seems that the admin option to "cleanup" only clear the sessions 
store in the filesystem, not the DB alternative.

Thanks for reading!

-- 
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] Caching DAL Selects - only cache.ram works?

2018-04-03 Thread Brian M
I've been playing with caching and looking through the mailing list and 
have a bit of confusion about whether or not you can actually cache DAL 
Selects with anything other than cache.ram due to issues with what 
can/cannot be pickled. When I use 

db(...).select(...,cache=(cache.disk, 300), cacheable=True)

Caching works just fine. But if I try it with cache.disk or cache.redis 
instead then I get errors which seem to be related to not being able to 
unpickle the cached select results. 

type 'exceptions.TypeError'> ("cannot create 'pyodbc.Row' instances", , )


This, admittedly old, post seems to suggest that cache.redis should be 
pretty much drop-in for cache.ram but that's not my experience. 
https://groups.google.com/forum/?fromgroups#!searchin/web2py/caching$20model$20data/web2py/Tn4TiLPScII/jtMR1KtT4V8J


So does the ability to cache DAL Selects really only exist for cache.ram or 
am I missing something?


Brian

-- 
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 on migrate=True

2018-04-03 Thread Stephan
I am getting an "tables already exist" error after adding column to an 
existing table in db.py  and setting migrate from false to true. It's 
connected to a mysql. Application is running in version 2.8.2. Is there 
some cahce to be cleared? thx

-- 
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: customizing SQLFORM to insert many rows from one form

2018-04-03 Thread Tribo Eila
you can try this http://www.mdelrosso.com/sheepit/index.php?lng=en_GB

On Monday, April 2, 2018 at 5:37:09 PM UTC+3, Mashareq M wrote:
>
> Hi,
>
> I am creating a web app for attending employees.
>
> This is the model:
>
> db.define_table(
> 'employee',
>  Field('name'),
>  format = '%(name)s')
> db.define_table(
> 'attendance',
> Field('employee_id',db.employee),
> Field('attend','boolean'),
> Field('comments','text') )
>
> This is the controller:
> def fillForm():
> employeeIDS=db(db.employee).select(db.employee.ALL)
> form = SQLFORM(db.attendance)
> if form.process(session=None, formname='test').accepted:
> response.flash = 'form accepted'
> elif form.errors:
> response.flash = 'form has errors'
> else:
> response.flash = 'please fill the form'
> return locals()
>
> This is the view:
> 
> 
> 
> name
> attend?
> comments
> 
> 
> {{for eid in employeeIDS:}}
> 
> {{=eid.name}}
> 
> 
> 
> 
> {{pass}}
> 
> 
> 
> 
> 
>
> The question is:
>
> How can I insert the data in each row in the table to be in one row in the 
> attendance table, whether the employee is attendance or absence ?
>
>
> Best Regards,
>

-- 
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: FYI: A tutorial on how to customize export in SQLFORM.grid

2018-04-03 Thread Alex Beskopilny
Hi! 
exporter example

0 pip install xlwt 
1 at end of gluon/sqlhtml.py 

class ExporterXLS(ExportClass):
label = 'XLS'
file_ext = "xls"
content_type = ".xls"
# https://gist.github.com/brendano/22764
# https://groups.google.com/forum/#!topic/web2py/MR_8JzzP9o4
def __init__(self, rows):
ExportClass.__init__(self, rows)

def export(self):
import xlwt, cStringIO
if len(self.rows) == 0:
  return 'empty rows-table'

rows_colnames= [name.translate(None,'"') for name in 
self.rows.colnames ]

(table_name, _)= rows_colnames[0].split('.')
book = xlwt.Workbook()
sheet = book.add_sheet(table_name)
first_xls_row= 0
# rows.db.licence.fld2.represent(row.fld2,3)

def list2xls(row_num,line_list):
for col_num, value in enumerate(line_list):
 if value is None:
 value=''
 elif isinstance(value, long):
 value= str(value)
 elif isinstance(value, str):
 value= value.decode('utf8')
 elif isinstance(value,  datetime.date):
 value= value.strftime('%d.%m.%Y')
 elif isinstance(value, datetime.datetime):
 value= value.strftime('%d.%m.%Y %H:%M:%S')
 else:
 value=''
 sheet.write(row_num, col_num, value)

fields=[]; labels=[]
for col in rows_colnames:
(t,f) = col.split('.')
fields.append(f)
labels.append( self.rows.db[t][f].label )
list2xls(first_xls_row, labels)

for r_num, row in enumerate (self.rows, first_xls_row + 1):
 llist=[ row[f]  for f in fields]
 list2xls(r_num, llist)

s = cStringIO.StringIO()
book.save(s)
return s.getvalue()

2  gluon/sqlhtml.py 
2517 exportManager = dict(
2518 axls=(ExporterXLS, 'XLS', T('Excell file')), # myfix
2519 csv_with_hidden_cols=(ExporterCSV_hidden, 'CSV (hidden 
cols)', T('Comma-separated export including columns not shown; fields from 
other tables are exported as raw values  for faster export')),
...

3 it's work for me :)


воскресенье, 1 апреля 2018 г., 10:08:30 UTC+3 пользователь Ray (a.k.a. 
Iceberg) написал:
>
> Stumbled upon this blog post "Export in web2py's SQLFORM.grid 
> " by Prasad Muley. It provides 
> concrete example on how to customize an exporter TO REMOVE THE TABLE PREFIX 
> IN CSV HEADER LINE. That is easier to digest than the standard web2py 
> book's one-liner 
> 
>  
> "(exporters) are all defined in gluon/sqlhtml.py. Take a look at those for 
> creating your own exporter.".
>
> Hope that helps! Enjoy!
>
> Regards,
> Ray
>
>
>

-- 
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: prevent multiple session at the same time

2018-04-03 Thread AlighaThor
I would do not perform the database check in every request (and I think 
Massimo did'nt mean that :)), only during the the second (or more) attempt 
to log in with the same user. 

Let's say you have the X user logged in. You stored the uuid in the 
auth_user.uuid field as mentioned. Then in another session there is an 
attempt to log in with those same credentials. You generate a second uuid, 
and validate that new uuid against the older store in the user record..

If the auth_user.uuid field is blank, there have been no session with that 
user. So you proceed to log in.
If it exists, but it is different from the stored one, the user is already 
logged in, so you must prevent the second one.

-- 
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: Sending emails from different email ids

2018-04-03 Thread yogeshwar khalkar
Thanks it solved my problem.
On Apr 3, 2018 5:17 PM, "Anthony"  wrote:

> You can just dynamically set the values of the mail settings within each
> request (the mail settings do not have to be retrieved from the appconfig
> file).
>
> Anthony
>
> On Tuesday, April 3, 2018 at 4:01:26 AM UTC-4, yogeshwar khalkar wrote:
>>
>> Hi,
>>
>> I want to send email from different email IDs each time.
>>
>> I have configured 1 smtp email for sender in appconfig file & it's
>> working fine, But
>> i want to configure different email on user login.
>>
>> Please help me to solve the problem.
>>
> --
> 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.


[web2py] Re: Request with login privileges hangs for a specific user account, how to debug it?

2018-04-03 Thread Lisandro
I store the sessions in the database, so there is no problem with a locked 
file.

I've just found something interesting that could help to figure out: when 
the problem presents, I checked the pg_stat_activity in postgres to see if 
there was a long running query, and there is indeed. But the query is a 
simple select to the auth_user table, to select the row of the logged in 
user. How can this query take that long? Does web2py lock the user row? If 
so, how do I release it?

Something to consider: in my db.py, at the end, I do this:

response.user = db.auth_user[auth.user.id] if auth.is_logged_in() else None


I think that is the query taking that long, because this is the SQL query 
that I can see in the pg_stat_activity:

SELECT  auth_user.id, auth_user.first_name, auth_user.last_name, auth_user.
email, auth_user.password, auth_user.registration_key, auth_user.
reset_password_key, auth_user.registration_id, auth_user.alta, auth_user.
plantel, auth_user.responsable, auth_user.nombre, auth_user.telefono, 
auth_user.autor, auth_user.foto, auth_user.foto_temp, auth_user.moderador, 
auth_user.descripcion, auth_user.facebook, auth_user.twitter, auth_user.
linkedin, auth_user.gplus FROM auth_user WHERE (auth_user.id = 2) LIMIT 1 
OFFSET 0;


So, I think the problem is related to that sentence where I need to 
retrieve the row of the logged in user and store it in a variable inside 
response object.
What do you think?



El martes, 3 de abril de 2018, 8:29:09 (UTC-3), Leonel Câmara escribió:
>
> I would use redis for sessions instead of the default file based ones, it 
> makes the site a lot quicker and it would probably solve your problem as I 
> would bet this is happening due to a locked session file.
>

-- 
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: Sending emails from different email ids

2018-04-03 Thread Anthony
You can just dynamically set the values of the mail settings within each 
request (the mail settings do not have to be retrieved from the appconfig 
file).

Anthony

On Tuesday, April 3, 2018 at 4:01:26 AM UTC-4, yogeshwar khalkar wrote:
>
> Hi,
>
> I want to send email from different email IDs each time.
>
> I have configured 1 smtp email for sender in appconfig file & it's working 
> fine, But 
> i want to configure different email on user login.
>
> Please help me to solve the problem. 
>

-- 
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: direct upload in directory

2018-04-03 Thread Anthony
On Tuesday, April 3, 2018 at 6:09:36 AM UTC-4, Dave S wrote:
>
> On Monday, April 2, 2018 at 12:50:38 PM UTC-7, Diego Tostes wrote:
>>
>> Hi,
>>
>> I already use this:
>>
>> stream = open("/teste_en.pdf", 'rb')
>> db.ensaios.insert(codigo_registro="novo ensaio",
>>   en_pdf=stream 
>> )
>>
>>
> You're using this to read the file into the uploads table?  You haven't 
> set "uploadfield=True" on your upload fields, so the model is expecting the 
> file to be stored in the uploads directory, and a filename to be filled in 
> as the field value.
>

The above is correct -- you can pass a stream directly to .insert() and the 
DAL will store the file in the filesystem and the (transformed) filename in 
the database field. 
See 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#More-on-uploads.

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] Re: Request with login privileges hangs for a specific user account, how to debug it?

2018-04-03 Thread Leonel Câmara
I would use redis for sessions instead of the default file based ones, it 
makes the site a lot quicker and it would probably solve your problem as I 
would bet this is happening due to a locked session file.

-- 
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: direct upload in directory

2018-04-03 Thread Diego Tostes
thanks.

db(db.ensaios.codigo_registro == "novo ensaio").update(en_pdf=stream)

works for me!!

thanks again!

2018-04-03 7:09 GMT-03:00 Dave S :

> On Monday, April 2, 2018 at 12:50:38 PM UTC-7, Diego Tostes wrote:
>>
>> Hi,
>>
>> I already use this:
>>
>> stream = open("/teste_en.pdf", 'rb')
>> db.ensaios.insert(codigo_registro="novo ensaio",
>>   en_pdf=stream
>> )
>>
>>
> You're using this to read the file into the uploads table?  You haven't
> set "uploadfield=True" on your upload fields, so the model is expecting the
> file to be stored in the uploads directory, and a filename to be filled in
> as the field value.
>
>
>>
>> but I need to know if is a possible update a row with an upload.
>>
>>
> I would think so, but the most common usage seems to be just to make a new
> entry with every upload, with the form.process.accepted doing an insert,
> except if you've set the record parameter to SQLFORM().  See
>  and-validators#SQLFORM-and-insert-update-delete>
> (and a brief mention in the SQLFORM() signature a couple paragraphs above)/
>
> You may want to show us the controller code you are using if this doesn't
> answer your questions.
>
> /dps
>
>
>>
>> 2018-04-02 14:27 GMT-03:00 Diego Tostes :
>>
>>>
>>>
>>> 2018-04-02 13:22 GMT-03:00 Diego Tostes :
>>>
 Hi,


 i have a table in my model called ensaios:

 Ensaios = db.define_table('ensaios',
 Field('codigo_registro', 'string'),
 Field('url', 'string'),
 Field('titulo_pt', 'string'),
 Field('titulo_en', 'string'),
 Field('tags', 'text'),
 Field('contato_publico', 'string'),
 Field('email_contato_publico', 'string'),
 Field('pt_pdf', 'upload'),
 Field('en_pdf', 'upload'),
 Field.Virtual('relatorio', lambda row: A('Relatorio',
   _href=URL('default',
 'ensaios',
   vars=dict(ensaio_id=
 row.ensaios.id,
 )


 i will store pdfs from clinical trials. the problem is that i already
 have more than 5000 pdfs.

 i tried to put all the pdfs inside of the 
 "web2py/applications/ensaiosclinicos/uploads"


 and did insertions of the names of the files in the database. But I am
 getting a error :

 404 NOT FOUND

 Is it possible to do this ?


 rgds

 Diego



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


[web2py] Re: direct upload in directory

2018-04-03 Thread Dave S
On Monday, April 2, 2018 at 12:50:38 PM UTC-7, Diego Tostes wrote:
>
> Hi,
>
> I already use this:
>
> stream = open("/teste_en.pdf", 'rb')
> db.ensaios.insert(codigo_registro="novo ensaio",
>   en_pdf=stream 
> )
>
>
You're using this to read the file into the uploads table?  You haven't set 
"uploadfield=True" on your upload fields, so the model is expecting the 
file to be stored in the uploads directory, and a filename to be filled in 
as the field value.
 

>
> but I need to know if is a possible update a row with an upload.
>
>
I would think so, but the most common usage seems to be just to make a new 
entry with every upload, with the form.process.accepted doing an insert, 
except if you've set the record parameter to SQLFORM().  See

(and a brief mention in the SQLFORM() signature a couple paragraphs above)/

You may want to show us the controller code you are using if this doesn't 
answer your questions.

/dps

  
>
> 2018-04-02 14:27 GMT-03:00 Diego Tostes :
>
>>
>>
>> 2018-04-02 13:22 GMT-03:00 Diego Tostes :
>>
>>> Hi,
>>>
>>>
>>> i have a table in my model called ensaios:
>>>
>>> Ensaios = db.define_table('ensaios',
>>> Field('codigo_registro', 'string'),
>>> Field('url', 'string'),
>>> Field('titulo_pt', 'string'),
>>> Field('titulo_en', 'string'),
>>> Field('tags', 'text'),
>>> Field('contato_publico', 'string'),
>>> Field('email_contato_publico', 'string'),
>>> Field('pt_pdf', 'upload'),
>>> Field('en_pdf', 'upload'),
>>> Field.Virtual('relatorio', lambda row: A('Relatorio', 
>>>   _href=URL('default', 
>>> 'ensaios',
>>>   vars=dict(ensaio_id=
>>> row.ensaios.id,
>>> )
>>>
>>>
>>> i will store pdfs from clinical trials. the problem is that i already 
>>> have more than 5000 pdfs.
>>>
>>> i tried to put all the pdfs inside of the 
>>> "web2py/applications/ensaiosclinicos/uploads" 
>>>
>>> and did insertions of the names of the files in the database. But I am 
>>> getting a error :
>>>
>>> 404 NOT FOUND
>>>
>>> Is it possible to do this ?
>>>
>>>
>>> rgds
>>>
>>> Diego
>>>
>>>
>>>
>>
>

-- 
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: service function with header key

2018-04-03 Thread 黄祥
after several test and relearn from the book
*controllers/api.py*
def http_api_key():
api_key = request.env.http_api_key # change api_key with the parameter you 
want in curl request header
if api_key == 'your_api_key':
query = (db.table0.id > 0)
rows = db(query).select()
else:
rows = {'status':'Invalid API Key'}
return response.json(rows)

*terminal return the value*
curl -X GET -i http://127.0.0.1:8000/test/api/http_api_key --header 
'api_key: your_api_key'

*terminal return bad value 'Invalid API Key' because the api_key in header 
is mismatch*
curl -X GET -i http://127.0.0.1:8000/test/api/http_api_key --header 
'api_key: your_api_key0'

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: direct upload in directory

2018-04-03 Thread Dave S


On Monday, April 2, 2018 at 9:22:51 AM UTC-7, Diego Tostes wrote:
>
> Hi,
>
>
> i have a table in my model called ensaios:
>
> Ensaios = db.define_table('ensaios',
> Field('codigo_registro', 'string'),
> Field('url', 'string'),
> Field('titulo_pt', 'string'),
> Field('titulo_en', 'string'),
> Field('tags', 'text'),
> Field('contato_publico', 'string'),
> Field('email_contato_publico', 'string'),
> Field('pt_pdf', 'upload'),
> Field('en_pdf', 'upload'),
> Field.Virtual('relatorio', lambda row: A('Relatorio', 
>   _href=URL('default', 
> 'ensaios',
>   vars=dict(ensaio_id=
> row.ensaios.id,
> )
>
>
> i will store pdfs from clinical trials. the problem is that i already have 
> more than 5000 pdfs.
>
> i tried to put all the pdfs inside of the 
> "web2py/applications/ensaiosclinicos/uploads" 
>
> and did insertions of the names of the files in the database. But I am 
> getting a error :
>
> 404 NOT FOUND
>
>
What are you doing that returns a 404 error?  Is this during the insertion 
or during an attempt to retrieve the file?
 

> Is it possible to do this ?
>
>
I mostly have the problem going the other way ... deleting rows (and their 
files) that are either development-test files or excessibely obsolete.
 

>
> rgds
>
> Diego
>
>
Dave
/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] Sending emails from different email ids

2018-04-03 Thread yogeshwar khalkar
Hi,

I want to send email from different email IDs each time.

I have configured 1 smtp email for sender in appconfig file & it's working 
fine, But 
i want to configure different email on user login.

Please help me to solve the problem. 

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