Re: [web2py] Re: optimizations

2015-09-25 Thread Manuele Pesenti
Il 25/09/15 16:11, Niphlod ha scritto:
> there are multiple sides of the story.
> The original recommendation stands for SQLite, which doesn't handle at
> all concurrent writes. Given scheduler does a lot of it, a separate
> database is warmly advised to prevent locks on the main app.
> You're allowed to separate databases (hence, connections) as long as
> you don't need to orchestrate transactions between them
> You can hope for better performances with separate databases, as long
> as they don't live in the same server: if they do live in the same
> server, the same "pressure" is applied to the database server host.
> When you "split" connections, a little overhead to establish the
> connection in the model is added.
>
> I'd say that from a technical standpoint, sessions CAN be moved to a
> separate database, because they are logically separated from any other
> table.
> If you're looking for performance improvements over sessions though,
> I'd highly recommend the redis store which is a gazillion times faster
> and lighter on the host.
Thank you very mutch Niphold!

All is clear now :)

Manuele

-- 
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: sqlform.factory

2015-09-25 Thread Laurent Lc
Sorry i found

distinct=True

Le vendredi 25 septembre 2015 16:25:42 UTC+2, Laurent Lc a écrit :
>
> Hi,
>
> i'd like to create a form from a database.
> form = SQLFORM.factory(
> Field('groupe',requires=IS_IN_DB(db1,db1.test.id
> ,'%(groupe)s',multiple=False)),
> Field('financement',requires=IS_IN_DB(db1,db1.test.id
> ,'%(financement)s')),
> 
> #Field('quantity','integer',requires=IS_INT_IN_RANGE(1,100))).process()
> Field('date','date')).process()
>
> Im my first field "groupe" there are many doubloons and i need to put a 
> condtional query, howto do that ?
>
> In Sql like this
>
> SELECT DISTINCT  from mytable
> in web2py ..
>
> 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] How to download (zip) file with jQuery ajax?

2015-09-25 Thread Phillip
 

A zip file is written in 'download_data' and nothing happens upon 
returning. 


Please indicate what is missing in the following ajax call and / or 
controller function to spawn the zip file download.


jQuery.ajax({method:'get',url:'{{=URL('download_data')}}',

data:fileIDs,

success: function(){}


});


__


def download_data():

vars = request.get_vars

fileIDs = vars.values()

import zipfile

import cStringIO

import contenttype as c



zf = zipfile.ZipFile('data download.zip', mode='w')

try:

for file_id in fileIDs:

file = db.files[file_id].file

fileLoc = db.files.file.retrieve_file_properties(file)['path'] 
+ '/' + file

displayName = db.files[file_id].file_name

zf.write(fileLoc, displayName)



finally:

zf.close()


s=cStringIO.StringIO() 

 

zipfile = open('data download.zip','r')

s.write(zipfile.read())  

response.headers['Content-Type'] = c.contenttype(filename)

response.headers['Content-Disposition'] = "attachment; filename=%s" % 
filename  

return s.getvalue()

-- 
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: How to download (zip) file with jQuery ajax?

2015-09-25 Thread Niphlod
usually I do

def download_that():
  ...
 tempfile = StringIO()
 temparchive = zipfile.ZipFile(tempfile, 'w', zipfile.ZIP_DEFLATED)
 blablabla
 temparchive.writestr(filename, filecontent)
 temparchive.close() #writes 
 response.headers['Content-Disposition'] = 
'attachment;filename=blablabla.zip'
 response.headers['Content-Type'] = 'application/zip'
 rtn = tempfile.getvalue()
 tempfile.close()
 return rtn

On Friday, September 25, 2015 at 8:55:01 PM UTC+2, Phillip wrote:
>
> A zip file is written in 'download_data' and nothing happens upon 
> returning. 
>
>
> Please indicate what is missing in the following ajax call and / or 
> controller function to spawn the zip file download.
>
>
> jQuery.ajax({method:'get',url:'{{=URL('download_data')}}',
>
> data:fileIDs,
>
> success: function(){}
>
>
> });
>
>
> __
>
>
> def download_data():
>
> vars = request.get_vars
>
> fileIDs = vars.values()
>
> import zipfile
>
> import cStringIO
>
> import contenttype as c
>
> 
>
> zf = zipfile.ZipFile('data download.zip', mode='w')
>
> try:
>
> for file_id in fileIDs:
>
> file = db.files[file_id].file
>
> fileLoc = db.files.file.retrieve_file_properties(file)['path'] 
> + '/' + file
>
> displayName = db.files[file_id].file_name
>
> zf.write(fileLoc, displayName)
>
> 
>
> finally:
>
> zf.close()
>
>
> s=cStringIO.StringIO() 
>
>  
>
> zipfile = open('data download.zip','r')
>
> s.write(zipfile.read())  
>
> response.headers['Content-Type'] = c.contenttype(filename)
>
> response.headers['Content-Disposition'] = "attachment; filename=%s" % 
> filename  
>
> return s.getvalue()
>

