[web2py] Re: user roles
If I use your if statement in my controller, this is the error I get type 'exceptions.AttributeError' 'Auth' object has no attribute 'user_groups' why?? On Monday, June 2, 2014 3:13:26 PM UTC+2, Michael Beller wrote: If the user is logged in, then auth.user_groups contains a dictionary of the user's roles. You can also use auth.has_membership('role name') to check membership. You can search auth.user_groups for a role, e.g., if any (role in ['customer_service', 'admin'] for role in auth.user_groups .itervalues()): On Monday, June 2, 2014 8:53:55 AM UTC-4, Yebach wrote: Hello I am trying to get user's role looking into membership table etc. Following all the codes on majority of forums my code does not work. this is my controller from gluon.tools import Auth database = request.cookies['mycookie'].value db = DAL('postgres://postgres:postg...@195.xxx.yyy.zzz/' + database, migrate=False) auth = Auth(db) def index(): if not auth.is_logged_in(): login_adress= auth.settings.login_url = URL('user','user', args='login') redirect (login_adress) print auth.user_id ###Works print auth.user_group ### result is bound method Auth.user_group of gluon.tools.Auth object at 0x0A307F28 print auth.has_membership(auth.id_group('Member'),auth.user.id) type 'exceptions.AttributeError' 'NoneType' object has no attribute 'role' Also, If I try with some DAL select sentances none of them work. error is usually if code is rows = db(db.auth_user).select() or rows = db((db.auth_user.email == auth.user.email)(db.auth_membership.user_id == auth.user_id)( db.auth_group.id==db.auth_membership.group_id)).select(db.auth_group.ALL) error is type 'exceptions.KeyError' 'auth_user' what am I doing wrong here. It is a f#$# simple ask. Get user role so I can get a user a specific view based on that role (btw any suggestions on that would be nice). 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 handle \t \r in text area
I have a large file that starts a new line at every \r I want users to be able to copy and paste their data into the web2py textarea field. When I check the form.vars it does show the \t \r's in the text, but when I check form.vars.fieldname it strips the r's. How can I iterate through their text have the \r's be recognized as a new line. -- 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] select only one table in a joined select
Hey, I have a many-to-manyrelation, such as: *db.define_table('product_tag',Field('product', 'reference product'),Field('tag', 'reference tag'),)* Now when I would like to select the tags for a product with the id row.product.id, I came up with this, so that I don't have to do an extra query for each tag name: *dbTags = db(db.product_tag.product==row.product.id).select(join=db.tag.on(db.tag.id==db.product_tag.tag))* Now when I iterate dbTags, I don't need to reference the product_tag table, but only the tag table. I would like to iterate such as *for tag in dbTags:print tag.name # instead of current tag.tag.name* Thanks for your 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] web2py function import not working well
from applications.Folders1.modules.myfolder1.main import mainfrom applications.Folders1.modules.myfolder1.list1 import GAMES0 code.if id == name3: result = location return result else: while True: class Filters(object): def Filter_cause(self): for item in name3.split(): b = False for c in FILTERTYPE: b = b | (item.find(c) != -1) if b: for (func) in GAMES0: func() o = Filters() for stuff in dir(o): if 'Filter' in stuff: getattr(o, stuff)() result = Filters() return result GAMES0 contains several python modules being imported. My loop works well up to the return location, section but on looping over the 'def class Filters', I get this message: applications.Folders1.modules.myfolder1.main.Filters object at 0x06D689F0 How can I make it to print out my message from any of the modules -- 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: Modifying select element created from a list:reference field
Yep - that took care of it. Thanks, Anthony! On Monday, June 2, 2014 5:17:02 PM UTC-5, Anthony wrote: Your set object is actually a Query, not a Set -- should be: set = db(db.t_image.id.belongs(db(query)._select(db.t_image.id, limitby=(0 ,48 Anthony On Monday, June 2, 2014 5:27:12 PM UTC-4, Spokes wrote: Thanks! I removed that while doing some debugging, and forgot to bring it back in - it seems to have fixed the error originating in the model. Now that that's resolved, I'm a bit confused about how to use the gallery table in the controller with SQLFORM(). If I do the usual thing, as in the following line, there is an error message stating that Query' object is not callable: form = SQLFORM(db.t_gallery) On Monday, June 2, 2014 2:14:20 PM UTC-5, Anthony wrote: You forgot the second argument to IS_IN_DB: IS_IN_DB(set, 't_image.id', db.t_image._format, multiple=(1,24))) Anthony On Monday, June 2, 2014 2:50:53 PM UTC-4, Spokes wrote: I made the modification, and it's still producing the same error message. I get the impression that it has to do with *db.t_image*'s format field. Do you think that this may be the case? Any other suggestions on how to go about resolving the issue? 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: Apache-wep2py error when upgrading to Debian Wheezy
Hello The apache setup is the same for both servers. I don't have routes.py files. With the URL http://ldap/controlies/init/default/user/login?_next=/controlies/init/default/index runs ok on both servers (Squeeze and Wheezy), but with http://ldap/controlies fails on the Debian Wheezy server. Thanks. El lunes, 2 de junio de 2014 14:05:55 UTC+2, Niphlod escribió: it seems that you were loading sites before inside a specific directory (controlies) while now those are in the root. The first 303 points to */controlies/init/default/user/login?_next=/controlies/init/default/index* while the second to */init/default/user/login?_next=/init/default/index* The second seems to point to a normal setup, where all web2py applications are served under the root website. The first instead looks like a custom setup, where all applications are served under the controlies virtual directory. Did you change routes ? On Sunday, June 1, 2014 5:36:37 PM UTC+2, Alfonso Pastor Sierra wrote: More info: Apache version: 2.2.22-13+deb7u1 Web2py version: Version 1.95.1 (2011-04-25 15:04:14) Permissions: # ls -l /var/web2py total 68 drwxr-xr-x 3 www-data www-data 4096 may 29 13:10 applications -rw-r--r-- 1 www-data www-data 44 may 29 11:12 arranque.sh -rw-r--r-- 1 www-data www-data 43 may 29 12:15 cron.master drwxr-xr-x 2 www-data www-data 4096 jun 6 2011 deposit -rw-r--r-- 1 www-data www-data 9623 may 29 11:53 httpserver.log -rwxr-xr-x 1 www-data www-data0 nov 18 2013 __init__.py -rw-r--r-- 1 www-data www-data 105 may 27 11:36 __init__.pyc drwxr-xr-x 2 www-data www-data 4096 jun 6 2011 logs -rw-r--r-- 1 www-data www-data 44 may 29 11:12 parameters_8000.py drwxr-xr-x 2 www-data www-data 4096 jun 6 2011 site-packages -rwxr-xr-x 1 www-data www-data 2410 nov 18 2013 subwsgihandler.py -rwxr-xr-x 1 www-data www-data 37 nov 18 2013 VERSION -rwxr-xr-x 1 www-data www-data 448 may 28 09:22 web2py.py -rw-r--r-- 1 www-data www-data 57 may 28 09:22 welcome.w2p -rwxr-xr-x 1 www-data www-data 1007 nov 18 2013 wsgihandler.py -rw-r--r-- 1 www-data www-data 1102 may 27 11:36 wsgihandler.pyc ldap:/var# ls -l | grep web drwxr-xr-x 6 www-data www-data 4096 may 29 13:10 web2py When running standalone web2py with: python web2py.py -a mypwd -i 0.0.0.0 -p 8000 the application (http://ldap:8000) loads without error. Greetings -- 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] TABLE and aggregate fields
Hello, I've an application in production with 2.5.1-stable+timestamp.2013.06.06.15.39.19, and I would like to update at the newest web2py 2.9.5-stable+timestamp.2014.03.16.02.35.39, but I could a problem with aggregate fields. That is what's happen: If I print my Rows var I get: print rows: zone.zona,tratte.tratta,SUM(qviewriepilogoprevisioni.bilici),SUM(qviewriepilogoprevisioni.motrici),SUM(qviewriepilogoprevisioni.abbinati) ABRUZZO,ASCOLI (Ascoli Piceno),3,0,0 ABRUZZO,C. ABRUZZO (Pescara),2,0,0 ABRUZZO,S.BENEDETTO (),1,0,1 BUT if I do something like that: TABLE(rows) I got ONLY the 2 fields zone.zona,tratte.tratta With the old web2py version this wasn't happen. Where can I start to look at this problem? Thank you -- Massimiliano -- 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] Is it easy to create a grid data entry form using web2py?
This may be trying to run before I can walk but never mind! :-) Is it easy to create a grid type table editing form in web2py? I just want an easy way to edit an existing table, edit existing fields and add new rows. It's just simple data, text and numeric fields in a sqlite3 database. I want to edit the data in place, no pop-up forms or windows, just click on a field and edit the data, tab to the next field and the changed data is saved (could be delayed to when on leaves the form but I don't want to have to do any explcit 'save' action). Add a new row at the bottom by tab off the last field of the last existing row or maybe cursor down on last row or just have an empty row always at the bottom (like MS Access). The table will already exist and I want to see all the columns, no need for views or selects (though I might find uses for them in the future). This is to run on an existing system (xubuntu 14.04) running apache2 web server with various bits and pieces already running on it. I'm fairly happy with installing web apps and use Python quite a lot for small scripts but I haven't really worked with a development framework like web2py before. -- Chris Green · -- 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: user roles
confirm that you have a logged in user first On Tuesday, June 3, 2014 3:00:18 AM UTC-4, Yebach wrote: If I use your if statement in my controller, this is the error I get type 'exceptions.AttributeError' 'Auth' object has no attribute 'user_groups' why?? On Monday, June 2, 2014 3:13:26 PM UTC+2, Michael Beller wrote: If the user is logged in, then auth.user_groups contains a dictionary of the user's roles. You can also use auth.has_membership('role name') to check membership. You can search auth.user_groups for a role, e.g., if any (role in ['customer_service', 'admin'] for role in auth. user_groups.itervalues()): On Monday, June 2, 2014 8:53:55 AM UTC-4, Yebach wrote: Hello I am trying to get user's role looking into membership table etc. Following all the codes on majority of forums my code does not work. this is my controller from gluon.tools import Auth database = request.cookies['mycookie'].value db = DAL('postgres://postgres:postg...@195.xxx.yyy.zzz/' + database, migrate=False) auth = Auth(db) def index(): if not auth.is_logged_in(): login_adress= auth.settings.login_url = URL('user','user', args='login') redirect (login_adress) print auth.user_id ###Works print auth.user_group ### result is bound method Auth.user_group of gluon.tools.Auth object at 0x0A307F28 print auth.has_membership(auth.id_group('Member'),auth.user.id) type 'exceptions.AttributeError' 'NoneType' object has no attribute 'role' Also, If I try with some DAL select sentances none of them work. error is usually if code is rows = db(db.auth_user).select() or rows = db((db.auth_user.email == auth.user.email)(db.auth_membership.user_id == auth.user_id)( db.auth_group.id ==db.auth_membership.group_id)).select(db.auth_group.ALL) error is type 'exceptions.KeyError' 'auth_user' what am I doing wrong here. It is a f#$# simple ask. Get user role so I can get a user a specific view based on that role (btw any suggestions on that would be nice). 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: Problems with multiple forms and SQLFORM.grid
Can anybody help me? I still can't figure it out on my own... W dniu niedziela, 1 czerwca 2014 16:10:07 UTC+2 użytkownik john smith napisał: I want to create a page that will display user data, with additional controls. I want librarian to be able to add user to 'readers' and remove group, that part works. I also want admin be able to freely manage groups of a user, I want him to have a widget that will have a list of groups with submit button that will add user to selected group, and list of all groups user is a member of with ability to remove him from those. I have 3 problems with that: 1. I don't know how to create form that will display drop-down list with groups, like SQLFORM does. I could replace it with SQLFORM but then I need to know how to hide user_id field and set it to user.id value 2. Even when click submit button of form2, action of form is executed. 3. SQLFORM.grid won't let me access the view, i get flash with 'not authorized' message. Here is my code: @auth.requires(auth.has_membership('librarian') or auth.has_membership('admin')) def show_reader(): if request.args(0) and db.auth_user(request.args(0, cast=int)): user = db.auth_user(request.args(0, cast=int)) form2='' if (auth.has_membership('admin', user.id) or auth.has_membership('librarian', user.id)) and not auth.has_membership('admin'): session.flash = T('Insufficient privileges') redirect(URL('readers')) else: if not auth.has_membership('reader', user.id): form=FORM(INPUT(_type='submit', _value=T('Activate user'))) if form.process().accepted: session.flash = T('User has been activated') db.auth_membership.update_or_insert(user_id=user.id ,group_id=auth.id_group('reader')) redirect(URL('show_reader', args=user.id), client_side=True) else: form=FORM(INPUT(_type='submit', _value=T('Deactivate user'))) if form.process().accepted: session.flash = T('User has been deactivated') #user.registration_key='blocked' #user.update_record(registration_key='blocked') db(db.auth_membership.user_id==user.id).delete() redirect(URL('show_reader', args=user.id), client_side=True) if auth.has_membership('admin'): #form2='' form2=FORM('Your name:', INPUT(_name='grupa', _type='text'), INPUT(_type='submit')) if form2.process().accepted: redirect(URL('index')) form3=SQLFORM.grid(db.auth_membership.user_id==user.id, deletable=False, editable=False, create=False, details=False) return locals() else: session.flash = T('No such user') redirect(URL('readers')) -- 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 change SQLFORM smartgrid title
Noob question -- I searched around and couldn't find an answer on how to change the SQLFORM.smartgrid label which displays the name of the database. I know you can set fields in a table by typing label='newName', but how can I change the table name itself so it doesn't display the table name in smartgrid (and its also plural) -- 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: Problems with multiple forms and SQLFORM.grid
1) Use SQLFORM factory. 2) Name your forms example below. (changes in red do this to them all with different names of course) 3) Not sure whats going on can you explain a bit more? form2=FORM('Your name:', INPUT(_name='grupa', _type='text'), INPUT(_type='submit')) if form2.process(formname='SomeName').accepted: redirect(URL('index')) On Sunday, June 1, 2014 9:10:07 AM UTC-5, john smith wrote: I want to create a page that will display user data, with additional controls. I want librarian to be able to add user to 'readers' and remove group, that part works. I also want admin be able to freely manage groups of a user, I want him to have a widget that will have a list of groups with submit button that will add user to selected group, and list of all groups user is a member of with ability to remove him from those. I have 3 problems with that: 1. I don't know how to create form that will display drop-down list with groups, like SQLFORM does. I could replace it with SQLFORM but then I need to know how to hide user_id field and set it to user.id value 2. Even when click submit button of form2, action of form is executed. 3. SQLFORM.grid won't let me access the view, i get flash with 'not authorized' message. Here is my code: @auth.requires(auth.has_membership('librarian') or auth.has_membership('admin')) def show_reader(): if request.args(0) and db.auth_user(request.args(0, cast=int)): user = db.auth_user(request.args(0, cast=int)) form2='' if (auth.has_membership('admin', user.id) or auth.has_membership('librarian', user.id)) and not auth.has_membership('admin'): session.flash = T('Insufficient privileges') redirect(URL('readers')) else: if not auth.has_membership('reader', user.id): form=FORM(INPUT(_type='submit', _value=T('Activate user'))) if form.process().accepted: session.flash = T('User has been activated') db.auth_membership.update_or_insert(user_id=user.id ,group_id=auth.id_group('reader')) redirect(URL('show_reader', args=user.id), client_side=True) else: form=FORM(INPUT(_type='submit', _value=T('Deactivate user'))) if form.process().accepted: session.flash = T('User has been deactivated') #user.registration_key='blocked' #user.update_record(registration_key='blocked') db(db.auth_membership.user_id==user.id).delete() redirect(URL('show_reader', args=user.id), client_side=True) if auth.has_membership('admin'): #form2='' form2=FORM('Your name:', INPUT(_name='grupa', _type='text'), INPUT(_type='submit')) if form2.process().accepted: redirect(URL('index')) form3=SQLFORM.grid(db.auth_membership.user_id==user.id, deletable=False, editable=False, create=False, details=False) return locals() else: session.flash = T('No such user') redirect(URL('readers')) -- 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: Is it easy to create a grid data entry form using web2py?
Like this? http://www.web2pyslices.com/slice/show/1928/basic-inline-editing-in-sqlformgrid-no-plugin-no-javascript On Tuesday, June 3, 2014 7:25:19 AM UTC-5, c...@isbd.net wrote: This may be trying to run before I can walk but never mind! :-) Is it easy to create a grid type table editing form in web2py? I just want an easy way to edit an existing table, edit existing fields and add new rows. It's just simple data, text and numeric fields in a sqlite3 database. I want to edit the data in place, no pop-up forms or windows, just click on a field and edit the data, tab to the next field and the changed data is saved (could be delayed to when on leaves the form but I don't want to have to do any explcit 'save' action). Add a new row at the bottom by tab off the last field of the last existing row or maybe cursor down on last row or just have an empty row always at the bottom (like MS Access). The table will already exist and I want to see all the columns, no need for views or selects (though I might find uses for them in the future). This is to run on an existing system (xubuntu 14.04) running apache2 web server with various bits and pieces already running on it. I'm fairly happy with installing web apps and use Python quite a lot for small scripts but I haven't really worked with a development framework like web2py before. -- Chris Green · -- 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: select only one table in a joined select
The join is making that happen. Why not just do *dbTags = db(db.product_tag.product==row.product.id http://row.product.id/).select(db.product_tag.tag)* *Whats the point in the join on a m2m table?* On Tuesday, June 3, 2014 3:54:52 AM UTC-5, Robin Manoli wrote: Hey, I have a many-to-manyrelation, such as: *db.define_table('product_tag',Field('product', 'reference product'),Field('tag', 'reference tag'),)* Now when I would like to select the tags for a product with the id row.product.id, I came up with this, so that I don't have to do an extra query for each tag name: *dbTags = db(db.product_tag.product==row.product.id http://row.product.id).select(join=db.tag.on(db.tag.id http://db.tag.id==db.product_tag.tag))* Now when I iterate dbTags, I don't need to reference the product_tag table, but only the tag table. I would like to iterate such as *for tag in dbTags:print tag.name http://tag.name # instead of current tag.tag.name http://tag.tag.name* Thanks for your 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.
Re: [web2py] Re: web2py CMS
+1 pynuke while in beta is very good already and actively developed. 2014-06-02 4:51 GMT+02:00 Carlos A. Armenta Castro carlos.armen...@gmail.com: Hi Andrey, I recommend you a new CMS named pynukedev: https://bitbucket.org/pynukedev According to RochacBruno the creator of Movuca - If you want a stable CMS for web2py take a look at PyNUke http://www.pynuke.net/ Regards El viernes, 30 de mayo de 2014 07:21:04 UTC-7, Andrey K escribió: I am interested to add in CMS system for our web2py application. Quick search does not give me any solutions. Is there any CMS plugin already or any recipes on it? Any thoughts, suggestions, links and comments would be very appreciated. Thank you in advance! -- 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.
[web2py] show_if belongs condition.second is set()
The following show_if condition gives me an Not Implemented Error: auth_table_user.position.show_if = auth_table_user.employee_type.belongs(('employee', 'external')) I fixed it for me, with the following change in sqlhtml.py if cond.op.__name__ == 'BELONGS' and isinstance(cond.second,(list,tuple)): to if cond.op.__name__ == 'BELONGS' and isinstance(cond.second,(set,list,tuple)): Is this a bug, or is there a different notation for belongs? I tried belongs('employee', 'external') belongs(('employee', 'external')) belongs(['employee', 'external']) cond.second is always a Set. -- 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: Is it easy to create a grid data entry form using web2py?
LaDarrius Stewart ladarrius.stew...@gadgroup.com wrote: [-- text/plain, encoding quoted-printable, charset: UTF-8, 52 lines --] Like this? http://www.web2pyslices.com/slice/show/1928/basic-inline-editing-in-sqlformgrid-no-plugin-no-javascript Yes, that's pretty much what I'm after. Just a couple of questions:- By The basic idea is to use represent to show a field in the grid as an INPUT tag does it mean that what this does is enable editing fields 'in place' which isn't what the basic SQLFORM.grid offers? It also says to add a submit button to SQLFORM.grid, but there isn't a submit button. Does the bit about boolean checkboxes just mean that these are rather more difficult to implement? (I don't need them). Presumably the plugin_SQLFORM_INLINE plugin is an alternative way to do the same thing - using a plugin and some javascript. Thanks! It looks as if I will try diving into web2py. :-) On Tuesday, June 3, 2014 7:25:19 AM UTC-5, c...@isbd.net wrote: This may be trying to run before I can walk but never mind! :-) Is it easy to create a grid type table editing form in web2py? I just want an easy way to edit an existing table, edit existing fields and add new rows. It's just simple data, text and numeric fields in a sqlite3 database. I want to edit the data in place, no pop-up forms or windows, just click on a field and edit the data, tab to the next field and the changed data is saved (could be delayed to when on leaves the form but I don't want to have to do any explcit 'save' action). Add a new row at the bottom by tab off the last field of the last existing row or maybe cursor down on last row or just have an empty row always at the bottom (like MS Access). The table will already exist and I want to see all the columns, no need for views or selects (though I might find uses for them in the future). This is to run on an existing system (xubuntu 14.04) running apache2 web server with various bits and pieces already running on it. I'm fairly happy with installing web apps and use Python quite a lot for small scripts but I haven't really worked with a development framework like web2py before. -- Chris Green · -- 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. -- Chris Green · -- 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: Problems with multiple forms and SQLFORM.grid
Thanks, naming forms works as expected. Regarding grid, when I try to access show_readers function as admin, I get redirected to readers function with flash message saying: 'not authorized'. Librarian can access it, but not if I move the grid code outside of if statement, then librarian gets same message. I don't need to use grid, I just want there to be a list of groups user is currently a member of, and a button next to all these groups that would remove the user from group. I will probably try to do it using for loop and html table. I'm not sure how am I supposed to resolve my dropdown issue with SQLFORM factory, but I'll try to read some more on that. General idea I had for that would be a form with one field only and a submit button. The field would be a dropdown list with a list of all groups in auth_groups. Then admin could add users to group by just selecting group and clicking submit. Basically I want to have same thing that you get in appadmin for adding new record to auth_membership, just without the User_id field (it would by default take value from request.args). This dropdown list combined with list of groups with some kind of 'remove from group' buttons, should provide an easy way for admins to manage user groups. I hope that explanation was clear, English is not my first language. Thank you for your help. W dniu wtorek, 3 czerwca 2014 16:21:21 UTC+2 użytkownik LaDarrius Stewart napisał: 1) Use SQLFORM factory. 2) Name your forms example below. (changes in red do this to them all with different names of course) 3) Not sure whats going on can you explain a bit more? form2=FORM('Your name:', INPUT(_name='grupa', _type='text'), INPUT(_type='submit')) if form2.process(formname='SomeName').accepted: redirect(URL('index')) On Sunday, June 1, 2014 9:10:07 AM UTC-5, john smith wrote: I want to create a page that will display user data, with additional controls. I want librarian to be able to add user to 'readers' and remove group, that part works. I also want admin be able to freely manage groups of a user, I want him to have a widget that will have a list of groups with submit button that will add user to selected group, and list of all groups user is a member of with ability to remove him from those. I have 3 problems with that: 1. I don't know how to create form that will display drop-down list with groups, like SQLFORM does. I could replace it with SQLFORM but then I need to know how to hide user_id field and set it to user.id value 2. Even when click submit button of form2, action of form is executed. 3. SQLFORM.grid won't let me access the view, i get flash with 'not authorized' message. Here is my code: @auth.requires(auth.has_membership('librarian') or auth.has_membership('admin')) def show_reader(): if request.args(0) and db.auth_user(request.args(0, cast=int)): user = db.auth_user(request.args(0, cast=int)) form2='' if (auth.has_membership('admin', user.id) or auth.has_membership('librarian', user.id)) and not auth.has_membership('admin'): session.flash = T('Insufficient privileges') redirect(URL('readers')) else: if not auth.has_membership('reader', user.id): form=FORM(INPUT(_type='submit', _value=T('Activate user'))) if form.process().accepted: session.flash = T('User has been activated') db.auth_membership.update_or_insert(user_id=user.id ,group_id=auth.id_group('reader')) redirect(URL('show_reader', args=user.id), client_side=True) else: form=FORM(INPUT(_type='submit', _value=T('Deactivate user'))) if form.process().accepted: session.flash = T('User has been deactivated') #user.registration_key='blocked' #user.update_record(registration_key='blocked') db(db.auth_membership.user_id==user.id).delete() redirect(URL('show_reader', args=user.id), client_side=True) if auth.has_membership('admin'): #form2='' form2=FORM('Your name:', INPUT(_name='grupa', _type='text'), INPUT(_type='submit')) if form2.process().accepted: redirect(URL('index')) form3=SQLFORM.grid(db.auth_membership.user_id==user.id, deletable=False, editable=False, create=False, details=False) return locals() else: session.flash = T('No such user') redirect(URL('readers')) -- 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 organize the model for a chat application?
If you don't want to create group authentication, and playing with a single registration view different types of users. I wonder if you could have the users log into to a completely different app, if all it was for was for the chat. It is possible to share databases between web2py applications AFAIK, and if all chat traffic went through the common database, you might be good to go. (or you could have some kind of chat traffic daemon in your system at a dedicated socket port that they pass chat messages through) Or do the users and employees use other functions in the app as well? -- 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: Problems with multiple forms and SQLFORM.grid
the easiest (and eastethically pleasing) method is to use components: controllers/default.py def index(): form1 = LOAD('default', 'form1.load', ajax=True) form2 = LOAD('default', 'form2.load', ajax=True) form3 = LOAD('default', 'form3.load', ajax=True) def form1(): grid = SQLFORM.grid(db.table1, formname='form1') return dict(grid=grid) def form2(): grid = SQLFORM.grid(db.table2, formname='form2') return dict(grid=grid) def form3(): grid = SQLFORM.grid(db.table3, formname='form3') return dict(grid=grid) On Tuesday, June 3, 2014 5:06:55 PM UTC+2, john smith wrote: Thanks, naming forms works as expected. Regarding grid, when I try to access show_readers function as admin, I get redirected to readers function with flash message saying: 'not authorized'. Librarian can access it, but not if I move the grid code outside of if statement, then librarian gets same message. I don't need to use grid, I just want there to be a list of groups user is currently a member of, and a button next to all these groups that would remove the user from group. I will probably try to do it using for loop and html table. I'm not sure how am I supposed to resolve my dropdown issue with SQLFORM factory, but I'll try to read some more on that. General idea I had for that would be a form with one field only and a submit button. The field would be a dropdown list with a list of all groups in auth_groups. Then admin could add users to group by just selecting group and clicking submit. Basically I want to have same thing that you get in appadmin for adding new record to auth_membership, just without the User_id field (it would by default take value from request.args). This dropdown list combined with list of groups with some kind of 'remove from group' buttons, should provide an easy way for admins to manage user groups. I hope that explanation was clear, English is not my first language. Thank you for your help. W dniu wtorek, 3 czerwca 2014 16:21:21 UTC+2 użytkownik LaDarrius Stewart napisał: 1) Use SQLFORM factory. 2) Name your forms example below. (changes in red do this to them all with different names of course) 3) Not sure whats going on can you explain a bit more? form2=FORM('Your name:', INPUT(_name='grupa', _type='text'), INPUT(_type='submit')) if form2.process(formname='SomeName').accepted: redirect(URL('index')) On Sunday, June 1, 2014 9:10:07 AM UTC-5, john smith wrote: I want to create a page that will display user data, with additional controls. I want librarian to be able to add user to 'readers' and remove group, that part works. I also want admin be able to freely manage groups of a user, I want him to have a widget that will have a list of groups with submit button that will add user to selected group, and list of all groups user is a member of with ability to remove him from those. I have 3 problems with that: 1. I don't know how to create form that will display drop-down list with groups, like SQLFORM does. I could replace it with SQLFORM but then I need to know how to hide user_id field and set it to user.id value 2. Even when click submit button of form2, action of form is executed. 3. SQLFORM.grid won't let me access the view, i get flash with 'not authorized' message. Here is my code: @auth.requires(auth.has_membership('librarian') or auth.has_membership('admin')) def show_reader(): if request.args(0) and db.auth_user(request.args(0, cast=int)): user = db.auth_user(request.args(0, cast=int)) form2='' if (auth.has_membership('admin', user.id) or auth.has_membership('librarian', user.id)) and not auth.has_membership('admin'): session.flash = T('Insufficient privileges') redirect(URL('readers')) else: if not auth.has_membership('reader', user.id): form=FORM(INPUT(_type='submit', _value=T('Activate user'))) if form.process().accepted: session.flash = T('User has been activated') db.auth_membership.update_or_insert(user_id=user.id ,group_id=auth.id_group('reader')) redirect(URL('show_reader', args=user.id), client_side=True) else: form=FORM(INPUT(_type='submit', _value=T('Deactivate user'))) if form.process().accepted: session.flash = T('User has been deactivated') #user.registration_key='blocked' #user.update_record(registration_key='blocked') db(db.auth_membership.user_id==user.id).delete() redirect(URL('show_reader', args=user.id), client_side=True) if auth.has_membership('admin'): #form2='' form2=FORM('Your name:', INPUT(_name='grupa', _type='text'), INPUT(_type='submit')) if form2.process().accepted: redirect(URL('index')) form3=SQLFORM.grid(db.auth_membership.user_id==user.id, deletable=False, editable=False, create=False, details=False) return locals() else: session.flash = T('No such user') redirect(URL('readers')) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source
[web2py] Re: TABLE and aggregate fields
it's not a problem. we just changed the way a Rows class gets represented (printing resultsets with 1k rows was kynda lame ^_^) if you do print rows things change, but for row in rows: print row doesn't change a bit. On Tuesday, June 3, 2014 12:53:08 PM UTC+2, Massimiliano wrote: Hello, I've an application in production with 2.5.1-stable+timestamp.2013.06.06.15.39.19, and I would like to update at the newest web2py 2.9.5-stable+timestamp.2014.03.16.02.35.39, but I could a problem with aggregate fields. That is what's happen: If I print my Rows var I get: print rows: zone.zona,tratte.tratta,SUM(qviewriepilogoprevisioni.bilici),SUM(qviewriepilogoprevisioni.motrici),SUM(qviewriepilogoprevisioni.abbinati) ABRUZZO,ASCOLI (Ascoli Piceno),3,0,0 ABRUZZO,C. ABRUZZO (Pescara),2,0,0 ABRUZZO,S.BENEDETTO (),1,0,1 BUT if I do something like that: TABLE(rows) I got ONLY the 2 fields zone.zona,tratte.tratta With the old web2py version this wasn't happen. Where can I start to look at this problem? Thank you -- Massimiliano -- 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: Email attachment size limit
there are not hardcoded limits. those are usually smtp dependant (you'd get an error with mail.send()) or dependant on receivers capacity (in which case you'd receive a bounced email) On Monday, June 2, 2014 9:21:10 PM UTC+2, Guilherme Rosa wrote: What is the email attachment size limit for any one file and as a whole? 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: Problems with multiple forms and SQLFORM.grid
As far as I could replace it with SQLFORM but then I need to know how to hide user_id field and set it to user.id value What do you mean are you just trying to hide the id value? like this - db.table.id.readable=False ? On Sunday, June 1, 2014 9:10:07 AM UTC-5, john smith wrote: I want to create a page that will display user data, with additional controls. I want librarian to be able to add user to 'readers' and remove group, that part works. I also want admin be able to freely manage groups of a user, I want him to have a widget that will have a list of groups with submit button that will add user to selected group, and list of all groups user is a member of with ability to remove him from those. I have 3 problems with that: 1. I don't know how to create form that will display drop-down list with groups, like SQLFORM does. I could replace it with SQLFORM but then I need to know how to hide user_id field and set it to user.id value 2. Even when click submit button of form2, action of form is executed. 3. SQLFORM.grid won't let me access the view, i get flash with 'not authorized' message. Here is my code: @auth.requires(auth.has_membership('librarian') or auth.has_membership('admin')) def show_reader(): if request.args(0) and db.auth_user(request.args(0, cast=int)): user = db.auth_user(request.args(0, cast=int)) form2='' if (auth.has_membership('admin', user.id) or auth.has_membership('librarian', user.id)) and not auth.has_membership('admin'): session.flash = T('Insufficient privileges') redirect(URL('readers')) else: if not auth.has_membership('reader', user.id): form=FORM(INPUT(_type='submit', _value=T('Activate user'))) if form.process().accepted: session.flash = T('User has been activated') db.auth_membership.update_or_insert(user_id=user.id ,group_id=auth.id_group('reader')) redirect(URL('show_reader', args=user.id), client_side=True) else: form=FORM(INPUT(_type='submit', _value=T('Deactivate user'))) if form.process().accepted: session.flash = T('User has been deactivated') #user.registration_key='blocked' #user.update_record(registration_key='blocked') db(db.auth_membership.user_id==user.id).delete() redirect(URL('show_reader', args=user.id), client_side=True) if auth.has_membership('admin'): #form2='' form2=FORM('Your name:', INPUT(_name='grupa', _type='text'), INPUT(_type='submit')) if form2.process().accepted: redirect(URL('index')) form3=SQLFORM.grid(db.auth_membership.user_id==user.id, deletable=False, editable=False, create=False, details=False) return locals() else: session.flash = T('No such user') redirect(URL('readers')) -- 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: user roles
I just tested and reread your original post. auth.user_groups is a dict containing the id and role for each auth_group for the logged in user auth.user_group is a method of auth from the book: auth.user_groups contains a dictionary where each key is the id of a group of with the current logged in user is member of, the value is the corresponding group role. auth.user_group(user_id) returns the id of the group uniquely associated to the user identified by user_id. This should work for both logged-in and logged-out users: if any (role in ['customer_service', 'admin'] for role in auth.user_groups. itervalues()): On Tuesday, June 3, 2014 9:02:19 AM UTC-4, Michael Beller wrote: confirm that you have a logged in user first On Tuesday, June 3, 2014 3:00:18 AM UTC-4, Yebach wrote: If I use your if statement in my controller, this is the error I get type 'exceptions.AttributeError' 'Auth' object has no attribute 'user_groups' why?? On Monday, June 2, 2014 3:13:26 PM UTC+2, Michael Beller wrote: If the user is logged in, then auth.user_groups contains a dictionary of the user's roles. You can also use auth.has_membership('role name') to check membership. You can search auth.user_groups for a role, e.g., if any (role in ['customer_service', 'admin'] for role in auth. user_groups.itervalues()): On Monday, June 2, 2014 8:53:55 AM UTC-4, Yebach wrote: Hello I am trying to get user's role looking into membership table etc. Following all the codes on majority of forums my code does not work. this is my controller from gluon.tools import Auth database = request.cookies['mycookie'].value db = DAL('postgres://postgres:postg...@195.xxx.yyy.zzz/' + database, migrate=False) auth = Auth(db) def index(): if not auth.is_logged_in(): login_adress= auth.settings.login_url = URL('user','user', args='login') redirect (login_adress) print auth.user_id ###Works print auth.user_group ### result is bound method Auth.user_group of gluon.tools.Auth object at 0x0A307F28 print auth.has_membership(auth.id_group('Member'),auth.user.id) type 'exceptions.AttributeError' 'NoneType' object has no attribute 'role' Also, If I try with some DAL select sentances none of them work. error is usually if code is rows = db(db.auth_user).select() or rows = db((db.auth_user.email == auth.user.email)(db.auth_membership.user_id == auth.user_id)( db.auth_group.id ==db.auth_membership.group_id)).select(db.auth_group.ALL) error is type 'exceptions.KeyError' 'auth_user' what am I doing wrong here. It is a f#$# simple ask. Get user role so I can get a user a specific view based on that role (btw any suggestions on that would be nice). 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: How to handle \t \r in text area
I figured out when I type form.vars.fieldname.file it maintains the \r \n, but I haven't tested it on the text area yet. Going to give that a try and hope for the best. Thanks guys On Tuesday, June 3, 2014 4:44:23 AM UTC-4, LoveWeb2py wrote: I have a large file that starts a new line at every \r I want users to be able to copy and paste their data into the web2py textarea field. When I check the form.vars it does show the \t \r's in the text, but when I check form.vars.fieldname it strips the r's. How can I iterate through their text have the \r's be recognized as a new line. -- 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: Problems with multiple forms and SQLFORM.grid
Yes, it works if I add writable=False, but I still have to set user_id to user.id and I don't know how to do that. In regards to components, I'm not sure how does it solve my problem. Could you please elaborate? I will look into this to improve my project but I have deadline on Monday and need to work on other stuff. Oh, and by the way, do you have any idea on how to select a user who does not have a record in auth_membership? This is my current code and it worked, but I want to change the query because I changed my model a little bit. @auth.requires(auth.has_membership('librarian') or auth.has_membership('admin')) def readers_pending(): grid = SQLFORM.grid(db.auth_user.registration_key=='blocked', deletable=False, editable=False, create=False, details=False, paginate=25, links=[dict(header='Link',body=lambda row: A(T('Show'), _href=URL('show_reader',args=row.id)))]) return locals() W dniu wtorek, 3 czerwca 2014 17:30:11 UTC+2 użytkownik LaDarrius Stewart napisał: As far as I could replace it with SQLFORM but then I need to know how to hide user_id field and set it to user.id value What do you mean are you just trying to hide the id value? like this - db.table.id.readable=False ? On Sunday, June 1, 2014 9:10:07 AM UTC-5, john smith wrote: I want to create a page that will display user data, with additional controls. I want librarian to be able to add user to 'readers' and remove group, that part works. I also want admin be able to freely manage groups of a user, I want him to have a widget that will have a list of groups with submit button that will add user to selected group, and list of all groups user is a member of with ability to remove him from those. I have 3 problems with that: 1. I don't know how to create form that will display drop-down list with groups, like SQLFORM does. I could replace it with SQLFORM but then I need to know how to hide user_id field and set it to user.id value 2. Even when click submit button of form2, action of form is executed. 3. SQLFORM.grid won't let me access the view, i get flash with 'not authorized' message. Here is my code: @auth.requires(auth.has_membership('librarian') or auth.has_membership('admin')) def show_reader(): if request.args(0) and db.auth_user(request.args(0, cast=int)): user = db.auth_user(request.args(0, cast=int)) form2='' if (auth.has_membership('admin', user.id) or auth.has_membership('librarian', user.id)) and not auth.has_membership('admin'): session.flash = T('Insufficient privileges') redirect(URL('readers')) else: if not auth.has_membership('reader', user.id): form=FORM(INPUT(_type='submit', _value=T('Activate user'))) if form.process().accepted: session.flash = T('User has been activated') db.auth_membership.update_or_insert(user_id=user.id ,group_id=auth.id_group('reader')) redirect(URL('show_reader', args=user.id), client_side=True) else: form=FORM(INPUT(_type='submit', _value=T('Deactivate user'))) if form.process().accepted: session.flash = T('User has been deactivated') #user.registration_key='blocked' #user.update_record(registration_key='blocked') db(db.auth_membership.user_id==user.id).delete() redirect(URL('show_reader', args=user.id), client_side=True) if auth.has_membership('admin'): #form2='' form2=FORM('Your name:', INPUT(_name='grupa', _type='text'), INPUT(_type='submit')) if form2.process().accepted: redirect(URL('index')) form3=SQLFORM.grid(db.auth_membership.user_id==user.id, deletable=False, editable=False, create=False, details=False) return locals() else: session.flash = T('No such user') redirect(URL('readers')) -- 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 change SQLFORM smartgrid title
I believe smartgrid uses the table _plural attribute for the first item in the smarrgrid breadcrumb. If _plural is not set, it uses the table name and a pluralization function to create the name. You can set the attributes in the define table method, e.g., singular=Dog, plural=Dogs You can also set directly right before you create the smartgrid with: db.dog._plural = 'dogs' Many, maybe all, of the attributes are exposed using a leading underscore so they won't conflict with field names. On Tuesday, June 3, 2014 9:52:38 AM UTC-4, LoveWeb2py wrote: Noob question -- I searched around and couldn't find an answer on how to change the SQLFORM.smartgrid label which displays the name of the database. I know you can set fields in a table by typing label='newName', but how can I change the table name itself so it doesn't display the table name in smartgrid (and its also plural) -- 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] crud.create form does not show errors in iframe
I have simple crud.update form which works as expected but when I embed the same form in iframe on another site id does not show the form input errors at all. It does not accept form if errors exists and that is OK but I don't know how to force it to show the errors to my users? Is it normal behavior or I'm doing something wrong? -- 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 migrate to UUID references in db without messing up reference fields
Thanks very much Massimo and Philip. I had missed the fact that the id_map parameter triggered smart updating of the reference fields. That's great and for the moment is solves my problem. I'll keep thinking about a longer-term solution for syncing. Here's what I'm thinking would be desirable: 1. 2-way intelligent sync (look at whatever update-time info is available in the table), maybe using websockets 2. automated backup of the original data for rollback if necessary 3. can be performed on one table 4. reference field ids are updated on both ends as necessary 5. no extra fields need be added to db model 6. can easily be scheduled or triggered by user activity on one end In the long run this is something I'll need, so if I make any progress I'll let you know. Ian On Monday, May 26, 2014 11:49:20 AM UTC-4, Massimo Di Pierro wrote: I now understand your problem better. Have you looked into? db.export_to_csv_file(file) db.import_from_csv_file(file,id_map={}) https://groups.google.com/forum/#!msg/web2py/P_lBv8JKiiQ/LESBbSGikw8J When importing from the file the id_map will recognize records from the uuid (assuming they have it) and fix the references accordingly. So the references in the imported records will be different but will point to the right record. This may fail if there are circular references because it would be unable to built the references. Moreover it requires comparing the entire db and cannot be used on one single table. I agree a better solution would be desirable. Massimo On Saturday, 24 May 2014 10:58:39 UTC-5, Ian W. Scott wrote: Thanks Massimo. I explained my problem a bit better (I hope) in my reply to Philip below. There are a couple of reasons why the approach you suggest isn't ideal, from my point of view: 1. I'm working with existing database instances (sqlite). So if I change all of the reference fields to use uuid connections as you suggest, I will have to perform a large-scale migration with a custom script. I'm nervous about the potential for error here. 2. This approach would prevent my use of some great web2py dal features (reference fields, list-reference fields, recursive selects, cascading deletes, etc.) I'd really rather not have to sacrifice so much web2py functionality just to synchronize two db instances. I wonder whether this doesn't point to a potential area for improvement in web2py. It seems like a framework like this would benefit from having an easier, built-in solution for synchronizing db instances without breaking dal features. So if you can think of a way to facilitate synchronization that's more elegant, I'd be happy to contribute back any code I write to implement it. Thanks again, Ian On Saturday, May 24, 2014 3:08:58 AM UTC-4, Massimo Di Pierro wrote: Hello Ian, Sorry we overlooked your email. You can easily add a UUID field from gluon.util import web2py_uuid db.define_table('person',Field('name'),Field('uuid',compute=lambda:web2py_uuid())) You can also create table that reference that field: db.define_table('thing',Field('name'),Field('owner',requires=IS_IN_DB(db,'person.uuid','name')) Except the reference will not be enforced at the DB level, only at the web2py level. Massimo On Friday, 23 May 2014 23:04:10 UTC-5, Ian W. Scott wrote: After 10 days I've received no help on this. Is there something about the question that is inappropriate? Is my question unclear? On Wednesday, May 14, 2014 11:44:43 AM UTC-4, Ian W. Scott wrote: I need to take an existing db and implement a UUID referencing system so that I can sync local db's with a central remote version. But I'm concerned that this will break reference fields that refer to the newly synced rows. My understanding is that the UUID field is necessary because a csv import will assign different row ids to the new entries in the target db than the ones they had in the source db (especially if new records have been added to the target db in the meantime). The UUID is supposed to overcome this, by allowing the db to recognize that rows are equivalent even if they have different ids. But in that case, won't reference fields in other tables often be pointing to the wrong ID number in the target db? (i.e., they'll keep the row ID of the db version in which they were created, and if this ID changes in the target db they will then be referencing a different record.) Sorry if this explanation is overly complicated. I'm just trying to get things clear in my own mind. Thanks -- 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
[web2py] plugin_dataTables
I'd like to share this plugin I prepared... maybe I'll produce a web2py slice recipe about how to use it but for the moment if you are interested in it you can browse the demo application or look the code of the plugin_examples files. I hope to collect contributions and comments :) https://github.com/manuelep/web2py.app_plugin_dataTables 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.
[web2py] Re: select only one table in a joined select
Hi Robin Assuming your product_tag table contains product Ids and tag Ids and you want a list of tags for a given product id This should work : tags = db((db.product_tag.product==row.product.id)(db.product_tag==db.tag.id)).select(db.tag.name).as_list() Regards, Annet -- 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 change SQLFORM smartgrid title
Thanks, Michael! On Tuesday, June 3, 2014 12:21:39 PM UTC-4, Michael Beller wrote: I believe smartgrid uses the table _plural attribute for the first item in the smarrgrid breadcrumb. If _plural is not set, it uses the table name and a pluralization function to create the name. You can set the attributes in the define table method, e.g., singular=Dog, plural=Dogs You can also set directly right before you create the smartgrid with: db.dog._plural = 'dogs' Many, maybe all, of the attributes are exposed using a leading underscore so they won't conflict with field names. On Tuesday, June 3, 2014 9:52:38 AM UTC-4, LoveWeb2py wrote: Noob question -- I searched around and couldn't find an answer on how to change the SQLFORM.smartgrid label which displays the name of the database. I know you can set fields in a table by typing label='newName', but how can I change the table name itself so it doesn't display the table name in smartgrid (and its also plural) -- 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: how to determine the server (name) ?
On Saturday, May 31, 2014 12:31:57 PM UTC-7, aapaap wrote: thanks Leonel and Michael. forgot to tell there are 2 programs running at least on one of those servers, a web2py application and another application polling a solar system. So I don't always have the request variable. Not sure I understand. When does having the other application cause you not to have the request variable? (Not to worry; it's still easy to get me to not understand.) /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] Re: web2py CMS
I would recommend Plone (http://plone.org/). It's a very good Python CMS with a 13 year history. There's also Tactic (http://community.southpawtech.com/get-started) which is good, if you handle digital assets like video files. On Friday, May 30, 2014 7:21:04 AM UTC-7, Andrey K wrote: I am interested to add in CMS system for our web2py application. Quick search does not give me any solutions. Is there any CMS plugin already or any recipes on it? Any thoughts, suggestions, links and comments would be very appreciated. Thank you in advance! -- 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: web2py function import not working well
Sorry, but it looks like it's doing what you are asking of it. Perhaps you should comment your code to make sure it's doing what you are thinking it's doing. you are instantiating a new filters class, giving it the name 'o', then you get a list of the contents of that class, run them if possible, and then you are instantiating a new filters class, naming it 'result', kinda like 'o' was and then you are returning it. Why? What's the point of doing all that if 'o' is never going to be used? you might as well take that out since you are just returning a new class instance anyway. On Tuesday, June 3, 2014 2:50:48 AM UTC-7, Maurice Waka wrote: from applications.Folders1.modules.myfolder1.main import mainfrom applications.Folders1.modules.myfolder1.list1 import GAMES0 code.if id == name3: result = location return result else: while True: class Filters(object): def Filter_cause(self): for item in name3.split(): b = False for c in FILTERTYPE: b = b | (item.find(c) != -1) if b: for (func) in GAMES0: func() o = Filters() for stuff in dir(o): if 'Filter' in stuff: getattr(o, stuff)() result = Filters() return result GAMES0 contains several python modules being imported. My loop works well up to the return location, section but on looping over the 'def class Filters', I get this message: applications.Folders1.modules.myfolder1.main.Filters object at 0x06D689F0 How can I make it to print out my message from any of the modules -- 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 add button on SQLFORM.grid?
Hi, How to add button/field on SQLFORM.grid? I need create link to edit slave table with row id. Thanks, Fabiano -- 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 function import not working well
When I work with the same module on python shell, its perfectly printing out. I dont know why it does not print on web2py. Basically I imported it without editing from python shell. Anyway since am new to web2py and python, you could help out On Tuesday, June 3, 2014, Derek sp1d...@gmail.com wrote: Sorry, but it looks like it's doing what you are asking of it. Perhaps you should comment your code to make sure it's doing what you are thinking it's doing. you are instantiating a new filters class, giving it the name 'o', then you get a list of the contents of that class, run them if possible, and then you are instantiating a new filters class, naming it 'result', kinda like 'o' was and then you are returning it. Why? What's the point of doing all that if 'o' is never going to be used? you might as well take that out since you are just returning a new class instance anyway. On Tuesday, June 3, 2014 2:50:48 AM UTC-7, Maurice Waka wrote: from applications.Folders1.modules.myfolder1.main import main from applications.Folders1.modules.myfolder1.list1 import GAMES0 code. if id == name3: result = location return result else: while True: class Filters(object): def Filter_cause(self): for item in name3.split(): b = False for c in FILTERTYPE: b = b | (item.find(c) != -1) if b: for (func) in GAMES0: func() o = Filters() for stuff in dir(o): if 'Filter' in stuff: getattr(o, stuff)() result = Filters() return result GAMES0 contains several python modules being imported. My loop works well up to the return location, section but on looping over the 'def class Filters', I get this message: applications.Folders1.modules.myfolder1.main.Filters object at 0x06D689F0 How can I make it to print out my message from any of the modules -- 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/JsESNTvfrHQ/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. -- Dr Maurice Waka, MBCHB. Nairobi -- 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: web2py CMS
Plone +1 2014-06-03 15:52 GMT-03:00 Derek sp1d...@gmail.com: I would recommend Plone (http://plone.org/). It's a very good Python CMS with a 13 year history. There's also Tactic ( http://community.southpawtech.com/get-started) which is good, if you handle digital assets like video files. On Friday, May 30, 2014 7:21:04 AM UTC-7, Andrey K wrote: I am interested to add in CMS system for our web2py application. Quick search does not give me any solutions. Is there any CMS plugin already or any recipes on it? Any thoughts, suggestions, links and comments would be very appreciated. Thank you in advance! -- 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.
[web2py] Re: Restore missing web2py.socket
Did as you wrote, but there were no errors in uwsgi logs. In the next step nginx logged exactly the same error as described in my first post. I'm thinking of setting web2py up again, from scratch. Can you suggest a good .sh script for that purpose? I use CentOS 6.4. Thanks for help. On Monday, June 2, 2014 2:00:51 PM UTC+2, Niphlod wrote: uhm, I see. This script doesn't use host:port but a socket file for the interaction between nginx and uwsgi. The first thing to do is be sure that uwsgi can create the file. You can check it with /etc/init.d/uwsgi start This should start the uwsgi process and report if any errors occurred. uwsgi log is in /var/log/uwsgi/uwsgi.log to check for futher errors. Once uwsgi is ruled out, you can then check with /etc/init.d/nginx to start the nginx process and see if there are errors on the nginx side On Sunday, June 1, 2014 5:52:33 PM UTC+2, lesssugar wrote: I used the following script for the setup: http://web2py.googlecode.com/hg/scripts/setup-web2py-nginx-uwsgi-centos64.sh I tried recreating logs folder under /var/www/web2py/, restarting uwsgi and nginx - unfortunately the error occurs. Do I need to add specific permissions for the logs folder? No idea. Do I even need to use the web2py.socket? Isn't 127.0.0.1:9001 enough as uwsgi_pass value? I have really small knowledge on the subject of configuring web2py on a server, that's why I used the .sh script. On Saturday, May 31, 2014 5:59:05 PM UTC+2, Niphlod wrote: What did you do to install this setup ? having the socket inside /var/www is not something is usually done. However, that error is nginx telling you that a socket you told him to listen to isn't there, so to fix the error I'd create the logs folder again and restart whatever process (supposedly uwsgi) creates that file. The second step would be to review carefully the configuration ^_^ On Saturday, May 31, 2014 2:30:22 PM UTC+2, lesssugar wrote: I'm using web2py's nginx + uwsgi + centos configuration and I accidentally removed web2py/logs folder on my server. Now I get 502 bad gateway whenever I try to open my page. nginx error log: 2014/05/31 13:16:50 [crit] 762#0: *1052 connect() to unix:///var/www/web2py/logs/web2py.socket failed (2: No such file or directory) while connecting to upstream, client: xxx.xx.xxx.xxx, server: xxx.com, request: GET / HTTP/1.1, upstream: uwsgi://unix:///var/www/web2py/logs/web2py.socket:, host: www.xxx.com How can I restore web2py.socket file and get my website to work again? Any help appreciated. -- 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 function import not working well
Some of the code in the functions and classes not displayed in your original post may reference web2py globals and environment variables. I think (I'm still learning web2py also) that running your code in the shell then has access to the web2py environment. Modules do not have access automatically (unlike models and controllers and views). You have to explicitly give your module functions and classes access to the web2py globals, environment, etc. either by importing them in the module or passing them as arguments. Here's one thread that has some more information: https://groups.google.com/forum/#!searchin/web2py/modules$20environment/web2py/FIF1JnBjuIY/f8-6QwXPpDkJ There's also a good slice on web2pyslices that gives an example. On Tuesday, June 3, 2014 3:30:02 PM UTC-4, Maurice Waka wrote: When I work with the same module on python shell, its perfectly printing out. I dont know why it does not print on web2py. Basically I imported it without editing from python shell. Anyway since am new to web2py and python, you could help out On Tuesday, June 3, 2014, Derek sp1...@gmail.com javascript: wrote: Sorry, but it looks like it's doing what you are asking of it. Perhaps you should comment your code to make sure it's doing what you are thinking it's doing. you are instantiating a new filters class, giving it the name 'o', then you get a list of the contents of that class, run them if possible, and then you are instantiating a new filters class, naming it 'result', kinda like 'o' was and then you are returning it. Why? What's the point of doing all that if 'o' is never going to be used? you might as well take that out since you are just returning a new class instance anyway. On Tuesday, June 3, 2014 2:50:48 AM UTC-7, Maurice Waka wrote: from applications.Folders1.modules.myfolder1.main import main from applications.Folders1.modules.myfolder1.list1 import GAMES0 code. if id == name3: result = location return result else: while True: class Filters(object): def Filter_cause(self): for item in name3.split(): b = False for c in FILTERTYPE: b = b | (item.find(c) != -1) if b: for (func) in GAMES0: func() o = Filters() for stuff in dir(o): if 'Filter' in stuff: getattr(o, stuff)() result = Filters() return result GAMES0 contains several python modules being imported. My loop works well up to the return location, section but on looping over the 'def class Filters', I get this message: applications.Folders1.modules.myfolder1.main.Filters object at 0x06D689F0 How can I make it to print out my message from any of the modules -- 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/JsESNTvfrHQ/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- Dr Maurice Waka, MBCHB. Nairobi -- 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: Alternative to SQLFORM for Angular
What happened to this? /R -- 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] nodejs and web2py
hello Is it possible to work web2py with nodejs and that somebody knows the procedure 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] Is it easy to create a grid data entry form using web2py?
This may be trying to run before I can walk but never mind! :-) Is it easy to create a grid type table editing form in web2py? I just want an easy way to edit an existing table, edit existing fields and add new rows. It's just simple data, text and numeric fields in a sqlite3 database. I want to edit the data in place, no pop-up forms or windows, just click on a field and edit the data, tab to the next field and the changed data is saved (could be delayed to when on leaves the form but I don't want to have to do any explcit 'save' action). Add a new row at the bottom by tab off the last field of the last existing row or maybe cursor down on last row or just have an empty row always at the bottom (like MS Access). The table will already exist and I want to see all the columns, no need for views or selects (though I might find uses for them in the future). This is to run on an existing system (xubuntu 14.04) running apache2 web server with various bits and pieces already running on it. I'm fairly happy with installing web apps and use Python quite a lot for small scripts but I haven't really worked with a development framework like web2py before. -- Chris Green -- 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] better way to find the updated or inserted record id
Before I insert a record, I need to check whether the record is already in database. If true, then I need to know the id of the record. Below is my implementation, I first does the query, and check whether record exist or not query = db(db.groups.name == 'some_name').select() if query.records: group_id = query[0].id else: group_id = db.groups.insert(.) I wonder is there any better way to do this task? may be use update_or_insert ? does it return the id of updated or inserted record? -- 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] Reading and extracting strings from a file
I am a beginner.I want to extract some text from a file.Where do I upload the file and how can I extract the text?Please help me out.(Using python) -- 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: plugin_dataTables
Could you post some screenshots? On Tuesday, 3 June 2014 12:08:03 UTC-5, Manuele wrote: I'd like to share this plugin I prepared... maybe I'll produce a web2py slice recipe about how to use it but for the moment if you are interested in it you can browse the demo application or look the code of the plugin_examples files. I hope to collect contributions and comments :) https://github.com/manuelep/web2py.app_plugin_dataTables 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.
[web2py] Re: plugin_dataTables
Thank you for sharing this. On Tuesday, 3 June 2014 12:08:03 UTC-5, Manuele wrote: I'd like to share this plugin I prepared... maybe I'll produce a web2py slice recipe about how to use it but for the moment if you are interested in it you can browse the demo application or look the code of the plugin_examples files. I hope to collect contributions and comments :) https://github.com/manuelep/web2py.app_plugin_dataTables 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.
[web2py] Re: better way to find the updated or inserted record id
You should not access query.records since it may go away. You can do: row = db.groups(name http://db.groups.name/='some_name') or db.groups.insert(...) It is still two queries but a little faster because db.groups(name http://db.groups.name/ = 'some_name') only looks for the first match. On Tuesday, 3 June 2014 11:41:37 UTC-5, chuan137 wrote: Before I insert a record, I need to check whether the record is already in database. If true, then I need to know the id of the record. Below is my implementation, I first does the query, and check whether record exist or not query = db(db.groups.name == 'some_name').select() if query.records: group_id = query[0].id else: group_id = db.groups.insert(.) I wonder is there any better way to do this task? may be use update_or_insert ? does it return the id of updated or inserted record? -- 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: nodejs and web2py
node.js assumes a server in JS, web2py is written in Python. I guess you can have a a node.js app and web2py app share a database but that is about it. On Tuesday, 3 June 2014 01:37:06 UTC-5, eric cuver wrote: hello Is it possible to work web2py with nodejs and that somebody knows the procedure 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: Reading and extracting strings from a file
def index(): form = FORM(INPUT(_type='file',_name='myfile'),INPUT(_type='submit',_value='upload')) if form.process().accepted and form.vars.myfile: text = form.vars.myfile.file.read() form = DIV(XML(text)) return dict(form = form) On Tuesday, 3 June 2014 01:55:58 UTC-5, Akhila Reddy wrote: I am a beginner.I want to extract some text from a file.Where do I upload the file and how can I extract the text?Please help me out.(Using python) -- 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: nodejs and web2py
You might be able to use something like ZeroRPC to communicate between the two on the server: http://zerorpc.dotcloud.com/ Anthony On Tuesday, June 3, 2014 4:17:05 PM UTC-4, Massimo Di Pierro wrote: node.js assumes a server in JS, web2py is written in Python. I guess you can have a a node.js app and web2py app share a database but that is about it. On Tuesday, 3 June 2014 01:37:06 UTC-5, eric cuver wrote: hello Is it possible to work web2py with nodejs and that somebody knows the procedure 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 redirect a page after Google OAuth login?
I am using Google OAuth to login in my app. In `default/index.html` I have some buttons (as a menu), each button have a link to specific controller. When I click on one of those buttons, my app go to 'default/user/login'. After login process I am being redirected to `default/index.html`. I'd like to be redirected to the link I clicked. I tried the following, I have the next lines in each controller: vars={'controller': request.controller, 'function':request.function} (auth.user or request.args(0) == 'login') or\ redirect(URL('default', 'user', args='login', vars=vars)) In the `user` function in `default.py` controller I have: controller = request.vars['controller'] function = request.vars['function'] if request.args(0) == 'login': auth.settings.login_next = URL(controller, function) I receive 'None' and 'None' however. Which is the way to redirect to the correct controller instead of 'default/index' after login process with Google OAuth? Greetings -- 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: Restore missing web2py.socket
uwsgi either creates the file, or it errors out and stops. It can't work otherwise if the script you used is that one. Look into /etc/uwsgi/web2py.ini to see the socket path. As a good script, sorry, I refrain from anything not Debian-related as nightmares although nginx+uwsgi+web2py is one of the easiest setups around, because all of them are extensively documented. On Tuesday, June 3, 2014 9:46:53 PM UTC+2, lesssugar wrote: Did as you wrote, but there were no errors in uwsgi logs. In the next step nginx logged exactly the same error as described in my first post. I'm thinking of setting web2py up again, from scratch. Can you suggest a good .sh script for that purpose? I use CentOS 6.4. Thanks for help. On Monday, June 2, 2014 2:00:51 PM UTC+2, Niphlod wrote: uhm, I see. This script doesn't use host:port but a socket file for the interaction between nginx and uwsgi. The first thing to do is be sure that uwsgi can create the file. You can check it with /etc/init.d/uwsgi start This should start the uwsgi process and report if any errors occurred. uwsgi log is in /var/log/uwsgi/uwsgi.log to check for futher errors. Once uwsgi is ruled out, you can then check with /etc/init.d/nginx to start the nginx process and see if there are errors on the nginx side On Sunday, June 1, 2014 5:52:33 PM UTC+2, lesssugar wrote: I used the following script for the setup: http://web2py.googlecode.com/hg/scripts/setup-web2py-nginx-uwsgi-centos64.sh I tried recreating logs folder under /var/www/web2py/, restarting uwsgi and nginx - unfortunately the error occurs. Do I need to add specific permissions for the logs folder? No idea. Do I even need to use the web2py.socket? Isn't 127.0.0.1:9001 enough as uwsgi_pass value? I have really small knowledge on the subject of configuring web2py on a server, that's why I used the .sh script. On Saturday, May 31, 2014 5:59:05 PM UTC+2, Niphlod wrote: What did you do to install this setup ? having the socket inside /var/www is not something is usually done. However, that error is nginx telling you that a socket you told him to listen to isn't there, so to fix the error I'd create the logs folder again and restart whatever process (supposedly uwsgi) creates that file. The second step would be to review carefully the configuration ^_^ On Saturday, May 31, 2014 2:30:22 PM UTC+2, lesssugar wrote: I'm using web2py's nginx + uwsgi + centos configuration and I accidentally removed web2py/logs folder on my server. Now I get 502 bad gateway whenever I try to open my page. nginx error log: 2014/05/31 13:16:50 [crit] 762#0: *1052 connect() to unix:///var/www/web2py/logs/web2py.socket failed (2: No such file or directory) while connecting to upstream, client: xxx.xx.xxx.xxx, server: xxx.com, request: GET / HTTP/1.1, upstream: uwsgi://unix:///var/www/web2py/logs/web2py.socket:, host: www.xxx.com How can I restore web2py.socket file and get my website to work again? Any help appreciated. -- 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 add button on SQLFORM.grid?
two simple steps: 1) read ALL this http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-grid-and-SQLFORM-smartgrid 2) if you don't know how to do it with the links argument, go to step 1) ^_^ On Tuesday, June 3, 2014 9:24:26 PM UTC+2, Fabiano Almeida wrote: Hi, How to add button/field on SQLFORM.grid? I need create link to edit slave table with row id. Thanks, Fabiano -- 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 redirect a page after Google OAuth login?
I solved: vars={'_next':request.env.request_uri} (auth.user or request.args(0) == 'login') or\ redirect(URL('default', 'user', args='login', vars=vars)) On Tuesday, June 3, 2014 5:12:06 PM UTC-5, Omar Meat Boy Gutiérrez wrote: I am using Google OAuth to login in my app. In `default/index.html` I have some buttons (as a menu), each button have a link to specific controller. When I click on one of those buttons, my app go to 'default/user/login'. After login process I am being redirected to `default/index.html`. I'd like to be redirected to the link I clicked. I tried the following, I have the next lines in each controller: vars={'controller': request.controller, 'function':request.function} (auth.user or request.args(0) == 'login') or\ redirect(URL('default', 'user', args='login', vars=vars)) In the `user` function in `default.py` controller I have: controller = request.vars['controller'] function = request.vars['function'] if request.args(0) == 'login': auth.settings.login_next = URL(controller, function) I receive 'None' and 'None' however. Which is the way to redirect to the correct controller instead of 'default/index' after login process with Google OAuth? Greetings -- 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: How to add button on SQLFORM.grid?
Thanks Niphlod, Using links worked! Fabiano. 2014-06-03 19:21 GMT-03:00 Niphlod niph...@gmail.com: two simple steps: 1) read ALL this http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-grid-and-SQLFORM-smartgrid 2) if you don't know how to do it with the links argument, go to step 1) ^_^ On Tuesday, June 3, 2014 9:24:26 PM UTC+2, Fabiano Almeida wrote: Hi, How to add button/field on SQLFORM.grid? I need create link to edit slave table with row id. Thanks, Fabiano -- 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.
[web2py] How to use createargs in SQLFORM.grid?
Hi, How to use creatargs in SQLFORM.grid? Table: Objeto = db.define_table('objeto', SQLField('almoxarifado_id', db.almoxarifado, notnull=True, readable=True, writable=True, label='Almoxarifado'), SQLField('nome', 'string', length='50', notnull=True, label='Nome'), SQLField('quantidade', 'integer', notnull=True, default=0), SQLField('localizacao', 'string', length='50', label='Localização'), SQLField('obs', 'text', label='Especificação')) Objeto.almoxarifado_id.requires=IS_IN_DB(db, 'almoxarifado.id', '%(nome)s') def index(): alm = request.args(0) or redirect(URL('almoxarifado','index')) form = SQLFORM.grid(Objeto.almoxarifado_id == alm, fields=[Objeto.nome, Objeto.quantidade, Objeto.localizacao], createargs={'Objeto.almoxarifado_id':alm}, user_signature=False, csv=False) return dict(form=form) I try create new record with field Objeto.almoxarifado_id = args(0), to hide this field in form. Thanks in advance, Fabiano. -- 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 use createargs in SQLFORM.grid?
In manual dont have example of createargs: while createargs, editargs and viewargs are passed only to the specific create, edit and details SQLFORMs this is the only reference manual Em quarta-feira, 4 de junho de 2014 00h43min27s UTC-3, Fabiano Almeida escreveu: Hi, How to use creatargs in SQLFORM.grid? Table: Objeto = db.define_table('objeto', SQLField('almoxarifado_id', db.almoxarifado, notnull=True, readable=True, writable=True, label='Almoxarifado'), SQLField('nome', 'string', length='50', notnull=True, label='Nome'), SQLField('quantidade', 'integer', notnull=True, default=0), SQLField('localizacao', 'string', length='50', label='Localização'), SQLField('obs', 'text', label='Especificação')) Objeto.almoxarifado_id.requires=IS_IN_DB(db, 'almoxarifado.id', '%(nome)s') def index(): alm = request.args(0) or redirect(URL('almoxarifado','index')) form = SQLFORM.grid(Objeto.almoxarifado_id == alm, fields=[Objeto.nome, Objeto.quantidade, Objeto.localizacao], createargs={'Objeto.almoxarifado_id':alm}, user_signature=False, csv=False) return dict(form=form) I try create new record with field Objeto.almoxarifado_id = args(0), to hide this field in form. Thanks in advance, Fabiano. -- 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: How to use createargs in SQLFORM.grid?
You can create a dictionary that represents the arguments passed to the SQLFORM(), and pass it in createargs, editargs, viewargs. The code basically updates the SQLFORM (not the grid) with the appropriate create/edit/view args: https://github.com/web2py/web2py/blob/7d8f4360facf4676253492952c28777147736c00/gluon/sqlhtml.py#L2094 Take a look at the SQLFORM signature to understand what can be passed in: http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM Hope this helps. Kiran Subbaraman http://subbaraman.wordpress.com/about/ On Wed, 04-06-2014 9:17 AM, Fabiano Almeida wrote: In manual dont have example of createargs: while |createargs|, |editargs| and |viewargs| are passed only to the specific create, edit and details SQLFORMs this is the only reference manual Em quarta-feira, 4 de junho de 2014 00h43min27s UTC-3, Fabiano Almeida escreveu: Hi, How to use creatargs in SQLFORM.grid? Table: Objeto = db.define_table('objeto', SQLField('almoxarifado_id', db.almoxarifado, notnull=True, readable=True, writable=True, label='Almoxarifado'), SQLField('nome', 'string', length='50', notnull=True, label='Nome'), SQLField('quantidade', 'integer', notnull=True, default=0), SQLField('localizacao', 'string', length='50', label='Localização'), SQLField('obs', 'text', label='Especificação')) Objeto.almoxarifado_id.requires=IS_IN_DB(db, 'almoxarifado.id http://almoxarifado.id', '%(nome)s') def index(): alm = request.args(0) or redirect(URL('almoxarifado','index')) form = SQLFORM.grid(Objeto.almoxarifado_id == alm, fields=[Objeto.nome, Objeto.quantidade, Objeto.localizacao], createargs={'Objeto.almoxarifado_id':alm}, user_signature=False, csv=False) return dict(form=form) I try create new record with field Objeto.almoxarifado_id = args(0), to hide this field in form. Thanks in advance, Fabiano. -- 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 mailto: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.