[web2py] Re: switch writable True/False

2017-10-20 Thread Dave S


On Wednesday, October 18, 2017 at 5:12:35 AM UTC-7, Mirek Zvolský wrote:
>
> I have a form:
> SQLFORM.factory(*field_list)
>
> First item in field list is a foreign key to some table.
> I see the selected value and all possible selectable values great.
> Example: drink : watter from (watter, beer, wine)
>
> However: I try make the first field readonly.
> Now I see it readonly, but with value None.
> Example: drink : None (in appadmin is the correct value: watter)
>
> What can I do better?
> Yet I try set
> field list[0].writable = False
> before the form=.. command
> or something similar between form=.. and form.process().accepted
>



I don't use factory, so I don't know if it has special requirements for 
this, but here's a snippet I use on an ordinary SQLFORM:


db.run.distance.readable = False
db.run.duration.readable = False
form = SQLFORM(db.run,linkto=link)
if form.process().accepted: 
  (etc)


For another form in the same app:

if request.vars.startseg:
db.segment.isstart.default = (request.vars.startseg == 'T' )
db.segment.isstart.readable = db.segment.isstart.default
db.segment.isstart.writable = db.segment.isstart.default
form = SQLFORM(db.segment)
if form.process().accepted:


 I hope this helps.

/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] Can i share a file with others and dont compromise my app security?

2017-10-20 Thread António Ramos
Hello in my app i need to share files with some clients that dont have
access to my app.

I will send a link directly to the file in the database that only the
destination can see
for example
i will send to customer A a link like

http://www.myapp.pt/xxxt/default/download/entities.file.bbsas17beb165d12.312e626174.pdf

Is this safe ?
Does this link compromises the app in any way?


Regards
António

-- 
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: Serving files from a Google Cloud Storage Bucket

2017-10-20 Thread Julian Sanchez
In case this helps anyone else, here is how I got it to work:

response.headers['Content-Type'] = 'application/octet-stream'
response.headers['Content-Disposition'] = 'attachment;filename=%s' % 
file_name
file_reader = cloudstore.open(file_path)
return file_reader.read()

any other attempts to use response.write or response.body kept returning 
'None'


On Monday, October 16, 2017 at 6:09:07 AM UTC-5, Julian Sanchez wrote:
>
> I'm in the process of 'upgrading' an old Web2py application hosted on GAE 
> that performs a fair amount of file manipulation.  The original version 
> used the blobstore to create files, and the 'default/download' function was 
> modified to serve those blobs like this (abbreviated):
>
> blob_key = request.args[0]
> blob_info = blobstore.get(blob_key)
>
> response.headers['X-AppEngine-BlobKey'] = blob_key;
> response.headers['Content-Type'] = blob_info.content_type;
> response.headers['Content-Disposition'] = "attachment; 
> filename=%s" % blob_info.filename
>
> blob_reader = blob_info.open()
> response.stream(blob_reader)
>
> Blobstore is now gone so I changed the code to use a GCS bucket.  
> Everything works well everywhere in the application as far as uploading and 
> creating files internally, but when I want to offer those files for 
> download I can't get it to work.  As you know, files on GCS buckets are 
> accessible via their path (i.e. cloudstore.open(file_path)) however if I 
> try something like:
>
> file_reader = cloudstore.open(file_path)
> response.stream(file_reader)
>
> all I get is a blank webpage with 'None' written on it, and no file.
> I can't (and don't want to) offer the actual file_path for download 
> straight to the user because the bucket permissions are private and web2py 
> is the only one authorized to access it.
>
> I've tried a number of combinations (setting headers with content-type and 
> content-disposition versus no headers, response.write versus 
> response.stream, reading file to StringIO object and try to stream/write 
> that object instead) but none of them work.  I'm at a point where I'm 
> blindly trying different code combinations.  Does anybody have a working 
> code example for this?
>
> Thanks,
> Julian
>
>

-- 
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] to be or not to be... run by scheduler

2017-10-20 Thread Manuele Pesenti

Hi *!

Is there a way to distinguish from within a function if it's run from 
the scheduler or not?


thanks a lot

    M.

--
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] maybe too many db connections todb on pythonanywhere

2017-10-20 Thread Manuele Pesenti
I often get this error from the db engine of my pythonanywhere account 
service


OperationalError: FATAL:  remaining connection slots are reserved for 
non-replication superuser connections


is there something quick to solve or by-pass it or do I need some 
profiling to limitate requests to the db?


thank you in advance

    M.

--
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: to be or not to be... run by scheduler

2017-10-20 Thread Anthony
If it is a scheduler execution, request.is_scheduler will be True.

Anthony

On Friday, October 20, 2017 at 9:09:40 AM UTC-4, Manuele wrote:
>
> Hi *! 
>
> Is there a way to distinguish from within a function if it's run from 
> the scheduler or not? 
>
> thanks a lot 
>
>  M. 
>
>

-- 
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: Bug with URL encoding?

2017-10-20 Thread Anthony
By default, characters in args that do not match the '[^\w/.@=-]' regular 
expression are replaced with underscores. To override that behavior, there 
are two options:

   1. In routes.py, set routes_apps_raw to a list of applications that will 
   handle their own args parsing. In those apps, the entire args part of the 
   URL (everything in path_info after /app/controller/function) will be 
   available in request.raw_args, and you will have to parse it yourself.
   2. Use the parameter-based rewrite system and specify args_match to suit 
   your needs (the default args_match regex is '([\w@ =-]|(?<=[\w@ -])[.])*$'.
   
Anthony

On Thursday, October 19, 2017 at 1:30:09 PM UTC-4, Francisco Ribeiro wrote:
>
> Hi,
>
> I have found that when I do request.args(), colons ':' even when properly 
> URL encoded become an underscore '_' .
>
> def echo():
> print request.args(0)
> return dict()
>
> A request http://.../echo/%a_ will become :
> __ 
>
> which prevents me from distinguishing one from another.
>
> Am I missing something? shouldn't request.args() take care of URL encoding 
> / decoding for me?
>
> Thank you
> Kind regards,
> Francisco Ribeiro
>

-- 
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] Custom maintenance message

