[web2py] Re: Can't understand this error in gluon/rewrite.py

2018-09-06 Thread Lisandro
I've modified gluon/rewrite.py to log functions and controllers:

if self.args:
try:
mylog = open('mylog.txt', 'a')
mylog.write('%s %s\n' % (self.functions, self.controllers))
mylog.close()
except:
pass
if self.args[0] in self.functions or self.args[0] in self.controllers or 
self.args[0] in applications:
self.omit_function = False


In the generated log I don't see anything weird:

set([]) set(['load', 'default', 'app', 'static'])
set([]) set(['load', 'default', 'app', 'static'])
set([]) set(['load', 'default', 'app', 'static'])
set([]) set(['load', 'default', 'app', 'static'])
set([]) set(['default', 'cache', 'afip', 'reportes', 'contrataciones', 
'admin', 'paypal', 'errores', 'periodos', 'facturas', 'ws', 'sitios', 
'scheduler', 'static', 'mercadopago', 'estadistica', 'notificaciones'])
set([]) set(['default', 'cache', 'afip', 'reportes', 'contrataciones', 
'admin', 'paypal', 'errores', 'periodos', 'facturas', 'ws', 'sitios', 
'scheduler', 'static', 'mercadopago', 'estadistica', 'notificaciones'])
set([]) set(['default', 'cache', 'afip', 'reportes', 'contrataciones', 
'admin', 'paypal', 'errores', 'periodos', 'facturas', 'ws', 'sitios', 
'scheduler', 'static', 'mercadopago', 'estadistica', 'notificaciones'])
set([]) set(['default', 'cache', 'afip', 'reportes', 'contrataciones', 
'admin', 'paypal', 'errores', 'periodos', 'facturas', 'ws', 'sitios', 
'scheduler', 'static', 'mercadopago', 'estadistica', 'notificaciones'])
set([]) set(['default', 'cache', 'afip', 'reportes', 'contrataciones', 
'admin', 'paypal', 'errores', 'periodos', 'facturas', 'ws', 'sitios', 
'scheduler', 'static', 'mercadopago', 'estadistica', 'notificaciones'])
set([]) set(['default', 'cache', 'afip', 'reportes', 'contrataciones', 
'admin', 'paypal', 'errores', 'periodos', 'facturas', 'ws', 'sitios', 
'scheduler', 'static', 'mercadopago', 'estadistica', 'notificaciones'])


There is a bunch of that. Notice the function list is always empty, I'm not 
sure if that's correct (I would say yes, because everything works as 
expected).
The list of controllers is correct, they correspond to the application 
running in each case.

Because I have many many applications installed and running, the log file 
was growing very quickly, so I made a simple modification to the code, to 
log only when the application was one of the ones throwing the error:

if self.args:
try:
if self.application in ('pescaregional', 'experienciasgo'):
mylog = open('mylog.txt', 'a')
mylog.write('%s %s\n' % (self.functions, self.controllers))
mylog.close()
except:
pass
if self.args[0] in self.functions or self.args[0] in self.controllers or 
self.args[0] in applications:
self.omit_function = False


The log was the same as the one I showed before.
However, I've noticed that *self.application is not set in the scheduler 
environment*, because the logging was done when the requests were made 
through http, but nothing was logged when the requests came from the 
scheduler environment.


Anyway, I think this is too much for me. Debugging this is getting hard, as 
the problem happens only in my production environment, and I don't like 
very much the idea of changing web2py code of the main instance that is 
running several apps. Regardless I use uwsgi gracefully reloading, I've 
done this tests very late at night, when the activity is low, but still I'm 
afraid of breaking something at production.

For now, I'll just apply a simple patch: whenever I use URL() in the 
scheduler environment, I'll check that the args are provided as strings.
Thanks a lot for your help!!

El martes, 4 de septiembre de 2018, 11:43:28 (UTC-3), Leonel Câmara 
escribió:
>
> The problems seems to be in the controllers and not in the application 
> list since looking at your logs they seem to be fine.
>
> Notice that "load" does not check if the controllers are coming just with 
> "DEFAULT" string.
>
> https://github.com/web2py/web2py/blob/master/gluon/rewrite.py#L283
>
> Can you log the controllers too?
>

-- 
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] Setting filename to a streamed file

2018-09-06 Thread Simona Chovancová
Hello.
I have a backend function that is supposed to stream a pdf file, but not 
instantly download it. It's being called like this 
.../function_to_create_pdf/323, where the number is some ID. I create a 
FPDF stream and make function return this
response.headers['Content-Type'] = None
return response.stream(pdf_stream, 4096, filename="iwanthisname.pdf")

Soo the problem is, this works well if I set attachment=True, but since I 
only want to display this pdf file, the filename is not applied in any way. 
I get the right document and all that, but the browser tab title is 
basically just the argument (ID) I passed to the function and if I press 
the download button it is saved as 323.pdf. I want to edit its name, how 
can I do this? I tried changing tab name with reponse.title, but it didn't 
work. Thank you.

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


[web2py] Re: Spreadsheet.py documentation and status

2018-09-06 Thread Yann Dulondel
Hi
I had a look on w2ui and look good but don't have any idea on how to use it 
with w2py.
I'm a client-server dev.
This a new world for me.
If you have any clue, it would be really good
Thanks
Yann

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