Re: [web2py] embed a pdf

2018-02-25 Thread Martin Weissenboeck
Did not solve the problem. The pdf data is stored in the table (it can be
retrieved manually).
The question is how to show the pdf in an iframe or an embed field.

2018-02-26 8:00 GMT+01:00 Marco Mansilla :

> Take a look to this
>
> https://groups.google.com/forum/m/#!topic/web2py/qgmh5C0XXkY
>
> El 26 feb. 2018 03:36, "Martin Weissenboeck" 
> escribió:
>
>> Sorry, it does not work.
>> The same results with or without "default"
>>
>> 2018-02-26 4:20 GMT+01:00 Marco Mansilla :
>>
>>> This
>>>
>>> download = URL("download", args=p.pdf)
>>>
>>> Should be
>>>
>>> download = URL("default", "download", args=p.pdf)
>>>
>>> You can do that on the view. But the change on the controller should do.
>>>
>>> El 25 feb. 2018 15:54, "Martin Weissenboeck" 
>>> escribió:
>>>
>>> What I want to do:
>>>
>>> I store a pdf-file in a database table.
>>> Then I want to show this file.
>>>
>>> The model:
>>>
>>> db.define_table("pdfs",
>>> Field("pdf", "upload", uploadfield="pdfdata"),
>>> Field("description", "text"),
>>> Field("pdfdata","blob")
>>> )
>>>
>>>
>>>
>>> The controller:
>>>
>>> def showpdf():
>>> id = int(request.args[0])
>>> p=db.pdfs(id)
>>> download = URL("download", args=p.pdf)
>>> return dict(p=p, download=download)
>>>
>>>
>>>
>>> The view:
>>>
>>> {{extend 'layout.html'}}
>>> Description: {{=p.description}}
>>> 
>>> 
>>> 
>>> Cannot display embed
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Cannot display iframe
>>> 
>>> 
>>>
>>>
>>>
>>> ​The  section show an error "Error on loading pdf".
>>>
>>> The  section shows an empty iframe and opens the Adobe Acrobat
>>> Reader with the required pdf.
>>>
>>> Any ideas?
>>>
>>> Regards Martin
>>>
>>> --
>>> 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.
>

-- 
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] embed a pdf

2018-02-25 Thread Marco Mansilla
Take a look to this

https://groups.google.com/forum/m/#!topic/web2py/qgmh5C0XXkY

El 26 feb. 2018 03:36, "Martin Weissenboeck"  escribió:

> Sorry, it does not work.
> The same results with or without "default"
>
> 2018-02-26 4:20 GMT+01:00 Marco Mansilla :
>
>> This
>>
>> download = URL("download", args=p.pdf)
>>
>> Should be
>>
>> download = URL("default", "download", args=p.pdf)
>>
>> You can do that on the view. But the change on the controller should do.
>>
>> El 25 feb. 2018 15:54, "Martin Weissenboeck" 
>> escribió:
>>
>> What I want to do:
>>
>> I store a pdf-file in a database table.
>> Then I want to show this file.
>>
>> The model:
>>
>> db.define_table("pdfs",
>> Field("pdf", "upload", uploadfield="pdfdata"),
>> Field("description", "text"),
>> Field("pdfdata","blob")
>> )
>>
>>
>>
>> The controller:
>>
>> def showpdf():
>> id = int(request.args[0])
>> p=db.pdfs(id)
>> download = URL("download", args=p.pdf)
>> return dict(p=p, download=download)
>>
>>
>>
>> The view:
>>
>> {{extend 'layout.html'}}
>> Description: {{=p.description}}
>> 
>> 
>> 
>> Cannot display embed
>> 
>> 
>> 
>> 
>> 
>> Cannot display iframe
>> 
>> 
>>
>>
>>
>> ​The  section show an error "Error on loading pdf".
>>
>> The  section shows an empty iframe and opens the Adobe Acrobat
>> Reader with the required pdf.
>>
>> Any ideas?
>>
>> Regards Martin
>>
>> --
>> 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] embed a pdf

2018-02-25 Thread Martin Weissenboeck
Sorry, it does not work.
The same results with or without "default"

2018-02-26 4:20 GMT+01:00 Marco Mansilla :

> This
>
> download = URL("download", args=p.pdf)
>
> Should be
>
> download = URL("default", "download", args=p.pdf)
>
> You can do that on the view. But the change on the controller should do.
>
> El 25 feb. 2018 15:54, "Martin Weissenboeck" 
> escribió:
>
> What I want to do:
>
> I store a pdf-file in a database table.
> Then I want to show this file.
>
> The model:
>
> db.define_table("pdfs",
> Field("pdf", "upload", uploadfield="pdfdata"),
> Field("description", "text"),
> Field("pdfdata","blob")
> )
>
>
>
> The controller:
>
> def showpdf():
> id = int(request.args[0])
> p=db.pdfs(id)
> download = URL("download", args=p.pdf)
> return dict(p=p, download=download)
>
>
>
> The view:
>
> {{extend 'layout.html'}}
> Description: {{=p.description}}
> 
> 
> 
> Cannot display embed
> 
> 
> 
> 
> 
> Cannot display iframe
> 
> 
>
>
>
> ​The  section show an error "Error on loading pdf".
>
> The  section shows an empty iframe and opens the Adobe Acrobat
> Reader with the required pdf.
>
> Any ideas?
>
> Regards Martin
>
> --
> 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.


[web2py] Re: cache response.render in views

2018-02-25 Thread Anthony
On Sunday, February 25, 2018 at 7:26:52 PM UTC-5, 黄祥 wrote:
>
> pardon, is this function is cached? on which side database, views, or 
> function?
> *modules/test_report.py*
> @cache.action(time_expire = cache_time_expire, cache_model = cache_model, 
> quick = cache_quick, prefix = cache_prefix) *# cache function, isn't it?*
>

Yes, this caches the output of a function. Note, though, that 
@cache.action() is specifically intended for actions in controllers because 
it also sets response headers that tell the browser to cache the HTML page 
for some time.
 

> def report_0(cache_db, print_controller):
> rows_currency = db(db.currency.id > 0).*iterselect*(cache = cache_db, 
> cacheable = True) *# cache query result, isn't it?*
>

I believe the "cache" argument is simply ignored with .iterselect(), as it 
doesn't make sense to cache the query result in this case (because 
.iterselect() does not retrieve all the records at once). If you want to 
cache the entire result set so you do not have to repeat the query, then 
use .select().
 

> d = dict(rows_currency = rows_currency, print_controller = 
> print_controller)
> return response.render(d) *# cache view, isn't it? not sure bout this 
> one, because it will contain another nested loop in the views part*
>

response.render() will return the final generated HTML (note, it is not 
caching the "view", which technically is the web2py template code -- it is 
caching the *result of executing the view*, which is just HTML). So, if the 
function returns that, then yes, the final HTML of the page is being 
cached. Any loops in the view are executed along with the view code, and 
the final output is cached.
 

> in my previous posted i cut the views part because it contain the nested 
> loop of the result of rows_currency e.g.
>

There is no reason to avoid caching the final HTML unless there are 
elements within the view code that generate data you don't want to cache 
from request to request. Loops are not a problem.
 

> is iterselect result is not cached while the select result is cached?
>

Correct.
 

> the reason i use iterselect is faster than select, pls correct me if i'm 
> wrong
>

If you cache the output of the function and the function returns 
response.render(), then that is all you need to cache. In that case, there 
is no need to also cache the select because on subsequent requests, the 
function itself won't even be run, as the cache system will return the 
cached output of the function rather than running the function itself. So, 
go ahead and use .iterselect() and just return response.render().

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] _href to URL()

2018-02-25 Thread Anthony
On Sunday, February 25, 2018 at 7:57:22 PM UTC-5, 黄祥 wrote:
>
> @anthony, tested your code but the result is not expected, it's added 
> another a href
> *usually use in response.menu :*
> (T('Address'), False, URL('master', 'address'), [] ),
> *result:*
> Address
>
> *change into :*
> (A('Address', _href='/test/master/address', _class='dropdown-item'), 
> False, *None*),
> *result:*
> ** href="/test/master/address">Address
>
> *change into :*
> (A('Address', _href='/test/master/address', _class='dropdown-item'), 
> False, *''*),
> *result :*
> ** href="/test/master/address">Address
>

Which version of web2py? Can you show all of your code? Here is what I get:

