[web2py] Ordering a dropdown in SQLFORM alphabetically

2015-12-16 Thread Evan Caldwell
I am having a hard time ordering a dropdown in a SQLFORM alphabetically. In my model: db.define_table('departments', Field('name', notnull=True, unique=True), Field('college_id','reference college', label='College'), Field('department_rep_user_id','reference auth_user',

[web2py] Re: "Uploading and install packed application" works, but running database administration fails

2015-12-16 Thread Niphlod
not every model can be safely applied to an empty database. What - probably - happened is that you had at some point in development - state a - state b --> migrations were triggered - state c Now, with an empty database, you're trying to recreate state c, but the model doesn't know about the

[web2py] Re: Run code before and after functions (statsd issue)

2015-12-16 Thread Anthony
response._caller is a function that wraps all controller actions, so something like this might work: def statsd(f): blah.start() result = f() blah.stop() return result response._caller = statsd Anthony On Wednesday, December 16, 2015 at 2:49:25 PM UTC-5, Octavian G wrote: > >

[web2py] Run code before and after functions (statsd issue)

2015-12-16 Thread Octavian G
Hello, I'd like to use statsd with my app. I'd like to time the execution of a web2py function and various smaller pieces of code. The statsd doc (http://statsd.readthedocs.org/en/v3.2.1/reference.html#timer) says their timer decorators are not threadsafe. This means I have to run a

[web2py] Re: Non authorized file download in custom grid view

2015-12-16 Thread Gael Princivalle
Shame on me. I've used part of a script from another application that download the pdf from a static folder outside the app. Thanks Anthony. Il giorno mercoledì 16 dicembre 2015 16:05:29 UTC+1, Anthony ha scritto: > > Your href would be a relative URL that includes only the file name, which >

[web2py] Re: Can you have multiple plugins use Web2py Scheduler in the same App?

2015-12-16 Thread Niphlod
This is definitely weird. Unless you're plugins that carry themselves the instantiation of the Scheduler AND the definition of tasks: there should be only ONE scheduler instance (because it's thought as a singleton) and tasks definitions should be available on models so they'd be

[web2py] Re: Ordering a dropdown in SQLFORM alphabetically

2015-12-16 Thread Niphlod
a proper IS_IN_DB with the correct orderby in models should be the easiest way to go. On Wednesday, December 16, 2015 at 8:33:06 PM UTC+1, Evan Caldwell wrote: > > > I am having a hard time ordering a dropdown in a SQLFORM alphabetically. > > In my model: > db.define_table('departments', >

[web2py] Re: The Almighty Form

2015-12-16 Thread Niphlod
you're doing it wrong. "fields" is a tuple containing - usually - id, label, controls and help. On Wednesday, December 16, 2015 at 3:14:02 PM UTC+1, Alfonso Serra wrote: > > Ive found a workaround but the question still remains. Why cant we define > formstyles like the example above? > > the

[web2py] Re: Ordering a dropdown in SQLFORM alphabetically

2015-12-16 Thread Evan Caldwell
I tried: db.mentors.auth_user_id.requires = IS_IN_DB(db, 'auth_user.id', '%(name)s', orderby = db.auth_user.first_name) but it had no effect. I read on another question about building and ordering a set and then using IS_IN_SET on that but I'm not sure how to go about doing that; can I do a

[web2py] Re: The Almighty Form

2015-12-16 Thread Anthony
On Wednesday, December 16, 2015 at 4:53:16 AM UTC-5, Alfonso Serra wrote: > > Im trying to create a formstyle, when the form is submitted without > introducing any value it skips any kind of validation and, without being > accepted, tries to perform db changes. Eventually i get an error ticket

[web2py] Re: Determine which login method was successful.

2015-12-16 Thread Jonathan R
I'll try this, -- 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"

[web2py] Re: The Almighty Form

2015-12-16 Thread Alfonso Serra
Thanks Niphlod and Anthony for your help. Niphlod i didnt want to use the tuple fields, was using form.fields to build everything from scratch as Anthony said. I like to have some kind of freedom to create html, without breaking internals whenever is posible. I thought requires was performed

[web2py] Re: The Almighty Form

2015-12-16 Thread Anthony
On Wednesday, December 16, 2015 at 5:09:51 PM UTC-5, Alfonso Serra wrote: > > I thought requires was performed in a different process than the form > serialization. It would be better if the requires information isnt embeded > in the inputs, but the form itself. > Wasnt expecting to redeclare

[web2py] how to wrap an already existing input element in a new div in web2py

2015-12-16 Thread Sujata Aghor
how to wrap an already existing input element in a new div in web2py -- 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

[web2py] Changing navbar color

2015-12-16 Thread Joe
I am trying to change the background-color of the nav bar in the newest web2py bootstrap 3 version. In the previous version I was able to change it in web2py_bootstrap.css section "other rules" but that doesn't seem to work in web2py_bootstrap3.css where there is no "other rules" section. I

[web2py] Re: How to upload a file in a directory without SQLFORM ?

2015-12-16 Thread Adrien
This is the subject where i found the previous code : https://groups.google.com/forum/#!searchin/web2py/upload$20file$20in$20directory$20with$20form/web2py/nyLx2MBLG2k/HQQ8a95D9oIJ Le mercredi 16 décembre 2015 11:17:05 UTC+1, Adrien a écrit : > > Thx for your quick answer. > But i try to do my

[web2py] Re: How to upload a file in a directory without SQLFORM ?

2015-12-16 Thread Anthony
On Wednesday, December 16, 2015 at 4:07:11 AM UTC-5, Adrien wrote: > > > Hi everyone, > Like i said in the title, i want to upload a file in a directory with a > form. > I saw another subject where he did what i want but with me, it doesn't > work and i don't know why. > > This is my controller

[web2py] Re: How to upload a file in a directory without SQLFORM ?

2015-12-16 Thread Anthony
On Wednesday, December 16, 2015 at 4:53:41 AM UTC-5, xmarx wrote: > > in controller: > > def index(): > import os > form=SQLFORM.factory(Field('name'),Field('file', > 'upload',uploadfolder=os.path.join(request.folder,'uploads'))) > if form.process().accepted: >

[web2py] Re: Web2py : how to make one shared upload folder for all applications

2015-12-16 Thread Anthony
Field('myfile', 'upload', uploadfolder='path/to/uploads/') Anthony On Wednesday, December 16, 2015 at 5:34:31 AM UTC-5, Ahmed Saidi wrote: > > Hi, > I have mutiple web2py applications that uses the same database. > When i upload a file in the first application, i cant see the file in the >

[web2py] Re: The Almighty Form

2015-12-16 Thread Alfonso Serra
Ive found a workaround but the question still remains. Why cant we define formstyles like the example above? the workaround is by creating the formstyle like this: def mystyle(form): container = CAT() for fld in form.fields: container += INPUT(_name=fld) container +=

[web2py] Re: How do I not show particular fields for the user to fill while signing up and make them fill later?

2015-12-16 Thread Anthony
Alternatively, you can simply set the fields' readable and writable attributes to False during registration but True during the profile setup. Anthony On Wednesday, December 16, 2015 at 6:28:28 AM UTC-5, 黄祥 wrote: > > just an idea that got from a lot website, is they have separate table for >

[web2py] web2py as an API provider

2015-12-16 Thread desta
I am thinking of using web2py to build a REST API project. I believe that features like authentication and authorization will save me a lot of development time and I will be able to focus on building the API. I already know that web2py is a great and reliable platform but I would like to hear

[web2py] Re: Non authorized file download in custom grid view

2015-12-16 Thread Anthony
Your href would be a relative URL that includes only the file name, which is not the proper URL for downloading a file stored via an upload field. Instead, you should pass the file name as a URL arg to the default/download function: {{=URL('default', 'download',

[web2py] Re: How to upload a file in a directory without SQLFORM ?

2015-12-16 Thread Adrien
For the path, i just don't write my path but it works only when i used the all path (from C:/ to my folder pictures like "C:/Adrien/web2py/applications/myApp/view/pictures/", don't know how to write only "pictures/"). So if i can resolve this and find how to change the filename, it's good and

[web2py] Re: Make variable available to all sessions in memory

2015-12-16 Thread Anthony
Is there a passphrase per user, or just one for the whole app (perhaps entered by an admin user)? In either case, I suppose you could use cache.ram, but if there is a passphrase per user, you would need a unique key for each user (e.g., the user ID), and you would also need to do some

[web2py] Re: Make variable available to all sessions in memory

2015-12-16 Thread Gary Cowell
No, it'd be one pass phrase for the whole thing. Like a vault key. There'd be another page for entering two of them so you can change the phrase, decrypt, encrypt pass the whole thing. cache.ram sounds a possibility, I'll look into that, I recall some discussions a while back that this wasn't

[web2py] Re: How to upload a file in a directory without SQLFORM ?

2015-12-16 Thread Anthony
Always use Python to build your paths: import os filepath = os.path.join(request.folder, 'view', 'pictures', filename) Again, don't just use the filename provided by the user, as that is a security vulnerability. Anthony On Wednesday, December 16, 2015 at 10:13:10 AM UTC-5, Adrien wrote: > >

[web2py] Make variable available to all sessions in memory

2015-12-16 Thread Gary Cowell
Hello I want to encrypt fields in the database, because of reasons. I've been through the arguments, but there we have it. I look at this web2py slice: http://www.web2pyslices.com/slice/show/2012/encrypt-information-into-the-database And it gives a good illustration of how to do it in model

[web2py] Re: web2py as an API provider

2015-12-16 Thread Gary Cowell
I'm using it to build REST services atop legacy data. So, it certainly can be used in a 'professional' way, whatever that means. I find that DAL is useful, and JSON and REST are easy to implement and as you say, can concentrate on the API rather than the nuts and bolts to a great extent. If

[web2py] Re: How to upload a file in a directory without SQLFORM ?

2015-12-16 Thread Adrien
Thanks Anthony, it works ! Yes i know, i will use the same security which was used before (was in PHP) but i know how to use this in python now. Thx again :) Le mercredi 16 décembre 2015 16:19:25 UTC+1, Anthony a écrit : > > Always use Python to build your paths: > > import os > filepath =

[web2py] Re: How do I not show particular fields for the user to fill while signing up and make them fill later?

2015-12-16 Thread 黄祥
just an idea that got from a lot website, is they have separate table for that, let say for login user it store in auth_user and then they build another table let say profile that contain additional information about the user, like : phone, address, hobby, etc and refer the table to the logged

[web2py] Non authorized file download in custom grid view

2015-12-16 Thread Gael Princivalle
Hello all. I would like in a custom grid view to add a link to a pdf file like that: Download PDF Controller: grid_memos = SQLFORM.grid(query=db.memos) But when the user, also after login, click on the link, main grid is displayed and web2py return "Non authorized". Someone knows how I can

[web2py] Re: Make variable available to all sessions in memory

2015-12-16 Thread Anthony
cache.ram is limited to a single server, but if you need to span multiple servers, you could set up something like memcache. Anthony On Wednesday, December 16, 2015 at 10:37:41 AM UTC-5, Gary Cowell wrote: > > No, it'd be one pass phrase for the whole thing. Like a vault key. > > There'd be

[web2py] Re: web2py as an API provider

2015-12-16 Thread desta
You are right the term 'professional' is rather poor. I meant that the service is expected to be deployed and be used as part of a company's services. Thanks for your comments. On Wednesday, December 16, 2015 at 5:32:21 PM UTC+2, Gary Cowell wrote: > > I'm using it to build REST services atop

[web2py] Re: nested reference fields in IS_IN_DB validator

2015-12-16 Thread Pierre-Antoine Roiron
Here's what I had in mind, if of any interest. This function does not work (and it's a simplified one that dosn't take into account the multiple=True in db.customer.guitar_ref). I'm not sure why it dosn't work. I think it's because I call a function in the first arg of IS_IN_DB. If someone

[web2py] The Almighty Form

2015-12-16 Thread Alfonso Serra
Im trying to create a formstyle, when the form is submitted without introducing any value it skips any kind of validation and, without being accepted, tries to perform db changes. Eventually i get an error ticket like: pymysql.err.InternalError'> (1048, u"Column 'salida' cannot be null")

[web2py] Re: How to upload a file in a directory without SQLFORM ?

2015-12-16 Thread xmarx
in controller: def index(): import os form=SQLFORM.factory(Field('name'),Field('file', 'upload',uploadfolder=os.path.join(request.folder,'uploads'))) if form.process().accepted: request.flash='file uploaded!' return dict(form=form) in view index.html: {{extend

[web2py] How to upload a file in a directory without SQLFORM ?

2015-12-16 Thread Adrien
Hi everyone, Like i said in the title, i want to upload a file in a directory with a form. I saw another subject where he did what i want but with me, it doesn't work and i don't know why. This is my controller default.py : def test(): import shutil filename=request.vars.filename

[web2py] Re: How to upload a file in a directory without SQLFORM ?

2015-12-16 Thread Adrien
Thx for your quick answer. But i try to do my form without sqlform (i didn't show all my form) because I have a form with a lot of fields, and they aren't all on the same page, i mean it's with anchor on the same page, and i dunno how to do the same thing with a factory. I can't upload a file

[web2py] compute using a variable for a field name (db.table.fieldname)

2015-12-16 Thread Pierre-Antoine Roiron
Hi, I have a function that works well and helps to compute the sum of fields referenced by a list:reference field in another table : table 'line' with field: 'price','double' table 'invoice' with fields: 'line_id', 'list:reference' 'total','double' def sum_total(row): t=0 for

[web2py] Re: compute using a variable for a field name (db.table.fieldname)

2015-12-16 Thread Pierre-Antoine Roiron
I nailed it... and I am ashamed : > for id_line in row.line_id: t=t+db.line[id_line][line_field_name] > and not for id_line in row.line_id: t=t+db.line[line_field_name][id_line] -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py

[web2py] Web2py : how to make one shared upload folder for all applications

2015-12-16 Thread Ahmed Saidi
Hi, I have mutiple web2py applications that uses the same database. When i upload a file in the first application, i cant see the file in the other application. How to configure web2py to use the same folder for all applications ? If its not possible how can I solve this problem ? Thank you.

[web2py] Can you have multiple plugins use Web2py Scheduler in the same App?

2015-12-16 Thread mike
I have 2 different plugins that currently use Web2Py Scheduler. They both work when they are installed in an App separately. If they are both isnstalled in the same App only one of the plugins scheduled tasks get run. (The one with the last loaded model alphabetically). Can someone point me in

[web2py] "Uploading and install packed application" works, but running database administration fails

2015-12-16 Thread Mat Miles
1. In the Web2py administrative interface I select "pack all" to output an application I have created. 2. I then select "Upload and install packed application" to a new project with the name of dev and upload the application I just packed. 3. I then edit db.py to change the db = DAL to a

[web2py] How do I not show particular fields for the user to fill while signing up and make them fill later?

2015-12-16 Thread aston . ribat
For example, fields like their profile picture and all have to be filled later, not while signing up. How do I do that? According to my db table, they are forced to fill everything in beginning only. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] How do I make users fill particular fields of the auth_user table later after signing up?

2015-12-16 Thread aston . ribat
For example, their profile pic have to be posted they sign up. But they are forced to fill everything in the beginning only. How to make them fill certain fields only in the beginning? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -