Re: [web2py] Re: How do I display uploaded images from uploads folder

2019-11-11 Thread Maurice Waka
Thanks.
Let me work it out.
Regards

On Tue, Nov 12, 2019, 01:01 Dave S  wrote:

>
>
> On Monday, November 11, 2019 at 12:10:53 PM UTC-8, Maurice Waka wrote:
>>
>> But I did upload and the image is in the folder.
>>
>
> How are you generating the URL for showarticle()?
>
> Also, I think you can just do an ordinary file open(), rather than having
> to import PIL and doing an Image.open()
>
> BTW, I handle images as  tags, where src=showimg(id), and showimg()
> reads the file.  I also have an example, maybe previously posted, where I
> use download() instead of a custom showimg(),so the controller does a
> select on the upload table, and then
> return dict(img=row.fdata)
>
> and the view has
> {{=IMG(_src=(URL"download", img), _alt="test image")}}
>
> Good luck!
>
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/GbwQoJymKns/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/6301fedd-ed05-484f-bffc-6afeb2f200cf%40googlegroups.com
> 
> .
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CALkNK56Ch%3DFRntkCB%2BFhN14VV2BHGsUcDvWiayJ1wR8ej36WZA%40mail.gmail.com.


[web2py] how to specify python3 for wsgihandler

2019-11-11 Thread David Zejda
Hello to all.

I have a web2py with several apps on a production server behind Apache 
accessed via wsgihandler. So far, all the apps have been developed for 
python2.

To support python3 apps (preferred for new projects), I set-up a separate 
web2py directory and adjusted the Apache configs respectively.

The question is - how to set this new web2py instance to run on python3?

For compatibility reasons, /usr/bin/env python still translates to python 2 
interpreter. 

Do I have to change all the #!/usr/bin/env python lines in web2py sources 
to point to python3 instead? 
Or where else can I specify the python version? 

Thank you very much for an answer in advance!

David

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/633956c2-9522-4d56-9bf0-7ec9a467881c%40googlegroups.com.


[web2py] Re: rename request hostname

2019-11-11 Thread Dave S


On Monday, November 11, 2019 at 7:12:44 AM UTC-8, Yoel Benitez Fonseca 
wrote:
>
> h!
>
> Is it possible to change the hostname that comes in the form request  so 
> that outbound links have the hostname i want?
>

I think you want to look at routes.py, but I haven't tried this use case, 
so any details I could give you are in the book.
 

>
> I have an app in an internal network that I want to make visible from the 
> outside with an nginx proxy, all relative links work correctly, this would 
> be the example of configuration in nginx:
>
> location ~* ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ {
>  rewrite ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ 
> /some-folder/statics/staging/$2 break;
> proxy_ignore_headers Cache-Control;
> add_header Cache-Control public;
> add_header Cache-Control max-age=31536000; # seconds, one year
> proxy_pass_request_headers  on;
> proxy_pass https://some.internal.server.local;
> }
>
> location ~* ^/(.*)$ {
> rewrite ^/(.*)$ /staging/$1 break;
> proxy_set_header Host "some.internal.server.local";
> proxy_set_header X-Real-IP $remote_addr;
> proxy_ssl_server_name on;
> proxy_pass https://some.internal.server.local;
> }
>
>
> That works correctly for any relative link, the problem comes with 
> uploads, whose links are being generated for some reason including the 
> hostname:
>
> https://some.internal.server.local
> /app/download/some.object.a051462ffdcb77a3.746d706c32417038422e6a7067.jpg
>
> and how it happens, i can't change the internal server name and need to 
> pass the proxy_set_header Host or I will not have access to that host... The 
> only thing I can think of is telling WEB2PY to use a fixed host name when 
> generating the links.
>
>
/dps

 
 
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/c747477d-0665-45ba-92f5-e2a87e2d1fca%40googlegroups.com.


Re: [web2py] Re: How do I display uploaded images from uploads folder

2019-11-11 Thread Dave S


On Monday, November 11, 2019 at 12:10:53 PM UTC-8, Maurice Waka wrote:
>
> But I did upload and the image is in the folder.
>

How are you generating the URL for showarticle()?

Also, I think you can just do an ordinary file open(), rather than having 
to import PIL and doing an Image.open()

BTW, I handle images as  tags, where src=showimg(id), and showimg() 
reads the file.  I also have an example, maybe previously posted, where I 
use download() instead of a custom showimg(),so the controller does a 
select on the upload table, and then
return dict(img=row.fdata)

and the view has
{{=IMG(_src=(URL"download", img), _alt="test image")}}

Good luck!

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/6301fedd-ed05-484f-bffc-6afeb2f200cf%40googlegroups.com.


Re: [web2py] Re: How do I display uploaded images from uploads folder

2019-11-11 Thread Maurice Waka
But I did upload and the image is in the folder.

On Mon, Nov 11, 2019 at 3:48 PM Ruslan Gareev  wrote:

> Hi, looks like your request.args(0) is empty.
>
> понедельник, 11 ноября 2019 г., 15:37:31 UTC+5 пользователь Maurice Waka
> написал:
>>
>> I'm trying to retrieve an uploaded image from the uploads folder using
>> this
>> 
>> example.
>>
>> I keep on being redirected back to the index page.
>>
>> I also tried this option with the same result.
>>
>> This is the controller code:
>>
>> def showarticle():
>> id = request.args(0) or redirect(URL('default', 'index'))
>> article = Article[id]
>> try:
>> import os
>> from PIL import Image
>> except:
>> return
>> stream=Image.open(request.folder + 'uploads/' + id)
>> return response.stream(stream, attachment=False, article=article)
>>
>> How can I get this right?
>> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/GbwQoJymKns/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/d9f38307-39a9-4b1b-b126-a440a8ad8d07%40googlegroups.com
> 
> .
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CALkNK55wO3QXDs6y4yLhYpeMyAWg0wxtW92U%3Dhu2VxbjdfuHWg%40mail.gmail.com.


[web2py] rename request hostname

2019-11-11 Thread Yoel Benitez Fonseca
h!

Is it possible to change the hostname that comes in the form request  so 
that outbound links have the hostname i want?

I have an app in an internal network that I want to make visible from the 
outside with an nginx proxy, all relative links work correctly, this would 
be the example of configuration in nginx:

location ~* ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ {
 rewrite ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ 
/some-folder/statics/staging/$2 break;
proxy_ignore_headers Cache-Control;
add_header Cache-Control public;
add_header Cache-Control max-age=31536000; # seconds, one year
proxy_pass_request_headers  on;
proxy_pass https://some.internal.server.local;
}

location ~* ^/(.*)$ {
rewrite ^/(.*)$ /staging/$1 break;
proxy_set_header Host "some.internal.server.local";
proxy_set_header X-Real-IP $remote_addr;
proxy_ssl_server_name on;
proxy_pass https://some.internal.server.local;
}


That works correctly for any relative link, the problem comes with 
uploads, whose links are being generated for some reason including the 
hostname:

https://some.internal.server.local
/app/download/some.object.a051462ffdcb77a3.746d706c32417038422e6a7067.jpg

and how it happens, i can't change the internal server name and need to 
pass the proxy_set_header Host or I will not have access to that host... The 
only thing I can think of is telling WEB2PY to use a fixed host name when 
generating the links.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/7488ff15-0039-4ee6-8623-3e974f368903%40googlegroups.com.


[web2py] Custom search function in GRID does not work anymore in R-2.18.5?

2019-11-11 Thread Krzysztof Socha
I have some old code that uses a custom search function in a sqlform.grid - 
something along the lines:

def process_filtered(sfields, keywords):
search_query = SQLFORM.build_query(sfields, keywords)
[...]
return search_query

grid = SQLFORM.grid(db.doc_scan_details, searchable=process_filtered)

It used to work fine on older versions of web2py, but when I updated to 
2.18.5 it does not work anymore - i.e., the search function does not seem 
to be called. Why?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/480314c1-06f6-4882-aa55-616fa4b31e48%40googlegroups.com.


[web2py] Re: How do I display uploaded images from uploads folder

2019-11-11 Thread Ruslan Gareev
Hi, looks like your request.args(0) is empty.

понедельник, 11 ноября 2019 г., 15:37:31 UTC+5 пользователь Maurice Waka 
написал:
>
> I'm trying to retrieve an uploaded image from the uploads folder using 
> this 
> 
>  
> example.
>
> I keep on being redirected back to the index page.
>
> I also tried this option with the same result.
>
> This is the controller code:
>
> def showarticle():
> id = request.args(0) or redirect(URL('default', 'index'))
> article = Article[id]
> try:
> import os
> from PIL import Image
> except: 
> return
> stream=Image.open(request.folder + 'uploads/' + id)
> return response.stream(stream, attachment=False, article=article)
>
> How can I get this right?
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/d9f38307-39a9-4b1b-b126-a440a8ad8d07%40googlegroups.com.


[web2py] How do I display uploaded images from uploads folder

2019-11-11 Thread Maurice Waka
I'm trying to retrieve an uploaded image from the uploads folder using this 

 
example.

I keep on being redirected back to the index page.

I also tried this option with the same result.

This is the controller code:

def showarticle():
id = request.args(0) or redirect(URL('default', 'index'))
article = Article[id]
try:
import os
from PIL import Image
except: 
return
stream=Image.open(request.folder + 'uploads/' + id)
return response.stream(stream, attachment=False, article=article)

How can I get this right?
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/29b39bb2-8084-41b8-b2a6-589e39aa3f92%40googlegroups.com.