>>> menu = [(A('mylink', _href='myurl'), False, None)]
>>> MENU(m).xml()
b'mylink'

objective why i use a href in menu, because i want to use anchor accesskey 
> for keyboard shortcut menu and anchor title for description
> any idea?
>

Well, alternatively, you can also do:

menu = [(None, False, A('Address', _href='/test/master/address', _class=
'dropdown-item'))]

The third item can be any HTML helper object (the first item can only be a 
string or an A() helper).

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] embed a pdf

2018-02-25 Thread Marco Mansilla
This

download = URL("download", args=p.pdf)

Should be

download = URL("default", "download", args=p.pdf)

You can do that on the view. But the change on the controller should do.

El 25 feb. 2018 15:54, "Martin Weissenboeck"  escribió:

What I want to do:

I store a pdf-file in a database table.
Then I want to show this file.

The model:

db.define_table("pdfs",
Field("pdf", "upload", uploadfield="pdfdata"),
Field("description", "text"),
Field("pdfdata","blob")
)



The controller:

def showpdf():
id = int(request.args[0])
p=db.pdfs(id)
download = URL("download", args=p.pdf)
return dict(p=p, download=download)



The view:

{{extend 'layout.html'}}
Description: {{=p.description}}



Cannot display embed





Cannot display iframe





​The  section show an error "Error on loading pdf".

The  section shows an empty iframe and opens the Adobe Acrobat
Reader with the required pdf.

Any ideas?

Regards Martin

-- 
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] _href to URL()

2018-02-25 Thread 黄祥
@anthony, tested your code but the result is not expected, it's added 
another a href
*usually use in response.menu :*
(T('Address'), False, URL('master', 'address'), [] ),
*result:*
Address

*change into :*
(A('Address', _href='/test/master/address', _class='dropdown-item'), False, 
*None*),
*result:*
**Address

*change into :*
(A('Address', _href='/test/master/address', _class='dropdown-item'), False, 
*''*),
*result :*
**Address

objective why i use a href in menu, because i want to use anchor accesskey 
for keyboard shortcut menu and anchor title for description
any idea?

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: cache response.render in views

2018-02-25 Thread 黄祥
pardon, is this function is cached? on which side database, views, or 
function?
*modules/test_report.py*
@cache.action(time_expire = cache_time_expire, cache_model = cache_model, 
quick = cache_quick, prefix = cache_prefix) *# cache function, isn't it?*
def report_0(cache_db, print_controller):
rows_currency = db(db.currency.id > 0).*iterselect*(cache = cache_db, 
cacheable = True) *# cache query result, isn't it?*
d = dict(rows_currency = rows_currency, print_controller = print_controller)
return response.render(d) *# cache view, isn't it? not sure bout this one, 
because it will contain another nested loop in the views part*

in my previous posted i cut the views part because it contain the nested 
loop of the result of rows_currency e.g. (select the selling transaction, 
buying transaction, product, customer and customer account base on the 
result of the currency table), no jquery involved in the views, i'll posted 
the views part if still not clear

is iterselect result is not cached while the select result is cached? the 
reason i use iterselect is faster than select, pls correct me if i'm wrong

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.


Re: [web2py] Error using Postgres

2018-02-25 Thread Massimo Di Pierro
If it finds psycopg2 it should be using it over pg8000. Is t possible you 
have two versions of python installed?



On Sunday, 25 February 2018 04:46:57 UTC-6, Morganti wrote:
>
> Hi Massimo, thanks your answer.
>
> How can force web2py uses psycop2? I install pyscop2 using pip and made a 
> test importing it in normal python shell. But I got the same error when 
> tried to execute the same function:
>
> ((u'ERROR', u'34000', 
> u'portal "pg8000_portal_294" does not exist', u'postgres.c', u'1861', 
> u'exec_execute_message', u'', u''))
>
> It is using pg8000 and not pyscop2.
>
> Thanks,
> Best regards
> André
>
> Em sábado, 24 de fevereiro de 2018 23:36:32 UTC-3, Massimo Di Pierro 
> escreveu:
>>
>> I know. It is there and we distribute it but we will remove it in the 
>> next version.
>> I run into lots of problems with it, even with simple apps. psycopg2 
>> works instead.
>>
>>
>> On Friday, 23 February 2018 04:57:41 UTC-6, Morganti wrote:
>>>
>>> Hi Dave,
>>>
>>> I found "pg8000" inside "gluon/contrib".
>>>
>>> In "gluon\packages\dal\pydal\adapters" I found the "postgres.py". So is 
>>> it wrong? Do I need to move pg8000 to "gluon\packages\dal\pydal\adapters"?
>>>
>>> You said about socket. I have no idea how to do it.
>>>
>>> Thanks a lot your support!
>>> Best regards
>>> Andre
>>>
>>> Em quinta-feira, 22 de fevereiro de 2018 18:30:17 UTC-3, Dave S escreveu:



 On Thursday, February 22, 2018 at 8:29:43 AM UTC-8, Morganti wrote:
>
> Hi, thanks your time.
>
> How can I check it? If I try to open web2py shell (web2py -S app -M), 
> I had no errors and all tables could be used.
>
> Thanks 
> BR
> André
>
>
 That's one way to check.  The actual files should show up in the 
 web2py/gluon/packages/dal/pydal/adapters, I think, and not just in 
 gluon/contrib.


 But the error looks, to my inexpert eye, like a socket error.  So I 
 would start by verifying the socket exists and has the proper permissions. 

 /dps

 Em quinta-feira, 22 de fevereiro de 2018 13:08:23 UTC-3, Ovidio Marinho 
> escreveu:
>>
>> make sure the pg8000 and psycopg2 libraries are installed at the 
>> start of web2py
>>
>>
>>
>>
>>
>>
>>[image: http://itjp.net.br] 
>>  http://itjp.net.b r
>>   *Ovidio Marinho Falcao Neto*
>>  ovid...@gmail.com
>> Brasil
>>  
>>
>> 2018-02-22 12:40 GMT-03:00 Morganti :
>>
>>> Hello,
>>>
>>> I have a VPS using ubuntu 16.04, nginx, Postgres and web2py 2.16.1.
>>>
>>> I tried to execute one controller that populate some tables and got 
>>> the error below.
>>>
>>> Then, I used that command to create a csv file with all tables and 
>>> uploaded it in my desktop using SQLITE and no error were found.
>>>
>>> The controller coud create some rows before the error.
>>>
>>> Traceback (most recent call last):
>>>   File "/home/www-data/py27env/web2py/gluon/restricted.py", line 219, 
>>> in restricted
>>> exec(ccode, environment)
>>>   File 
>>> "/home/www-data/py27env/web2py/applications/nwproducao/controllers/carreira.py",
>>>  line 633, in 
>>>   File "/home/www-data/py27env/web2py/gluon/globals.py", line 419, in 
>>> 
>>> self._caller = lambda f: f()
>>>   File 
>>> "/home/www-data/py27env/web2py/applications/nwproducao/controllers/carreira.py",
>>>  line 21, in gera_plano_carreira
>>> vgraduacao = gera_graduacao()
>>>   File 
>>> "/home/www-data/py27env/web2py/applications/nwproducao/controllers/carreira.py",
>>>  line 56, in gera_graduacao
>>> for r in rows:
>>>   File 
>>> "/home/www-data/py27env/web2py/gluon/packages/dal/pydal/objects.py", 
>>> line 3039, in __iter__
>>> row = next(self)
>>>   File 
>>> "/home/www-data/py27env/web2py/gluon/packages/dal/pydal/objects.py", 
>>> line 3014, in __next__
>>> db_row = self.cursor.fetchone()
>>>   File "/home/www-data/py27env/web2py/gluon/contrib/pg8000/core.py", 
>>> line 947, in fetchone
>>> return next(self)
>>>   File "/home/www-data/py27env/web2py/gluon/contrib/pg8000/core.py", 
>>> line 1032, in __next__
>>> self._c.handle_messages(self)
>>>   File "/home/www-data/py27env/web2py/gluon/contrib/pg8000/core.py", 
>>> line 2088, in handle_messages
>>> raise self.error
>>> ProgrammingError: (u'ERROR', u'34000', u'portal "pg8000_portal_13259" 
>>> does not exist', u'postgres.c', u'1861', u'exec_execute_message', u'', 
>>> u'')
>>>
>>> *Thanks your helping.*
>>>
>>> *Best regards*
>>>
>>> *Andre*
>>>
>>> -- 
>>> Resources:
>>> - http://web2py.com
>>> - 

Re: [web2py] Re: accessing Exchange IMAP email

2018-02-25 Thread Massimo Di Pierro
I am telling you not to use DAL('imap://...') any more. If you need to use 
imap, use imaplib https://docs.python.org/2/library/imaplib.html
We are no longer supporting imap as part of the DAL. Nobody was using it 
and it is not the right abstraction.

On Sunday, 25 February 2018 03:02:44 UTC-6, Andrea Fae' wrote:
>
> I'm sorry, but what are you telling me exactly? 
>
> 2018-02-25 3:33 GMT+01:00 Massimo Di Pierro :
>
>> I believe we dropped support of DAL('imap:...)
>>
>>
>> On Wednesday, 21 February 2018 10:41:40 UTC-6, Andrea Fae' wrote:
>>>
>>> I have an exchange server and usually I access to email using 
>>> "domain\username" and password...
>>>
>>> using # Replace user, password, server and port in the connection string
>>>
>>> # Set port as 993 for SSL supportimapdb = 
>>> DAL("imap://user:password@server:port", pool_size=1)
>>>
>>> what can I type in the user ? I tried "domain\username" but I cannot 
>>> access...
>>> 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 a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/pYr5SHjaSlU/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.


Re: [web2py] Re: controller with multiprocessing powers. Howto?

2018-02-25 Thread António Ramos
Ok thank you

2018-02-25 2:35 GMT+00:00 Massimo Di Pierro :

> Pierre is right. That is not the way to do it. This is an example of the
> XY problem.
>
> One way to do it to use the scheduler your tasks and performs the queries
> in background.
>
>
>
> On Thursday, 22 February 2018 07:11:06 UTC-6, Pierre wrote:
>>
>> i think the entry point to do multiprocessing in web2py is the
>> web2py-scheduler. Howewer with this tool you can't share objects betweeen
>> processes like you do using the multiprocessing python module so
>> synchronization might be an issue. There are other tools like for instance*
>> huey* but i am not sure it's easy to integrate with web2py. In case this
>> is feasible, i'd be interested in an Howto huey-web2py-integration :
>>
>> https://huey.readthedocs.io/en/latest/
>>
> --
> 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] embed a pdf

2018-02-25 Thread Martin Weissenboeck
What I want to do:

I store a pdf-file in a database table.
Then I want to show this file.

The model:

db.define_table("pdfs",
Field("pdf", "upload", uploadfield="pdfdata"),
Field("description", "text"),
Field("pdfdata","blob")
)



The controller:

def showpdf():
id = int(request.args[0])
p=db.pdfs(id)
download = URL("download", args=p.pdf)
return dict(p=p, download=download)



The view:

{{extend 'layout.html'}}
Description: {{=p.description}}



Cannot display embed





Cannot display iframe





​The  section show an error "Error on loading pdf".

The  section shows an empty iframe and opens the Adobe Acrobat
Reader with the required pdf.

Any ideas?

Regards Martin

-- 
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: cache response.render in views

2018-02-25 Thread Anthony
On Friday, February 23, 2018 at 10:29:32 PM UTC-5, 黄祥 wrote:
>
> according to book : 
> http://web2py.com/books/default/chapter/29/04/the-core?search=response.render,
>  
> the response.render is used in controllers, let say, my controller is 
> contain nested loop and i decide to put it on views, but i don't want to 
> lose the web2py cache function
> *e.g.*
> *controllers/default.py*
> @cache.action(time_expire = cache_time_expire, cache_model = cache_model, 
> quick = cache_quick, prefix = cache_prefix)
> def report_bank():
> rows_currency = db(db.currency.id > 0).iterselect()
> return dict(rows_currency = rows_currency)
>

The @cache decorator will cache the output of the decorated function. In 
the above case, it will cache the returned dictionary, but I'm not sure 
this makes sense with .iterselect() -- you should probably instead use 
.select() if you want to cache the results of the query. In that case, the 
view will still be executed on each request. If you also want to cache the 
generated view, then return response.render(...) instead of the dictionary.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] _href to URL()