-- 
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] optimizations

2015-09-25 Thread Manuele Pesenti
Hi,
I remember (but at the moment I cannot find on the online book) that in
case you use the scheduler in a project is suggested not to use the same
database as you use in your application... could it be a good suggestion
for session too? in case I intend to store my session on db...
I use PostgreSQL for my projects do anybody has experience to say if
it's usefull to use more than one database for one application or if
it's a unuseful complication?

Thank you very mutch
Cheers

Manuele

-- 
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] web2py dry

2015-09-25 Thread Vinicius Assef
Create a module and import it where necessary.

Or, if really widely used among many places, create a function in any `models/` 
script and just call it anywhere.

—
Vinicius.




> On 25 Sep 2015, at 07:17, T.R.Rajkumar  wrote:
> 
> A list of  employess are retuned by a stored procedure in database. I use 
> this in many pages of my app. How to make it DRY? That is I should be able to 
> call the procedure may be in a module and use in all my pages. Pl. help. 
> 
> -- 
> 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] Re: Nginx / Web2py modules dont reload

2015-09-25 Thread Mark Billion
Much appreciated everyone.  So far touch uwsgi.ini seems to be working...

On Thu, Sep 24, 2015 at 11:34 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Track changes is really meant for testing and not for production and I
> cannot exclude something strange can happen in a highly concurrent
> environment. If the module is in the app modules/ folder, all workers
> should update it but something else may be going on. As Leonel says
> restarting uwsgi-emperor is the safest thing.
>
>
> On Thursday, 24 September 2015 18:38:32 UTC-5, Mark Billion wrote:
>>
>> Running w2p on nginx/ubuntu 14.04.  When I change a module's code, the
>> changes dont show up when I load the app again (ie a class that returned 2
>> but now returns 1 still returns 2).  Ive turned sendfile off in Nginx
>> and have reloaded the thing over and over.  Sometimes it works and
>> sometimes I get the same (wrong) result. Any thoughts?
>>
> --
> 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/F9wY1JcjVqo/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.
>



-- 
Mark M. Billion
1904 N. Lincoln
Wilmington, DE 19806
302.416.2199

-- 
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: Installing app on Pythonanywhere

2015-09-25 Thread Leonel Câmara
Usually that was because naming your application init would make it the 
default application in pythonanywhere and then your problem of having the 
app name appear in the URL should not happen so that's weird.

Anyway, I think you can go 
to 
https://www.pythonanywhere.com/user/[[your_username]]/files/home/[[your_username]]/web2py

Then, just add a file named routes.py with this as content:
 
routers = dict(
# base router
BASE=dict(
default_application='init',
),
)

Finally, reload your webapp in the web tab.

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

2015-09-25 Thread T.R.Rajkumar
A list of  employess are retuned by a stored procedure in database. I use 
this in many pages of my app. How to make it DRY? That is I should be able 
to call the procedure may be in a module and use in all my pages. Pl. help. 

-- 
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: optimizations

2015-09-25 Thread Niphlod
there are multiple sides of the story.
The original recommendation stands for SQLite, which doesn't handle at all 
concurrent writes. Given scheduler does a lot of it, a separate database is 
warmly advised to prevent locks on the main app.
You're allowed to separate databases (hence, connections) as long as you 
don't need to orchestrate transactions between them
You can hope for better performances with separate databases, as long as 
they don't live in the same server: if they do live in the same server, the 
same "pressure" is applied to the database server host.
When you "split" connections, a little overhead to establish the connection 
in the model is added.

I'd say that from a technical standpoint, sessions CAN be moved to a 
separate database, because they are logically separated from any other 
table.
If you're looking for performance improvements over sessions though, I'd 
highly recommend the redis store which is a gazillion times faster and 
lighter on the host.

-- 
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] sqlform.factory

2015-09-25 Thread Laurent Lc
Hi,

i'd like to create a form from a database.
form = SQLFORM.factory(

Field('groupe',requires=IS_IN_DB(db1,db1.test.id,'%(groupe)s',multiple=False)),

Field('financement',requires=IS_IN_DB(db1,db1.test.id,'%(financement)s')),

#Field('quantity','integer',requires=IS_INT_IN_RANGE(1,100))).process()
Field('date','date')).process()

Im my first field "groupe" there are many doubloons and i need to put a 
condtional query, howto do that ?

In Sql like this

SELECT DISTINCT  from mytable
in web2py ..

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.