2017-10-20 Thread Yoel Benitez Fonseca
hi !

How can i make a custom 'Temporarily down for maintenance' page ?

-- 
Msc. Yoel Benítez Fonseca
Dpto. Informática. Redacción Adelante
http://www.adelante.cu/

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


[web2py] Re: Custom maintenance message

2017-10-20 Thread Yoel Benitez Fonseca
Nerver mind ... i have found app/static/503.html

now ¿how to include images and souch ?

2017-10-20 12:04 GMT-04:00 Yoel Benitez Fonseca :
> hi !
>
> How can i make a custom 'Temporarily down for maintenance' page ?
>
> --
> Msc. Yoel Benítez Fonseca
> Dpto. Informática. Redacción Adelante
> http://www.adelante.cu/



-- 
Msc. Yoel Benítez Fonseca
Dpto. Informática. Redacción Adelante
http://www.adelante.cu/

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


[web2py] Re: Custom maintenance message

2017-10-20 Thread Dave S


On Friday, October 20, 2017 at 10:05:34 AM UTC-7, Yoel Benitez Fonseca 
wrote:
>
> Nerver mind ... i have found app/static/503.html 
>
> now ¿how to include images and souch ? 
>

Just put those images in app/static (like the FB and Twitter logos), and 
add a 
in your 503.html file.

/dps
 

>
> 2017-10-20 12:04 GMT-04:00 Yoel Benitez Fonseca  >: 
> > hi ! 
> > 
> > How can i make a custom 'Temporarily down for maintenance' page ? 
> > 
> > -- 
> > Msc. Yoel Benítez Fonseca 
> > Dpto. Informática. Redacción Adelante 
> > http://www.adelante.cu/ 
>
>
>
> -- 
> Msc. Yoel Benítez Fonseca 
> Dpto. Informática. Redacción Adelante 
> http://www.adelante.cu/ 
>

-- 
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: maybe too many db connections todb on pythonanywhere

2017-10-20 Thread Alex Glaros
there are a lot of fixes if search on your error string, plus 
max_connections parm info is at 
Postgres https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server

what is your max_connections set to now?

Alex Glaros


-- 
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: response view with markdown

2017-10-20 Thread Anthony
On Tuesday, October 17, 2017 at 5:29:24 PM UTC-4, 黄祥 wrote:
>
> why web2py can't render the views in markdown format that been assign 
> (*.md) in most simple way?
> e.g.
> def testmd():
> response.view = 'default/testmd.md'
> #response.render = 'default/testmd.md'
> return locals()
>
> think about github pages can render it 
>

The web2py template engine does not do any specialized rendering of content 
outside the {{...}} delimiters. It processes the Python code inside the 
template delimiters and returns everything else as is. What you ask is 
simply not part of the design of the template system (nor most other 
template systems, I think).

Of course, you can pass markdown content to a web2py template and have it 
rendered to HTML using a markdown-to-html converter. Or you can do the 
conversion in the controller and return the output directly rather than 
using a view.

I'm not sure how Github Pages is relevant here. The issue is not a 
technical one (there are libraries to generate HTML from Markdown) -- this 
is already doable in web2py. It's just that the template system is not 
designed to do any special post-processing of the template content.

Note, we couldn't add this functionality without breaking backward 
compatibility -- the framework can't start automatically assuming any view 
with a .md extension includes Markdown to be transformed to HTML (existing 
apps might be using the .md extension for some other purpose or be designed 
to return actual Markdown content). We could probably create a generic.md 
view that looks for a named view associated with the current requested 
function (perhaps with a different extension, such as .markdown), renders 
that view, and then converts it from Markdown to HTML.

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: response view with markdown

2017-10-20 Thread 黄祥
got it, pretty much clear, thanks anthony, massimo and bernhart, perhaps 
for now i just stick with the bernhart code to transform markdown into html 
in controller, because i don't know how to create generic.md (or 
generic.markdown) that will transform markdown into html, hehe

thanks and best regards,
stifan

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


[web2py] Re: Custom maintenance message

2017-10-20 Thread 黄祥
i just interest for modif the 404 error not found, when trying to modif 
static/404.html, the result is not expected (no error traceback occur)
e.g.
*static/404.html*
this page doesn't exist

*result*
invalid controller (123/index)

*expected result*
this page doesn't exist

any idea to achieve it using web2py way? using routes maybe or controllers?

thanks and best regards,
stifan

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


[web2py] Re: Custom maintenance message

2017-10-20 Thread Dave S
On Friday, October 20, 2017 at 6:42:17 PM UTC-7, 黄祥 wrote:
>
> i just interest for modif the 404 error not found, when trying to modif 
> static/404.html, the result is not expected (no error traceback occur)
> e.g.
> *static/404.html*
> this page doesn't exist
>
> *result*
> invalid controller (123/index)
>
> *expected result*
> this page doesn't exist
>
> any idea to achieve it using web2py way? using routes maybe or controllers?
>
>
Routes.py and applications/myapp/routes.py,
but I don't have a complete answer yet.  
(The complete answer is documented in the sample route.py files, but I 
haven't absorbed all that yet.)

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