2018-02-25 Thread Anthony
On Sunday, February 25, 2018 at 5:25:51 AM UTC-5, Annet wrote:
>
> Hi Joel,
>
> Thanks for your reply.
>
> This works:
>
> ('', False, A('TaC', 
> _href='https://static.domain.com/files/Terms_and_Conditions.pdf', 
> _target="_blank", vars=dict(attachment=True))) 
>
> For some reason the first attribute is not used as the link text.
>

If the third element of the menu item is an HTML helper, it is used as the 
menu item, and the first element is ignored. The third element can also be 
a dictionary, in which case, the menu item becomes A(first_element, 
**third_element). Finally, the first element can itself be an A() helper, 
in which case the third element is ignored -- so you could instead do:

(A('TaC', _href='https://static.domain.com/files/Terms_and_Conditions.pdf',
   _target="_blank", vars=dict(attachment=True)), False, None)

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Error using Postgres

2018-02-25 Thread Morganti
Hi Massimo, thanks your answer.

How can force web2py uses psycop2? I install pyscop2 using pip and made a 
test importing it in normal python shell. But I got the same error when 
tried to execute the same function:

((u'ERROR', u'34000', 
u'portal "pg8000_portal_294" does not exist', u'postgres.c', u'1861', 
u'exec_execute_message', u'', u''))

It is using pg8000 and not pyscop2.

Thanks,
Best regards
André

Em sábado, 24 de fevereiro de 2018 23:36:32 UTC-3, Massimo Di Pierro 
escreveu:
>
> I know. It is there and we distribute it but we will remove it in the next 
> version.
> I run into lots of problems with it, even with simple apps. psycopg2 works 
> instead.
>
>
> On Friday, 23 February 2018 04:57:41 UTC-6, Morganti wrote:
>>
>> Hi Dave,
>>
>> I found "pg8000" inside "gluon/contrib".
>>
>> In "gluon\packages\dal\pydal\adapters" I found the "postgres.py". So is 
>> it wrong? Do I need to move pg8000 to "gluon\packages\dal\pydal\adapters"?
>>
>> You said about socket. I have no idea how to do it.
>>
>> Thanks a lot your support!
>> Best regards
>> Andre
>>
>> Em quinta-feira, 22 de fevereiro de 2018 18:30:17 UTC-3, Dave S escreveu:
>>>
>>>
>>>
>>> On Thursday, February 22, 2018 at 8:29:43 AM UTC-8, Morganti wrote:

 Hi, thanks your time.

 How can I check it? If I try to open web2py shell (web2py -S app -M), I 
 had no errors and all tables could be used.

 Thanks 
 BR
 André


>>> That's one way to check.  The actual files should show up in the 
>>> web2py/gluon/packages/dal/pydal/adapters, I think, and not just in 
>>> gluon/contrib.
>>>
>>>
>>> But the error looks, to my inexpert eye, like a socket error.  So I 
>>> would start by verifying the socket exists and has the proper permissions. 
>>>
>>> /dps
>>>
>>> Em quinta-feira, 22 de fevereiro de 2018 13:08:23 UTC-3, Ovidio Marinho 
 escreveu:
>
> make sure the pg8000 and psycopg2 libraries are installed at the start 
> of web2py
>
>
>
>
>
>
>[image: http://itjp.net.br] 
>  http://itjp.net.b r
>   *Ovidio Marinho Falcao Neto*
>  ovid...@gmail.com
> Brasil
>  
>
> 2018-02-22 12:40 GMT-03:00 Morganti :
>
>> Hello,
>>
>> I have a VPS using ubuntu 16.04, nginx, Postgres and web2py 2.16.1.
>>
>> I tried to execute one controller that populate some tables and got 
>> the error below.
>>
>> Then, I used that command to create a csv file with all tables and 
>> uploaded it in my desktop using SQLITE and no error were found.
>>
>> The controller coud create some rows before the error.
>>
>> Traceback (most recent call last):
>>   File "/home/www-data/py27env/web2py/gluon/restricted.py", line 219, in 
>> restricted
>> exec(ccode, environment)
>>   File 
>> "/home/www-data/py27env/web2py/applications/nwproducao/controllers/carreira.py",
>>  line 633, in 
>>   File "/home/www-data/py27env/web2py/gluon/globals.py", line 419, in 
>> 
>> self._caller = lambda f: f()
>>   File 
>> "/home/www-data/py27env/web2py/applications/nwproducao/controllers/carreira.py",
>>  line 21, in gera_plano_carreira
>> vgraduacao = gera_graduacao()
>>   File 
>> "/home/www-data/py27env/web2py/applications/nwproducao/controllers/carreira.py",
>>  line 56, in gera_graduacao
>> for r in rows:
>>   File 
>> "/home/www-data/py27env/web2py/gluon/packages/dal/pydal/objects.py", 
>> line 3039, in __iter__
>> row = next(self)
>>   File 
>> "/home/www-data/py27env/web2py/gluon/packages/dal/pydal/objects.py", 
>> line 3014, in __next__
>> db_row = self.cursor.fetchone()
>>   File "/home/www-data/py27env/web2py/gluon/contrib/pg8000/core.py", 
>> line 947, in fetchone
>> return next(self)
>>   File "/home/www-data/py27env/web2py/gluon/contrib/pg8000/core.py", 
>> line 1032, in __next__
>> self._c.handle_messages(self)
>>   File "/home/www-data/py27env/web2py/gluon/contrib/pg8000/core.py", 
>> line 2088, in handle_messages
>> raise self.error
>> ProgrammingError: (u'ERROR', u'34000', u'portal "pg8000_portal_13259" 
>> does not exist', u'postgres.c', u'1861', u'exec_execute_message', u'', 
>> u'')
>>
>> *Thanks your helping.*
>>
>> *Best regards*
>>
>> *Andre*
>>
>> -- 
>> 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 

Re: [web2py] _href to URL()

2018-02-25 Thread 'Annet' via web2py-users
Hi Joel,

Thanks for your reply.

This works:

('', False, A('TaC', 
_href='https://static.domain.com/files/Terms_and_Conditions.pdf', 
_target="_blank", vars=dict(attachment=True))) 

For some reason the first attribute is not used as the link text.

Kind regards,

Annet

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Web2Py + GAE + Memcache | How to Implement in Web2Py

2018-02-25 Thread PRACHI VAKHARIA

   
   1. 
*How to deploy Web2Py+Memcache on GAE *
   2. *How does one configure and also monitor the memcache server on GAE 
   from web2py?*

The description and details *here* 

 
are not enough or clear or explanative for a beginner.



For a *model* like this, *how to implement Memchache on GAE* for the *table 
'Articles'*?


if request.env.web2py_runtime_gae
htmlDB = DAL('google:datastore')
AuthDB = DAL('google:datastore')
*session.connect(request, response, db=AuthDB) #???*

*from gluon.contrib.gae_memcache import MemcacheClient*
*from gluon.contrib.memdb import MEMDB*
*cache.memcache = MemcacheClient(request)*
*cache.ram = cache.disk = cache.memcache*
*session.connect(request,response,db=MEMDB(cache.memcache.client))** 
#???*

else:
htmlDB = 
DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
AuthDB = 
DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])

from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
*auth = Auth(AuthDB) #???*
crud, service, plugins = Crud(htmlDB), Service(), PluginManager()
auth.define_tables(username=False, signature=False)

*htmlDB.define_table('Articles'*,
Field('Title'),
Field('Abstract', 'text', label="Enter Abstract"),
Field('Author'),
format='%(Title)s')


 Objective: *To cache the 'Articles' in Memcache in GAE*.

 

 



EOM 

-- 
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: accessing Exchange IMAP email

2018-02-25 Thread andfae
I'm sorry, but what are you telling me exactly?

2018-02-25 3:33 GMT+01:00 Massimo Di Pierro :

> I believe we dropped support of DAL('imap:...)
>
>
> On Wednesday, 21 February 2018 10:41:40 UTC-6, Andrea Fae' wrote:
>>
>> I have an exchange server and usually I access to email using
>> "domain\username" and password...
>>
>> using # Replace user, password, server and port in the connection string
>>
>> # Set port as 993 for SSL supportimapdb = 
>> DAL("imap://user:password@server:port", pool_size=1)
>>
>> what can I type in the user ? I tried "domain\username" but I cannot
>> access...
>> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/pYr5SHjaSlU/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.