Re: [web2py] Re: Resizing a user uploaded image
No, just regular web2py webserver on my machine. Jan 9, 2013 2:36 AM、Bruno Rocha rochacbr...@gmail.com のメッセージ: are you running on Google App Engine? -- --
[web2py] Resizing a user uploaded image
How can i make it so that when a user uploads an image, it automatically gets resized to a specified dimension? Thanks! --
Re: [web2py] Re: Resizing a user uploaded image
I put imageutils in my app's modules directory, then I added: Field(thumbnail, upload, uploadfolder=os.path.join(request.folder, 'uploads', 'profiles', 'thumbs')), to the appropriate database table, and below that, in the same file (db.py) I wrote: from imageutils import THUMB db.tutor.thumbnail.compute = lambda row: THUMB(row.picture, 200, 200) but the resizing doesn't seem to work. Am I doing something wrong? On Tue, Jan 8, 2013 at 9:29 PM, Michele Comitini michele.comit...@gmail.com wrote: I use wand for the task: http://pypi.python.org/pypi/Wand/0.1.10 there are many other bindings on the impressive *magick libraries, but this one being a ctypes implementation is light and fast enough.. mic 2013/1/8 Bruno Rocha rochacbr...@gmail.com: I am using this recipe: http://www.web2pyslices.com/slice/show/1522/generate-a-thumbnail-that-fits-in-a-box I have plans to integrate it with a JavaScript Cropper plugin to get the dimensions. -- -- --
Re: [web2py] Re: Resizing a user uploaded image
Hmm still not working. I'm wondering if this is the problem: uploadfolder=os.path.join(request.folder, 'uploads', 'profiles', 'thumbs') should it be uploadfolder=os.path.join(request.folder, 'uploads', 'profiles/thumbs') or something? On Wed, Jan 9, 2013 at 12:43 AM, Bruno Rocha rochacbr...@gmail.com wrote: Yeah it is a problem in THUMB function, thumb function looks for files under /uploads and you are defining another folder. change the imageutils module replacing /uploads with /uploads/profile On Tue, Jan 8, 2013 at 9:30 PM, Daniele Pestilli byakugan...@gmail.comwrote: I put imageutils in my app's modules directory, then I added: Field(thumbnail, upload, uploadfolder=os.path.join(request.folder, 'uploads', 'profiles', 'thumbs')), to the appropriate database table, and below that, in the same file (db.py) I wrote: from imageutils import THUMB db.tutor.thumbnail.compute = lambda row: THUMB(row.picture, 200, 200) but the resizing doesn't seem to work. Am I doing something wrong? On Tue, Jan 8, 2013 at 9:29 PM, Michele Comitini michele.comit...@gmail.com wrote: I use wand for the task: http://pypi.python.org/pypi/Wand/0.1.10 there are many other bindings on the impressive *magick libraries, but this one being a ctypes implementation is light and fast enough.. mic 2013/1/8 Bruno Rocha rochacbr...@gmail.com: I am using this recipe: http://www.web2pyslices.com/slice/show/1522/generate-a-thumbnail-that-fits-in-a-box I have plans to integrate it with a JavaScript Cropper plugin to get the dimensions. -- -- -- -- --
Re: [web2py] Re: Resizing a user uploaded image
It seems to be uploading the full-sized image properly but for the thumb it says 'thumbnail': None where thumbnail is the field name in the db.py file. On Wed, Jan 9, 2013 at 1:06 AM, Daniele Pestilli byakugan...@gmail.comwrote: Hmm still not working. I'm wondering if this is the problem: uploadfolder=os.path.join(request.folder, 'uploads', 'profiles', 'thumbs') should it be uploadfolder=os.path.join(request.folder, 'uploads', 'profiles/thumbs') or something? On Wed, Jan 9, 2013 at 12:43 AM, Bruno Rocha rochacbr...@gmail.comwrote: Yeah it is a problem in THUMB function, thumb function looks for files under /uploads and you are defining another folder. change the imageutils module replacing /uploads with /uploads/profile On Tue, Jan 8, 2013 at 9:30 PM, Daniele Pestilli byakugan...@gmail.comwrote: I put imageutils in my app's modules directory, then I added: Field(thumbnail, upload, uploadfolder=os.path.join(request.folder, 'uploads', 'profiles', 'thumbs')), to the appropriate database table, and below that, in the same file (db.py) I wrote: from imageutils import THUMB db.tutor.thumbnail.compute = lambda row: THUMB(row.picture, 200, 200) but the resizing doesn't seem to work. Am I doing something wrong? On Tue, Jan 8, 2013 at 9:29 PM, Michele Comitini michele.comit...@gmail.com wrote: I use wand for the task: http://pypi.python.org/pypi/Wand/0.1.10 there are many other bindings on the impressive *magick libraries, but this one being a ctypes implementation is light and fast enough.. mic 2013/1/8 Bruno Rocha rochacbr...@gmail.com: I am using this recipe: http://www.web2pyslices.com/slice/show/1522/generate-a-thumbnail-that-fits-in-a-box I have plans to integrate it with a JavaScript Cropper plugin to get the dimensions. -- -- -- -- --
[web2py] Delete a user
What's the correct way of deleting a user? Say someone creates an account on my page and wants to remove him/herself. How can I do this? Thank you! --
Re: [web2py] Delete a user
Well, I know I can do this from the admin interface but I was wondering how a user can remove himself from the website if he so wishes. Should I put the code `db(db.auth_user.email==some...@domain.com).delete()` in a {{=A(_href=action)}} or is that bad practice? I want the user to be able to delete himself. On Mon, Jan 7, 2013 at 9:56 PM, Bruno Rocha rochacbr...@gmail.com wrote: If you have shell access. Go to your shell python web2py.py -S yourappname -M db(db.auth_user.email==some...@domain.com).delete() db.commit() The user with some...@domain.com is now deleted! If you dont hace shell access, just go to your admi interface, database adminitration and delete from auth_user table. -- --
Re: [web2py] Re: web2py 2.3.2 added + - to some form elements
Hmm I'm not sure how to open a ticket in google...sorry ~_~ On Dec 20, 2012, at 6:48 AM, howesc how...@umich.edu wrote: ooops. i added the - and didn't test the only 1 row case. i'll try and create a patch tomorrow for it. mind opening a ticket in google code? thanks, christian On Tuesday, December 18, 2012 8:17:11 AM UTC-8, Daniele wrote: The newest version of web2py has added some + and - clickable links to form elements so that it is possible to remove the element. However, if there is only one element and one clicks the -, the form disappears and there's no way to get the form element back without refreshing the page. I'll post an image so that you can see what it looks like. I think this is a bug with the newest version because my code hasn't changed at all. There was only a + before... -- --
[web2py] web2py 2.3.2 added + - to some form elements
The newest version of web2py has added some + and - clickable links to form elements so that it is possible to remove the element. However, if there is only one element and one clicks the -, the form disappears and there's no way to get the form element back without refreshing the page. I'll post an image so that you can see what it looks like. I think this is a bug with the newest version because my code hasn't changed at all. There was only a + before... -- attachment: with_form_elt.pngattachment: without_form_elt.png
[web2py] Re: Add button to form access from view
Still isn't working for me :'( In my view, I have: div id=deltutor{{=A('Delete Role',_class=btn btn-danger,_id='deltutorlink', callback=URL('edit_profile'),delete='#deltutor')}/div in my controller, under the edit_profile method, I have: if request.vars.deltutorlink: response.flash = T('deltutorlink reached!') but this response.flash is never reached. I can't figure out how to get the callback go to the controller and pass in the request.vars.deltutorlink as being clicked so that it can run the code I want... On Saturday, December 15, 2012 7:36:34 PM UTC, Massimo Di Pierro wrote: div id=row123 {{=A('delete 123',callback=URL('delete',args=123),delete='#row123')}} ... /div The delete argument indicates that upon success you want to remove the div id=row123.../div from the page. If there is a delete argument the confirmation popup is automatic. ;-) On Saturday, 15 December 2012 11:35:28 UTC-6, Daniele wrote: I want to do something very simple but it's taking me eons to do this~ When the button is clicked, I want a javascript alert to pop up that asks, are you sure? Yes/No. If Yes, then run this code: auth.del_membership('role') No redirection, just delete the role. That's all -_- this is taking me way too long On Saturday, December 15, 2012 3:32:22 PM UTC, Massimo Di Pierro wrote: None. You are asking to :eval the result. It meas the action is supposed to return JS def test(): return alert('hello') anyway, you should debug this with the JS console in chrome. We do not know exactly how your code looks like. On Saturday, 15 December 2012 09:08:37 UTC-6, Daniele wrote: I am trying with: {{=A('Delete Role', _class=btn btn-danger, _id=del_role_tutor, callback=URL('test'), target=:eval)}} and in my controller: def test(): return Hello or def test(): return dict() but when I click the button, nothing happens. Why is this?? On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote: When I use form.add_button() I am able to add a button to a form, which I can display with {{=form}} in my view. However, if I'm making a custom form using form.custom, how can I display that button?? Thanks --
Re: [web2py] Re: Add button to form access from view
Sure thing Massimo, here's my view: http://bpaste.net/show/nSrzmYsurH2CnXLrpdwJ/ here's my controller: http://bpaste.net/show/KEx38v6ARYgsUwG8oXMd/ Daniele On Tue, Dec 18, 2012 at 5:07 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Please post your code so we can try it. Are you sure the edit_profile is not being called? Can you use the JS console in chorme to see what is going on? Massimo On Tuesday, 18 December 2012 10:49:28 UTC-6, Daniele wrote: Still isn't working for me :'( In my view, I have: div id=deltutor{{=A('Delete Role',_class=btn btn-danger,_id='deltutorlink'**, callback=URL('edit_profile'),** delete='#deltutor')}/div in my controller, under the edit_profile method, I have: if request.vars.deltutorlink: response.flash = T('deltutorlink reached!') but this response.flash is never reached. I can't figure out why On Saturday, December 15, 2012 7:36:34 PM UTC, Massimo Di Pierro wrote: div id=row123 {{=A('delete 123',callback=URL('delete',**args=123),delete='#row123')}} ... /div The delete argument indicates that upon success you want to remove the div id=row123.../div from the page. If there is a delete argument the confirmation popup is automatic. ;-) On Saturday, 15 December 2012 11:35:28 UTC-6, Daniele wrote: I want to do something very simple but it's taking me eons to do this~ When the button is clicked, I want a javascript alert to pop up that asks, are you sure? Yes/No. If Yes, then run this code: auth.del_membership('role') No redirection, just delete the role. That's all -_- this is taking me way too long On Saturday, December 15, 2012 3:32:22 PM UTC, Massimo Di Pierro wrote: None. You are asking to :eval the result. It meas the action is supposed to return JS def test(): return alert('hello') anyway, you should debug this with the JS console in chrome. We do not know exactly how your code looks like. On Saturday, 15 December 2012 09:08:37 UTC-6, Daniele wrote: I am trying with: {{=A('Delete Role', _class=btn btn-danger, _id=del_role_tutor, callback=URL('test'), target=:eval)}} and in my controller: def test(): return Hello or def test(): return dict() but when I click the button, nothing happens. Why is this?? On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote: When I use form.add_button() I am able to add a button to a form, which I can display with {{=form}} in my view. However, if I'm making a custom form using form.custom, how can I display that button?? Thanks -- --
[web2py] Re: Add button to form access from view
I tried doing this but absolutely nothing happens when I click the button On Tuesday, December 18, 2012 5:10:01 PM UTC, Massimo Di Pierro wrote: BTW... def edit_record(): ... if request.vars.deltutorlink: response.flash = T('deltutorlink reached!') ... If edit_record is called via ajax and not within a component, than response.flash is not displayed because there is no view associated to the callback. You can do: def edit_record(): ... if request.vars.deltutorlink: response.js = jQuery('.flash').html('deltutorlink reached!').slideDown() ... and the response flash will be injected in the proper place. On Tuesday, 18 December 2012 10:49:28 UTC-6, Daniele wrote: Still isn't working for me :'( In my view, I have: div id=deltutor{{=A('Delete Role',_class=btn btn-danger,_id='deltutorlink', callback=URL('edit_profile'),delete='#deltutor')}/div in my controller, under the edit_profile method, I have: if request.vars.deltutorlink: response.flash = T('deltutorlink reached!') but this response.flash is never reached. I can't figure out why On Saturday, December 15, 2012 7:36:34 PM UTC, Massimo Di Pierro wrote: div id=row123 {{=A('delete 123',callback=URL('delete',args=123),delete='#row123')}} ... /div The delete argument indicates that upon success you want to remove the div id=row123.../div from the page. If there is a delete argument the confirmation popup is automatic. ;-) On Saturday, 15 December 2012 11:35:28 UTC-6, Daniele wrote: I want to do something very simple but it's taking me eons to do this~ When the button is clicked, I want a javascript alert to pop up that asks, are you sure? Yes/No. If Yes, then run this code: auth.del_membership('role') No redirection, just delete the role. That's all -_- this is taking me way too long On Saturday, December 15, 2012 3:32:22 PM UTC, Massimo Di Pierro wrote: None. You are asking to :eval the result. It meas the action is supposed to return JS def test(): return alert('hello') anyway, you should debug this with the JS console in chrome. We do not know exactly how your code looks like. On Saturday, 15 December 2012 09:08:37 UTC-6, Daniele wrote: I am trying with: {{=A('Delete Role', _class=btn btn-danger, _id=del_role_tutor, callback=URL('test'), target=:eval)}} and in my controller: def test(): return Hello or def test(): return dict() but when I click the button, nothing happens. Why is this?? On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote: When I use form.add_button() I am able to add a button to a form, which I can display with {{=form}} in my view. However, if I'm making a custom form using form.custom, how can I display that button?? Thanks --
[web2py] Re: Add button to form access from view
It's quite pathetic that web2py doesn't provide a BUTTON helper by the way... On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote: When I use form.add_button() I am able to add a button to a form, which I can display with {{=form}} in my view. However, if I'm making a custom form using form.custom, how can I display that button?? Thanks --
[web2py] Re: Add button to form access from view
I tried putting this HTML button id=b_normal class=btn btn-danger onClick=ajax('{{=URL('test')}}',[],':eval')Delete Role/button which I saw on a stackoverflow post. However, even when I do that and click the button, the form ALWAYS gets submitted. I already have a submit button so I don't understand why the form is being submitted via other buttons as well. Does anyone know why this is??? On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote: When I use form.add_button() I am able to add a button to a form, which I can display with {{=form}} in my view. However, if I'm making a custom form using form.custom, how can I display that button?? Thanks --
[web2py] Re: Add button to form access from view
Please pardon my ignorance, I didn't know there was a button helper. And thanks Massimo, I'll give the A with the class btn a try now! On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote: When I use form.add_button() I am able to add a button to a form, which I can display with {{=form}} in my view. However, if I'm making a custom form using form.custom, how can I display that button?? Thanks --
[web2py] Re: Add button to form access from view
I am trying with: {{=A('Delete Role', _class=btn btn-danger, _id=del_role_tutor, callback=URL('test'), target=:eval)}} and in my controller: def test(): return Hello or def test(): return dict() but nothing happens. Why is this?? On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote: When I use form.add_button() I am able to add a button to a form, which I can display with {{=form}} in my view. However, if I'm making a custom form using form.custom, how can I display that button?? Thanks --
[web2py] Re: Add button to form access from view
I want to do something very simple but it's taking me eons to do this~ When the button is clicked, I want a javascript alert to pop up that asks, are you sure? Yes/No. If Yes, then run this code: auth.del_membership('role') No redirection, just delete the role. That's all -_- this is taking me way too long On Saturday, December 15, 2012 3:32:22 PM UTC, Massimo Di Pierro wrote: None. You are asking to :eval the result. It meas the action is supposed to return JS def test(): return alert('hello') anyway, you should debug this with the JS console in chrome. We do not know exactly how your code looks like. On Saturday, 15 December 2012 09:08:37 UTC-6, Daniele wrote: I am trying with: {{=A('Delete Role', _class=btn btn-danger, _id=del_role_tutor, callback=URL('test'), target=:eval)}} and in my controller: def test(): return Hello or def test(): return dict() but when I click the button, nothing happens. Why is this?? On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote: When I use form.add_button() I am able to add a button to a form, which I can display with {{=form}} in my view. However, if I'm making a custom form using form.custom, how can I display that button?? Thanks --
[web2py] Re: Add button to form access from view
I have the button button onclick={{=URL http://127.0.0.1:8000/examples/global/vars/URL(del_role)}} class=btn btn-dangerDelete Role/button And in my controller I try to put def del_role and, if the user has membership, i want to del_membership for that role. But this doesn't seem to be working. You were telling me to use _href or callback but, I don't think I can use those with a button html tag... On Tuesday, December 11, 2012 2:29:58 PM UTC, Massimo Di Pierro wrote: {{=A('click me',_href=URL('action'))}} (redirects) or {{=A('click me', callback=URL('action'))}} (call via ajax) or div id=t/div {{=A('click me', callback=URL('action'),target=t)}} (call via ajax and store result in t) or div id=c{{=A('click me', callback=URL('action'),delete=div#c)}}/div (call via ajax and delete button) They can be combined. On Tuesday, 11 December 2012 04:41:25 UTC-6, Daniele wrote: Ok. What's the correct way of associating an action to the HTML button with web2py? On Tuesday, December 11, 2012 12:30:34 AM UTC, Massimo Di Pierro wrote: This is not worth it. If you make a custom form than you are using html, you may as well make the button in html. On Monday, 10 December 2012 15:15:30 UTC-6, Daniele wrote: When I use form.add_button() I am able to add a button to a form, which I can display with {{=form}} in my view. However, if I'm making a custom form using form.custom, how can I display that button?? Thanks --
[web2py] Re: Add button to form access from view
I'm also trying this but it doesn't work: button onclick={{auth.del_membership('role'))}} class=btn btn-dangerDelete Role/button On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote: When I use form.add_button() I am able to add a button to a form, which I can display with {{=form}} in my view. However, if I'm making a custom form using form.custom, how can I display that button?? Thanks --
[web2py] Re: Add button to form access from view
So it's not possible to do this with a button? On Monday, December 10, 2012 9:15:30 PM UTC, Daniele wrote: When I use form.add_button() I am able to add a button to a form, which I can display with {{=form}} in my view. However, if I'm making a custom form using form.custom, how can I display that button?? Thanks --
[web2py] Re: Add button to form access from view
Ok. What's the correct way of associating an action to the HTML button with web2py? On Tuesday, December 11, 2012 12:30:34 AM UTC, Massimo Di Pierro wrote: This is not worth it. If you make a custom form than you are using html, you may as well make the button in html. On Monday, 10 December 2012 15:15:30 UTC-6, Daniele wrote: When I use form.add_button() I am able to add a button to a form, which I can display with {{=form}} in my view. However, if I'm making a custom form using form.custom, how can I display that button?? Thanks --
[web2py] Add button to form access from view
When I use form.add_button() I am able to add a button to a form, which I can display with {{=form}} in my view. However, if I'm making a custom form using form.custom, how can I display that button?? Thanks --
[web2py] Adding a button to a form and adding an action
Hello guys, I'm trying to add a button to a form and when clicked, I'd like for an action to be called that erases a record from the db. I saw the butting addition can be done with form.add_button('Delete Record', URL('other_page')) However, I am wondering how I can tie in an action instead of a url. Like a delete_record method or something. Also, is it possible to append a jQuery alert box to this button that asks the users if he/she is sure? Thanks! --
[web2py] Re: Displaying an image
The uploads seem to be working now, but I still can't figure out how to display them. I have a line in my controller that gets the images in the database: images = [row.t_Image for row in db().select(db.tutor.ALL)] which I can access in the view with {{=images}} Buthow do i get those images to display. I really am having a hard time figuring out how this works... -_- sorry guys On Wednesday, December 5, 2012 2:06:57 PM UTC, Daniele wrote: Guys I know this sounds simple but I'm having a hard time displaying uploaded images. I have an upload field in my model where logged in users can upload an image. But in my views when I try to do {{=IMG(_src=URL('uploads/', row.image))}} where row is a variable that refers to db(db.auth_user.id 0).select() nothing is being returned. However, row.image returns a string which is the name of the file. How can I display the image correctly? Thanks! --
[web2py] Re: Displaying an image
WOHO!!! I GOT IT!!! I needed to put URL('download', args=images[0]) I was spending time trying to figure out what the heck that request.args[-1]thing was. Is that even necessary? On Wednesday, December 5, 2012 2:06:57 PM UTC, Daniele wrote: Guys I know this sounds simple but I'm having a hard time displaying uploaded images. I have an upload field in my model where logged in users can upload an image. But in my views when I try to do {{=IMG(_src=URL('uploads/', row.image))}} where row is a variable that refers to db(db.auth_user.id 0).select() nothing is being returned. However, row.image returns a string which is the name of the file. How can I display the image correctly? Thanks! --
[web2py] Re: Displaying an image
This is still not working for me and I can't figure out for the life of me how to do this simple uploading and displaying of an image. I now have a table dedicated to tutors, which looks like this: db.define_table('tutor', Field('user', 'reference auth_user', default=auth.user_id), Field('t_Image', 'upload', uploadfolder='uploads/profiles', requires=IS_EMPTY_OR(IS_IMAGE(extensions=('jpeg', 'jpg', 'png', 'gif', Field('t_Location', 'list:string', requires=IS_NOT_EMPTY()), Field('t_Subjects', 'list:string', requires=IS_NOT_EMPTY()), Field('t_Qualifications', 'list:string', requires=IS_NOT_EMPTY()), Field('t_Biography', 'text'), #Does this need to be sanitized? Field('t_Hourly_Rate', 'decimal(7,2)', requires=IS_NOT_EMPTY()), Field('t_Modified_On', 'datetime', requires=IS_DATETIME(), writable=False, readable=False, default=request.utcnow) ) I then have the following in my controller: @auth.requires_login() def edit_profile(): response.subtitle = T(Edit Profile) tform = SQLFORM.factory( Field('is_tutor', 'boolean'), *[f for f in db.tutor if f.name.startswith('t_')], upload=URL('download'), table_name='tutor') if tform.process(keepvalues=True).accepted: if tform.vars.is_tutor: if not auth.has_membership('Tutors'): auth.add_membership('Tutors') db.tutor.update_or_insert(db.tutor.user==auth.user_id, t_Hourly_Rate = tform.vars.t_Hourly_Rate, t_Image = tform.vars.t_Image, t_Qualifications = tform.vars.t_Qualifications, t_Subjects = tform.vars.t_Subjects, t_Location = tform.vars.t_Location, t_Biography = tform.vars.t_Biography ) else: if auth.has_membership('Tutors'): auth.del_membership('Tutors') response.flash = T('Profile updated!') elif tform.errors: response.flash = T('There was an error with your submission') return dict(tform=tform) However, I am not able to display the image. I don't know why I can't do something so simple -_- Any help is greatly appreciated. Daniele On Wednesday, December 5, 2012 2:06:57 PM UTC, Daniele wrote: Guys I know this sounds simple but I'm having a hard time displaying uploaded images. I have an upload field in my model where logged in users can upload an image. But in my views when I try to do {{=IMG(_src=URL('uploads/', row.image))}} where row is a variable that refers to db(db.auth_user.id 0).select() nothing is being returned. However, row.image returns a string which is the name of the file. How can I display the image correctly? Thanks! --
[web2py] Tick checkbox if user has_membership
I want to tick a checkbox if a user has membership to something, else leave unticked. I tried putting it in the Field's default variable as such, Field('is_tutor', 'boolean', default=auth.has_membership(auth.user_id, 'Tutors')) but this is causing an error. What's the correct way to do this? Thanks --
[web2py] Unable to update database
I am unable to update entries in my database. I think I have an idea of why this may be, but I'm not sure how to go about fixing this. In my controller, I have: tform = SQLFORM.factory( Field('is_tutor', 'boolean'), *[f for f in db.tutor if f.name.startswith('t_')], table_name='tutor') if tform.process().accepted: if tform.vars.is_tutor: if not auth.has_membership('Tutors'): auth.add_membership('Tutors') db(db.tutor.user == auth.user_id).update( t_Hourly_Rate = tform.vars.t_Hourly_Rate, t_Image = tform.vars.t_Image, t_Qualifications = tform.vars.t_Qualifications, t_Subjects = tform.vars.t_Subjects, t_Location = tform.vars.t_Location, t_Biography = tform.vars.t_Biography ) else: if auth.has_membership('Tutors'): auth.del_membership('Tutors') response.flash = T('Profile updated!') elif tform.errors: response.flash = T('There was an error with your submission') However, when I submit the form I am just getting a bunch of 'None' values. I think the problem may be that I'm trying to update db(db.tutor.user == auth.user_id) but if db.tutor.user does not exist, it is not being assigned the value of the currently logged in user (auth.user_id) How can I go about fixing this?? Thanks --
[web2py] Re: Unable to update database
Ok that seems to have done the trick. However, it's creating a new record every time which means that the logged in user does not refer to the tutor table. Does the id field have to be the same as auth.user_id? The id field seems to be generated automatically. In my tutor table I have a line that says Field('user', 'reference auth.user.id') but the relation does not seem like it's being made... On Friday, December 7, 2012 11:28:06 PM UTC, Anthony wrote: You can try update_or_insert()http://web2py.com/books/default/chapter/29/06#update_or_insert . Anthony On Friday, December 7, 2012 5:54:58 PM UTC-5, Daniele wrote: I am unable to update entries in my database. I think I have an idea of why this may be, but I'm not sure how to go about fixing this. In my controller, I have: tform = SQLFORM.factory( Field('is_tutor', 'boolean'), *[f for f in db.tutor if f.name.startswith('t_')], table_name='tutor') if tform.process().accepted: if tform.vars.is_tutor: if not auth.has_membership('Tutors'): auth.add_membership('Tutors') db(db.tutor.user == auth.user_id).update( t_Hourly_Rate = tform.vars.t_Hourly_Rate, t_Image = tform.vars.t_Image, t_Qualifications = tform.vars.t_Qualifications, t_Subjects = tform.vars.t_Subjects, t_Location = tform.vars.t_Location, t_Biography = tform.vars.t_Biography ) else: if auth.has_membership('Tutors'): auth.del_membership('Tutors') response.flash = T('Profile updated!') elif tform.errors: response.flash = T('There was an error with your submission') However, when I submit the form I am just getting a bunch of 'None' values. I think the problem may be that I'm trying to update db(db.tutor.user == auth.user_id) but if db.tutor.user does not exist, it is not being assigned the value of the currently logged in user (auth.user_id) How can I go about fixing this?? Thanks --
[web2py] Re: Unable to update database
Alright I think I got it to work although I don't know if it's correct. Basically, I added a user variable to the update_or_insert() function, as follows: db.tutor.update_or_insert(db.tutor.user==auth.user_id, user = auth.user_id, t_Hourly_Rate = tform.vars.t_Hourly_Rate, t_Image = tform.vars.t_Image, t_Qualifications = tform.vars.t_Qualifications, t_Subjects = tform.vars.t_Subjects, t_Location = tform.vars.t_Location, t_Biography = tform.vars.t_Biography ) My reasoning was that user would be set automatically, since in my db.py file I said db.define_table('tutor', Field('user', 'reference auth.user.id'), ...) But apparently, I need to set that variable. So how does the actual reference work? I'm not sure I get it. Anyway, it seems to be updating the table now so, thanks for the help ;) On Friday, December 7, 2012 11:38:52 PM UTC, Daniele wrote: Ok that seems to have done the trick. However, it's creating a new record every time which means that the logged in user does not refer to the tutor table. Does the id field have to be the same as auth.user_id? The id field seems to be generated automatically. In my tutor table I have a line that says Field('user', 'reference auth.user.id') but the relation does not seem like it's being made... On Friday, December 7, 2012 11:28:06 PM UTC, Anthony wrote: You can try update_or_insert()http://web2py.com/books/default/chapter/29/06#update_or_insert . Anthony On Friday, December 7, 2012 5:54:58 PM UTC-5, Daniele wrote: I am unable to update entries in my database. I think I have an idea of why this may be, but I'm not sure how to go about fixing this. In my controller, I have: tform = SQLFORM.factory( Field('is_tutor', 'boolean'), *[f for f in db.tutor if f.name.startswith('t_')], table_name='tutor') if tform.process().accepted: if tform.vars.is_tutor: if not auth.has_membership('Tutors'): auth.add_membership('Tutors') db(db.tutor.user == auth.user_id).update( t_Hourly_Rate = tform.vars.t_Hourly_Rate, t_Image = tform.vars.t_Image, t_Qualifications = tform.vars.t_Qualifications, t_Subjects = tform.vars.t_Subjects, t_Location = tform.vars.t_Location, t_Biography = tform.vars.t_Biography ) else: if auth.has_membership('Tutors'): auth.del_membership('Tutors') response.flash = T('Profile updated!') elif tform.errors: response.flash = T('There was an error with your submission') However, when I submit the form I am just getting a bunch of 'None' values. I think the problem may be that I'm trying to update db(db.tutor.user == auth.user_id) but if db.tutor.user does not exist, it is not being assigned the value of the currently logged in user (auth.user_id) How can I go about fixing this?? Thanks --
[web2py] Re: Unable to update database
Worked!!! Thanks s much this has been bugging me for a while. On Saturday, December 8, 2012 12:15:49 AM UTC, Anthony wrote: db.define_table('tutor', Field('user', 'reference auth.user.id'), ...) This is not correct. It should be 'reference [table name]', so in this case, 'reference auth_user'. Perhaps you are attempting to set the default to be auth.user.id (same as auth.user_id) -- to do that, do: Field('user', 'reference auth_user', default=auth.user_id) Anthony --
Re: [web2py] Re: Displaying an image
I noticed that I am missing upload=URL('download') in my SQLFORM.factory, so I added that in there but it's still not working. I double checked the image name and you were right, I don't know how I must have mistakenly deleted that part but it was indeed [table_name].[field_name].[rand_string] I can't think of why else this is not working...I am following the web2py book verbatim... On Thu, Dec 6, 2012 at 3:06 AM, Anthony abasta...@gmail.com wrote: Hmm for some reason it's not working for me. I took a look at the source code and this is the HTML that is being generated: img src=/download/image.**a6e29a6f36771685.**e58699e79c9f2e4a5047.JPG / And this is what I have in my view that is generating that code: {{=IMG(_src=URL('default', 'download', args=row.image))}} so it seems to be taking the 'download' directory and looking for the image there, but as aforementioned, I've set the directory for these images to be in: Field('image', 'upload', uploadfolder=os.path.join(** request.folder,'uploads/**profiles/') No, the URL /download/image... does not imply web2py is looking the the download directory. Remember, URLs do not map to directories (with the exception of static files). In web2py, URLs always map to applications, controllers, and functions. In your URL, it looks like the application and controller are excluded, so download will be interpreted by web2py as the function, and then the filename will be interpreted as request.args(0). This URL will call the download() function in default.py, which will ultimately call response.download(request, db), and that function will pull the filename from request.args(0). There is a problem with the filename, though. It starts with image, which appears to be the field name, but it should actually start with [table_name].[field_name]. I'm not sure how that could have happened. Do you have the same problem with new images that you upload? Do their filenames start with the table name, or just with image? Anthony -- --
Re: [web2py] Re: Displaying an image
I saw in the book that a line is being used, namely record = db.person(request.args(0)) or redirect(URL('index')) but I am not using this line. I tried inserting it and removing the uploadfolder option in the Field('image', 'upload', uploadfolder='...') field but it's giving me all sorts of errors now. I never thought uploading and viewing an image could be this complicated. On Thu, Dec 6, 2012 at 1:33 PM, Daniele Pestilli byakugan...@gmail.comwrote: I noticed that I am missing upload=URL('download') in my SQLFORM.factory, so I added that in there but it's still not working. I double checked the image name and you were right, I don't know how I must have mistakenly deleted that part but it was indeed [table_name].[field_name].[rand_string] I can't think of why else this is not working...I am following the web2py book verbatim... On Thu, Dec 6, 2012 at 3:06 AM, Anthony abasta...@gmail.com wrote: Hmm for some reason it's not working for me. I took a look at the source code and this is the HTML that is being generated: img src=/download/image.**a6e29a6f36771685.**e58699e79c9f2e4a5047.JPG / And this is what I have in my view that is generating that code: {{=IMG(_src=URL('default', 'download', args=row.image))}} so it seems to be taking the 'download' directory and looking for the image there, but as aforementioned, I've set the directory for these images to be in: Field('image', 'upload', uploadfolder=os.path.join(** request.folder,'uploads/**profiles/') No, the URL /download/image... does not imply web2py is looking the the download directory. Remember, URLs do not map to directories (with the exception of static files). In web2py, URLs always map to applications, controllers, and functions. In your URL, it looks like the application and controller are excluded, so download will be interpreted by web2py as the function, and then the filename will be interpreted as request.args(0). This URL will call the download() function in default.py, which will ultimately call response.download(request, db), and that function will pull the filename from request.args(0). There is a problem with the filename, though. It starts with image, which appears to be the field name, but it should actually start with [table_name].[field_name]. I'm not sure how that could have happened. Do you have the same problem with new images that you upload? Do their filenames start with the table name, or just with image? Anthony -- --
Re: [web2py] Re: Displaying an image
) else: if auth.has_membership('Students'): auth.del_membership('Students') response http://127.0.0.1:8000/examples/global/vars/response.flash = T http://127.0.0.1:8000/examples/global/vars/T('Profile updated!') return dict(tform=tform, sform=sform) On Thu, Dec 6, 2012 at 1:48 PM, Anthony abasta...@gmail.com wrote: You mention using SQLFORM.factory -- do you actually store the record in a db table, does that db table name match the name at the beginning of the filename, and is the 'image' field definition in the model for that table the same as the field definition you're using in SQLFORM.factory? It might help if you show all of the relevant model and controller code. Anthony On Thursday, December 6, 2012 8:33:10 AM UTC-5, Daniele wrote: I noticed that I am missing upload=URL('download') in my SQLFORM.factory, so I added that in there but it's still not working. I double checked the image name and you were right, I don't know how I must have mistakenly deleted that part but it was indeed [table_name].[field_name].[**rand_string] I can't think of why else this is not working...I am following the web2py book verbatim... On Thu, Dec 6, 2012 at 3:06 AM, Anthony abas...@gmail.com wrote: Hmm for some reason it's not working for me. I took a look at the source code and this is the HTML that is being generated: img src=/download/image.**a6e29a6f3**6771685.**e58699e79c9f2e4a5047.**JPG / And this is what I have in my view that is generating that code: {{=IMG(_src=URL('default', 'download', args=row.image))}} so it seems to be taking the 'download' directory and looking for the image there, but as aforementioned, I've set the directory for these images to be in: Field('image', 'upload', uploadfolder=os.path.join(**requ** est.folder,'uploads/**profiles/'**) No, the URL /download/image... does not imply web2py is looking the the download directory. Remember, URLs do not map to directories (with the exception of static files). In web2py, URLs always map to applications, controllers, and functions. In your URL, it looks like the application and controller are excluded, so download will be interpreted by web2py as the function, and then the filename will be interpreted as request.args(0). This URL will call the download() function in default.py, which will ultimately call response.download(request, db), and that function will pull the filename from request.args(0). There is a problem with the filename, though. It starts with image, which appears to be the field name, but it should actually start with [table_name].[field_name]. I'm not sure how that could have happened. Do you have the same problem with new images that you upload? Do their filenames start with the table name, or just with image? Anthony -- -- --
Re: [web2py] Re: Displaying an image
this just completely broke my website -_- Now I can't even sign a user up anymore because it's requesting all those additional fields. On Thu, Dec 6, 2012 at 2:33 PM, Anthony abasta...@gmail.com wrote: You are using SQLFORM.factory to handle the upload, but the table and field names used there do not match the table or field names where the records are actually stored, so response.download() cannot find the appropriate table or field. By default, SQLFORM.factory uses no_table as the dummy table name, and your code uses image as the field name. So, your image files will end up with names that start with no_table.image. As a result, response.download(request, db) will look for a db.no_table table with an image field, but obviously won't find it. Instead, your image filenames are actually stored in db.auth_user.t_image, so you need to make sure the filenames get generated with names starting with auth_user.t_image. Also, if you specify a custom uploadfolder, you'll need to make sure that the db.auth_user.t_image field has that uploadfolder specified as well, because response.download() checks the actual db field to determine the uploadfolder. The easiest approach might be to define the field once and reference both in the appended auth_user fields and in SQLFORM.factory. Finally, you can specify the name of the dummy table used by SQLFORM.factory by passing a table_name argument. So, maybe something like this: image_field = Field('t_image', 'upload', ..., uploadfolder=[your upload folder]) auth.settings.extra_fields['auth_user'] = [..., image_field, ...] ... tform = SQLFORM.factory(..., image_field, ..., table_name='auth.user') Actually, you should probably do that with all the fields in SQLFORM.factory -- define them all once and use them in db.auth_user and to make the form. As it is, the field definitions in db.auth_user don't even have the correct field types defined. You could first add all the fields to db.auth_user, and then do something like this: tform = SQLFORM.factory(*[f for f in db.auth_user if f.name.startswith( 't_')], ...) That will include all the fields from db.auth_user that start with t_. Finally, note that there will not be any errors in the form until you process it, so your condition that checks for errors will never find any. First call, form.process(), and then check for errors. Anthony On Thursday, December 6, 2012 8:51:02 AM UTC-5, Daniele wrote: Ok here's my code: in db.py from gluon.tools import Auth, Crud, Service, PluginManager, prettydate auth = Auth(db) auth.settings.extra_fields['**auth_user']= [ # t denote tutor fields, s denote student fields. Field http://127.0.0.1:8000/examples/global/vars/Field('t_image'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_location'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_subjects'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_qualifications'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_biography'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_hourly_rate'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_modified_on'), Field http://127.0.0.1:8000/examples/global/vars/Field('s_location')] in my controller: @auth.requires_login() def edit_profile(): response http://127.0.0.1:8000/examples/global/vars/response.subtitle = T http://127.0.0.1:8000/examples/global/vars/T(Edit Profile) # Tutor form tform = SQLFORM http://127.0.0.1:8000/examples/global/vars/SQLFORM.factory( Field http://127.0.0.1:8000/examples/global/vars/Field('is_tutor', 'boolean'), Field http://127.0.0.1:8000/examples/global/vars/Field('image', 'upload', requires=IS_EMPTY_OR http://127.0.0.1:8000/examples/global/vars/IS_EMPTY_OR(IS_IMAGE http://127.0.0.1:8000/examples/global/vars/IS_IMAGE(**extensions=('jpeg', 'jpg', 'png', 'gif', Field http://127.0.0.1:8000/examples/global/vars/Field('location', 'list:string', requires=IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY()), Field http://127.0.0.1:8000/examples/global/vars/Field('subjects', 'list:string', requires=IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY()), Field http://127.0.0.1:8000/examples/global/vars/Field('qualifications', 'list:string', requires=IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY()), Field http://127.0.0.1:8000/examples/global/vars/Field('biography', 'text'), Field http://127.0.0.1:8000/examples/global/vars/Field('hourly_rate', 'decimal(7,2)', requires=IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY()), Field http://127.0.0.1:8000/examples/global/vars/Field('modified_on', 'datetime', requires=IS_DATETIME http://127.0.0.1:8000/examples
Re: [web2py] Re: Displaying an image
maybe instead of adding on to auth, I should just create two separate tables and have them reference auth On Thu, Dec 6, 2012 at 3:05 PM, Daniele Pestilli byakugan...@gmail.comwrote: this just completely broke my website -_- Now I can't even sign a user up anymore because it's requesting all those additional fields. On Thu, Dec 6, 2012 at 2:33 PM, Anthony abasta...@gmail.com wrote: You are using SQLFORM.factory to handle the upload, but the table and field names used there do not match the table or field names where the records are actually stored, so response.download() cannot find the appropriate table or field. By default, SQLFORM.factory uses no_table as the dummy table name, and your code uses image as the field name. So, your image files will end up with names that start with no_table.image. As a result, response.download(request, db) will look for a db.no_table table with an image field, but obviously won't find it. Instead, your image filenames are actually stored in db.auth_user.t_image, so you need to make sure the filenames get generated with names starting with auth_user.t_image. Also, if you specify a custom uploadfolder, you'll need to make sure that the db.auth_user.t_image field has that uploadfolder specified as well, because response.download() checks the actual db field to determine the uploadfolder. The easiest approach might be to define the field once and reference both in the appended auth_user fields and in SQLFORM.factory. Finally, you can specify the name of the dummy table used by SQLFORM.factory by passing a table_name argument. So, maybe something like this: image_field = Field('t_image', 'upload', ..., uploadfolder=[your upload folder]) auth.settings.extra_fields['auth_user'] = [..., image_field, ...] ... tform = SQLFORM.factory(..., image_field, ..., table_name='auth.user') Actually, you should probably do that with all the fields in SQLFORM.factory -- define them all once and use them in db.auth_user and to make the form. As it is, the field definitions in db.auth_user don't even have the correct field types defined. You could first add all the fields to db.auth_user, and then do something like this: tform = SQLFORM.factory(*[f for f in db.auth_user if f.name.startswith( 't_')], ...) That will include all the fields from db.auth_user that start with t_. Finally, note that there will not be any errors in the form until you process it, so your condition that checks for errors will never find any. First call, form.process(), and then check for errors. Anthony On Thursday, December 6, 2012 8:51:02 AM UTC-5, Daniele wrote: Ok here's my code: in db.py from gluon.tools import Auth, Crud, Service, PluginManager, prettydate auth = Auth(db) auth.settings.extra_fields['**auth_user']= [ # t denote tutor fields, s denote student fields. Field http://127.0.0.1:8000/examples/global/vars/Field('t_image'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_location'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_subjects'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_qualifications'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_biography'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_hourly_rate'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_modified_on'), Field http://127.0.0.1:8000/examples/global/vars/Field('s_location')] in my controller: @auth.requires_login() def edit_profile(): response http://127.0.0.1:8000/examples/global/vars/response.subtitle = T http://127.0.0.1:8000/examples/global/vars/T(Edit Profile) # Tutor form tform = SQLFORM http://127.0.0.1:8000/examples/global/vars/SQLFORM.factory( Field http://127.0.0.1:8000/examples/global/vars/Field('is_tutor', 'boolean'), Field http://127.0.0.1:8000/examples/global/vars/Field('image', 'upload', requires=IS_EMPTY_OR http://127.0.0.1:8000/examples/global/vars/IS_EMPTY_OR(IS_IMAGE http://127.0.0.1:8000/examples/global/vars/IS_IMAGE(**extensions=('jpeg', 'jpg', 'png', 'gif', Field http://127.0.0.1:8000/examples/global/vars/Field('location', 'list:string', requires=IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY()), Field http://127.0.0.1:8000/examples/global/vars/Field('subjects', 'list:string', requires=IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY()), Field http://127.0.0.1:8000/examples/global/vars/Field('qualifications', 'list:string', requires=IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY()), Field http://127.0.0.1:8000/examples/global/vars/Field('biography', 'text'), Field http://127.0.0.1:8000/examples/global/vars/Field('hourly_rate', 'decimal(7,2)', requires=IS_NOT_EMPTY
Re: [web2py] Re: Displaying an image
Yes I did but, the reason why I hadn't extended those directly in auth_user was precisely because I had noticed that, since some of those fields are required, when a user signs up they are prevented from signing up because those other auth fields have not been input. So what I'll do instead is just create another table for tutors and put all the fields there. Then in the SQLFORM.factory I'll use that list comprehension that you wrote to add all the fields. This is what I had done initially but I was having lots of trouble referencing the current logged in user. On Thu, Dec 6, 2012 at 3:20 PM, Anthony abasta...@gmail.com wrote: The last line was just an example -- if you don't need all the fields, then don't use that (or modify it accordingly). Did you try the first solution (i.e., properly naming and defining both the image field and the SQLFORM.factory table)? Anthony On Thursday, December 6, 2012 10:05:43 AM UTC-5, Daniele wrote: this just completely broke my website -_- Now I can't even sign a user up anymore because it's requesting all those additional fields. On Thu, Dec 6, 2012 at 2:33 PM, Anthony abas...@gmail.com wrote: You are using SQLFORM.factory to handle the upload, but the table and field names used there do not match the table or field names where the records are actually stored, so response.download() cannot find the appropriate table or field. By default, SQLFORM.factory uses no_table as the dummy table name, and your code uses image as the field name. So, your image files will end up with names that start with no_table.image. As a result, response.download(request, db) will look for a db.no_table table with an image field, but obviously won't find it. Instead, your image filenames are actually stored in db.auth_user.t_image, so you need to make sure the filenames get generated with names starting with auth_user.t_image. Also, if you specify a custom uploadfolder, you'll need to make sure that the db.auth_user.t_image field has that uploadfolder specified as well, because response.download() checks the actual db field to determine the uploadfolder. The easiest approach might be to define the field once and reference both in the appended auth_user fields and in SQLFORM.factory. Finally, you can specify the name of the dummy table used by SQLFORM.factory by passing a table_name argument. So, maybe something like this: image_field = Field('t_image', 'upload', ..., uploadfolder=[your upload folder]) auth.settings.extra_fields['**auth_user'] = [..., image_field, ...] ... tform = SQLFORM.factory(..., image_field, ..., table_name='auth.user') Actually, you should probably do that with all the fields in SQLFORM.factory -- define them all once and use them in db.auth_user and to make the form. As it is, the field definitions in db.auth_user don't even have the correct field types defined. You could first add all the fields to db.auth_user, and then do something like this: tform = SQLFORM.factory(*[f for f in db.auth_user if f.name.startswith( 't_')], ...) That will include all the fields from db.auth_user that start with t_. Finally, note that there will not be any errors in the form until you process it, so your condition that checks for errors will never find any. First call, form.process(), and then check for errors. Anthony On Thursday, December 6, 2012 8:51:02 AM UTC-5, Daniele wrote: Ok here's my code: in db.py from gluon.tools import Auth, Crud, Service, PluginManager, prettydate auth = Auth(db) auth.settings.extra_fields['**au**th_user']= [ # t denote tutor fields, s denote student fields. Field http://127.0.0.1:8000/examples/global/vars/Field('t_image'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_location'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_subjects'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_qualifications'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_biography'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_hourly_rate'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_modified_on'), Field http://127.0.0.1:8000/examples/global/vars/Field('s_location')] in my controller: @auth.requires_login() def edit_profile(): response http://127.0.0.1:8000/examples/global/vars/response.subtitle = T http://127.0.0.1:8000/examples/global/vars/T(Edit Profile) # Tutor form tform = SQLFORM http://127.0.0.1:8000/examples/global/vars/SQLFORM.factory( Field http://127.0.0.1:8000/examples/global/vars/Field('is_tutor', 'boolean'), Field http://127.0.0.1:8000/examples/global/vars/Field('image', 'upload', requires=IS_EMPTY_OR http://127.0.0.1:8000/examples/global/vars/IS_EMPTY_OR(IS_IMAGE http://127.0.0.1:8000/examples/global/vars/IS_IMAGE(extensions=('jpeg', 'jpg
[web2py] Displaying an image
Guys I know this sounds simple but I'm having a hard time displaying uploaded images. I have an upload field in my model where logged in users can upload an image. But in my views when I try to do {{=IMG(_src=URL('uploads/', row.image))}} where row is a variable that refers to db(db.auth_user.id 0).select() nothing is being returned. However, row.image returns a string which is the name of the file. How can I display the image correctly? Thanks! --
[web2py] Re: Displaying an image
I have def download(): return response.download(request,db) in my controller. But when I put {{=URL('default', 'download', args=row.image)}} in my view I'm just getting a string. Perhaps because the file was not saved to this directory? On Wednesday, December 5, 2012 2:25:57 PM UTC, Anthony wrote: You do not specify the uploads directory in the URL. Instead, you need to define a function that calls response.download() and pass the filename to that function via the last URL argument (i.e., request.args[-1]). In fact, this function is already provided for you in the welcome app: def download(): allows downloading of uploaded files http:///[app]/default/download/[filename] return response.download(request,db) So, your URL should be URL('default', 'download', args=row.image). This is discussed herehttp://web2py.com/books/default/chapter/29/03#An-image-blog, here http://web2py.com/books/default/chapter/29/07#SQLFORM-and-uploads, here http://web2py.com/books/default/chapter/29/04#response, and herehttp://www.web2py.com/examples/default/examples#database_examples(example 33). Anthony On Wednesday, December 5, 2012 9:06:57 AM UTC-5, Daniele wrote: Guys I know this sounds simple but I'm having a hard time displaying uploaded images. I have an upload field in my model where logged in users can upload an image. But in my views when I try to do {{=IMG(_src=URL('uploads/', row.image))}} where row is a variable that refers to db(db.auth_user.id 0).select() nothing is being returned. However, row.image returns a string which is the name of the file. How can I display the image correctly? Thanks! --
Re: [web2py] Re: Displaying an image
hmm still not working. I think it's because I set the upload directory to uploads/profiles/ so it's not finding the image. Maybe if I change that setting it will work... On Wed, Dec 5, 2012 at 5:43 PM, Niphlod niph...@gmail.com wrote: ehm in html you need to do img src=/something/photo.png /. {{=URL('default', 'download', args=row.image)}} is just the portion to put into the img tag as the src's attribute value {{=IMG( _src=URL('default', 'download', args=row.image) ) }} is the right one! On Wednesday, December 5, 2012 6:36:10 PM UTC+1, Daniele wrote: I have def download(): return response.download(request,db) in my controller. But when I put {{=URL('default', 'download', args=row.image)}} in my view I'm just getting a string. Perhaps because the file was not saved to this directory? On Wednesday, December 5, 2012 2:25:57 PM UTC, Anthony wrote: You do not specify the uploads directory in the URL. Instead, you need to define a function that calls response.download() and pass the filename to that function via the last URL argument (i.e., request.args[-1]). In fact, this function is already provided for you in the welcome app: def download(): allows downloading of uploaded files http:///[app]/default/**download/[filename] return response.download(request,db) So, your URL should be URL('default', 'download', args=row.image). This is discussed herehttp://web2py.com/books/default/chapter/29/03#An-image-blog, here http://web2py.com/books/default/chapter/29/07#SQLFORM-and-uploads, here http://web2py.com/books/default/chapter/29/04#response, and herehttp://www.web2py.com/examples/default/examples#database_examples(example 33). Anthony On Wednesday, December 5, 2012 9:06:57 AM UTC-5, Daniele wrote: Guys I know this sounds simple but I'm having a hard time displaying uploaded images. I have an upload field in my model where logged in users can upload an image. But in my views when I try to do {{=IMG(_src=URL('uploads/', row.image))}} where row is a variable that refers to db(db.auth_user.id 0).select() nothing is being returned. However, row.image returns a string which is the name of the file. How can I display the image correctly? Thanks! -- --
Re: [web2py] Re: Displaying an image
Yeah I checked my controller and it's uploading images to Field('image', 'upload', uploadfolder=os.path.join(request.folder,'uploads/profiles/') Is there a default directory where the download() function wants images to be? On Wed, Dec 5, 2012 at 5:55 PM, Daniele Pestilli byakugan...@gmail.comwrote: hmm still not working. I think it's because I set the upload directory to uploads/profiles/ so it's not finding the image. Maybe if I change that setting it will work... On Wed, Dec 5, 2012 at 5:43 PM, Niphlod niph...@gmail.com wrote: ehm in html you need to do img src=/something/photo.png /. {{=URL('default', 'download', args=row.image)}} is just the portion to put into the img tag as the src's attribute value {{=IMG( _src=URL('default', 'download', args=row.image) ) }} is the right one! On Wednesday, December 5, 2012 6:36:10 PM UTC+1, Daniele wrote: I have def download(): return response.download(request,db) in my controller. But when I put {{=URL('default', 'download', args=row.image)}} in my view I'm just getting a string. Perhaps because the file was not saved to this directory? On Wednesday, December 5, 2012 2:25:57 PM UTC, Anthony wrote: You do not specify the uploads directory in the URL. Instead, you need to define a function that calls response.download() and pass the filename to that function via the last URL argument (i.e., request.args[-1]). In fact, this function is already provided for you in the welcome app: def download(): allows downloading of uploaded files http:///[app]/default/**download/[filename] return response.download(request,db) So, your URL should be URL('default', 'download', args=row.image). This is discussed herehttp://web2py.com/books/default/chapter/29/03#An-image-blog, herehttp://web2py.com/books/default/chapter/29/07#SQLFORM-and-uploads, here http://web2py.com/books/default/chapter/29/04#response, and herehttp://www.web2py.com/examples/default/examples#database_examples(example 33). Anthony On Wednesday, December 5, 2012 9:06:57 AM UTC-5, Daniele wrote: Guys I know this sounds simple but I'm having a hard time displaying uploaded images. I have an upload field in my model where logged in users can upload an image. But in my views when I try to do {{=IMG(_src=URL('uploads/', row.image))}} where row is a variable that refers to db(db.auth_user.id 0).select() nothing is being returned. However, row.image returns a string which is the name of the file. How can I display the image correctly? Thanks! -- --
[web2py] Re: Displaying an image
Hmm for some reason it's not working for me. I took a look at the source code and this is the HTML that is being generated: img src=/download/image.a6e29a6f36771685.e58699e79c9f2e4a5047.JPG view-source:http://127.0.0.1:8000/download/tutor.image.a6e29a6f36771685.e58699e79c9f2e4a5047.JPG / And this is what I have in my view that is generating that code: {{=IMG(_src=URL('default', 'download', args=row.image))}} so it seems to be taking the 'download' directory and looking for the image there, but as aforementioned, I've set the directory for these images to be in: Field('image', 'upload', uploadfolder=os.path.join(request.folder,'uploads/profiles/') Should I just change the view to read URL('uploads/profiles/', 'download', args=row.image) or would that be an inelegant solution? On Wednesday, December 5, 2012 2:06:57 PM UTC, Daniele wrote: Guys I know this sounds simple but I'm having a hard time displaying uploaded images. I have an upload field in my model where logged in users can upload an image. But in my views when I try to do {{=IMG(_src=URL('uploads/', row.image))}} where row is a variable that refers to db(db.auth_user.id 0).select() nothing is being returned. However, row.image returns a string which is the name of the file. How can I display the image correctly? Thanks! --
[web2py] Re: Check if a from's boolean is true or false from the controller
OK. So I removed what I had before (tables in a database) and moved to SQLFORM.factory. I now have this in my controller: form = SQLFORM.factory( Field('is_tutor', 'boolean'), Field('image', 'upload', requires=IS_EMPTY_OR(IS_IMAGE(extensions=('jpeg', 'jpg', 'png', 'gif', Field('location', 'list:string', requires=IS_NOT_EMPTY()), Field('subjects', 'list:string', requires=IS_NOT_EMPTY()), Field('qualifications', 'list:string', requires=IS_NOT_EMPTY()), Field('biography', 'string', length=500), Field('hourly_rate', 'decimal(7,2)', requires=IS_NOT_EMPTY()), Field('modified_on', 'datetime', requires=IS_DATETIME(), writable=False, readable=False, default=request.utcnow), table_name='tutor') so when the form is submitted, I now need to check if the field is_tutor is True. If it is, I need to add that info to the current logged user's information. Do I need to modify auth to do this? If so, how? On Monday, December 3, 2012 3:16:45 PM UTC, Niphlod wrote: if it's checked the corresponding var would be True. If the form is submitted the controller will receive that field as request.vars.fieldname or as form.vars.fieldname if you are using a form. When you get to the form.process() line the value has been already been shipped to the database. You must act before: there is the onvalidation callback (but it's generally used for other things, like additional validation). If you want to skip form processing at all (and possibly doing some other custom logic) you can rely either on SQLFORM with process(dbio=False) or with SQLFORM.factory. in either case you'll have to build (or not, depending on the checkbox) the corresponding create/update record by hand (not so hard with e.g. SQLFORM.factory because generally your form.vars would be ready to be inserted into the table if the form has the same structure of the table itself, e.g. db.table.insert(**form.vars)) On Monday, December 3, 2012 3:27:29 PM UTC+1, Daniele wrote: Hey guys, I'm wondering if there's a way from the controller to know whether a form's boolean field (checkbox) is selected or not. I only want to add the info in the form to the database if the checkbox is selected, otherwise the controller should not process that form. Thanks! --
[web2py] Re: Check if a from's boolean is true or false from the controller
Thanks that was super helpful! On Tuesday, December 4, 2012 4:31:08 PM UTC, Niphlod wrote: if form.process().accepted: if form.vars.is_tutor: ...whatever, e.g. db.table.insert(**form.vars) How do you structure your db to save this data is up to your application: if you need this stored next to the auth_user table the recommended way is extending auth_user with auth.settings.extra_fields On Tuesday, December 4, 2012 5:21:59 PM UTC+1, Daniele wrote: OK. So I removed what I had before (tables in a database) and moved to SQLFORM.factory. I now have this in my controller: form = SQLFORM.factory( Field('is_tutor', 'boolean'), Field('image', 'upload', requires=IS_EMPTY_OR(IS_IMAGE(extensions=('jpeg', 'jpg', 'png', 'gif', Field('location', 'list:string', requires=IS_NOT_EMPTY()), Field('subjects', 'list:string', requires=IS_NOT_EMPTY()), Field('qualifications', 'list:string', requires=IS_NOT_EMPTY()), Field('biography', 'string', length=500), Field('hourly_rate', 'decimal(7,2)', requires=IS_NOT_EMPTY()), Field('modified_on', 'datetime', requires=IS_DATETIME(), writable=False, readable=False, default=request.utcnow), table_name='tutor') so when the form is submitted, I now need to check if the field is_tutor is True. If it is, I need to add that info to the current logged user's information. Do I need to modify auth to do this? If so, how? On Monday, December 3, 2012 3:16:45 PM UTC, Niphlod wrote: if it's checked the corresponding var would be True. If the form is submitted the controller will receive that field as request.vars.fieldname or as form.vars.fieldname if you are using a form. When you get to the form.process() line the value has been already been shipped to the database. You must act before: there is the onvalidation callback (but it's generally used for other things, like additional validation). If you want to skip form processing at all (and possibly doing some other custom logic) you can rely either on SQLFORM with process(dbio=False) or with SQLFORM.factory. in either case you'll have to build (or not, depending on the checkbox) the corresponding create/update record by hand (not so hard with e.g. SQLFORM.factory because generally your form.vars would be ready to be inserted into the table if the form has the same structure of the table itself, e.g. db.table.insert(**form.vars)) On Monday, December 3, 2012 3:27:29 PM UTC+1, Daniele wrote: Hey guys, I'm wondering if there's a way from the controller to know whether a form's boolean field (checkbox) is selected or not. I only want to add the info in the form to the database if the checkbox is selected, otherwise the controller should not process that form. Thanks! --
[web2py] Re: Check if a from's boolean is true or false from the controller
Another question has come to mind...I have the following code in my controller now: if tform.process().accepted: if tform.vars.is_tutor: auth.add_membership('Tutors') db.auth_user.insert( a_bunch_of_fields = tform.vars.a_bunch_of_fields) else: # check if the user has membership first auth.del_membership('Tutors') db.auth_user.delete() In the last line, db.auth_user.delete(), I'd like to delete all the fields in the database that I'd write if the is_tutor boolean is checked. But I'm wondering, I'd have to specify that it only needs to delete these for the logged in user. How can I do this? Also, is deleting the correct thing to do or should I just reset the values to a default, like or None ? Thanks On Monday, December 3, 2012 2:27:29 PM UTC, Daniele wrote: Hey guys, I'm wondering if there's a way from the controller to know whether a form's boolean field (checkbox) is selected or not. I only want to add the info in the form to the database if the checkbox is selected, otherwise the controller should not process that form. Thanks! --
[web2py] Re: Check if a from's boolean is true or false from the controller
And the same goes for db.auth_user.insert() ... does it imply the logged user or not? On Monday, December 3, 2012 2:27:29 PM UTC, Daniele wrote: Hey guys, I'm wondering if there's a way from the controller to know whether a form's boolean field (checkbox) is selected or not. I only want to add the info in the form to the database if the checkbox is selected, otherwise the controller should not process that form. Thanks! --
Re: [web2py] Re: Check if a from's boolean is true or false from the controller
How can I blank out all the **form.vars in the event that the form.vars.is_tutor returns false? Is there a simple way to do this or should I manually put in None for all the fields? On Tue, Dec 4, 2012 at 8:16 PM, Niphlod niph...@gmail.com wrote: depends on where do you use that kind of logic. If the user is already logged, you need to UPDATE the corresponding auth_user row with the data inserted, something among the lines of db(db.auth_user.id == auth.user_id).update(**form.vars) If instead you are requesting the user to fill that form without being logged already, you'd need to CREATE the row, so you should use insertin that case you should also ask for username/email and the password. summary: form.vars holds a dictionary composed of fieldname -- values. Both .insert() and .update() take a dictionary, in which case the columns corresponding to a table are updated/created with the correct values. On Tuesday, December 4, 2012 8:34:31 PM UTC+1, Daniele wrote: And the same goes for db.auth_user.insert() ... does it imply the logged user or not? On Monday, December 3, 2012 2:27:29 PM UTC, Daniele wrote: Hey guys, I'm wondering if there's a way from the controller to know whether a form's boolean field (checkbox) is selected or not. I only want to add the info in the form to the database if the checkbox is selected, otherwise the controller should not process that form. Thanks! -- --
Re: [web2py] Re: Check if a from's boolean is true or false from the controller
There's some problem with what I'm doing now. I have form = SQLFORM.factory() with all the fields in my controller. In my db.py file, I am extending auth with auth.settings.extra_fields['auth_user']= [ Field http://127.0.0.1:8000/examples/global/vars/Field('t_image'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_location'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_subjects'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_qualifications'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_biography'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_hourly_rate'), Field http://127.0.0.1:8000/examples/global/vars/Field('t_modified_on'), Field http://127.0.0.1:8000/examples/global/vars/Field('s_location')] However, when I visit the page I am getting a bunch of 'None' fields without input boxes. Am I supposed to somehow put the SQLFORM.factory info in my db.py file? I can't understand why it's doing this... On Wed, Dec 5, 2012 at 12:49 AM, Daniele Pestilli byakugan...@gmail.comwrote: How can I blank out all the **form.vars in the event that the form.vars.is_tutor returns false? Is there a simple way to do this or should I manually put in None for all the fields? On Tue, Dec 4, 2012 at 8:16 PM, Niphlod niph...@gmail.com wrote: depends on where do you use that kind of logic. If the user is already logged, you need to UPDATE the corresponding auth_user row with the data inserted, something among the lines of db(db.auth_user.id == auth.user_id).update(**form.vars) If instead you are requesting the user to fill that form without being logged already, you'd need to CREATE the row, so you should use insertin that case you should also ask for username/email and the password. summary: form.vars holds a dictionary composed of fieldname -- values. Both .insert() and .update() take a dictionary, in which case the columns corresponding to a table are updated/created with the correct values. On Tuesday, December 4, 2012 8:34:31 PM UTC+1, Daniele wrote: And the same goes for db.auth_user.insert() ... does it imply the logged user or not? On Monday, December 3, 2012 2:27:29 PM UTC, Daniele wrote: Hey guys, I'm wondering if there's a way from the controller to know whether a form's boolean field (checkbox) is selected or not. I only want to add the info in the form to the database if the checkbox is selected, otherwise the controller should not process that form. Thanks! -- --
[web2py] Check if a from's boolean is true or false from the controller
Hey guys, I'm wondering if there's a way from the controller to know whether a form's boolean field (checkbox) is selected or not. I only want to add the info in the form to the database if the checkbox is selected, otherwise the controller should not process that form. Thanks! --
[web2py] Re: Hide form and erase input
A combination of the two. Since I use bootstrap, I edited the html in the view, but i also added some parameters to the custom form in the controller, such as form['_class'] = form-horizontal On Sunday, December 2, 2012 2:29:57 AM UTC, Julian Sanchez wrote: Just curious... did you end up using a completely custom form or were you able to manipulate the SQLFORM inside the controller? On Saturday, December 1, 2012 7:03:33 AM UTC-6, Daniele wrote: I ended up putting them in separate divs and hiding the entire div. Works like a charm! Thanks guys On Thursday, November 29, 2012 4:44:50 PM UTC, Anthony wrote: The easiest way is probably via a custom form: http://web2py.com/books/default/chapter/29/07#Custom-forms. Another option -- each table row or div containing a field input has an id that starts with [tablename]_, so you could use a jQuery selector like: jQuery('[id^=tutor_]').hide() That will hide all table rows whose id's start with tutor_, which should be all the field inputs in the form. Anthony On Thursday, November 29, 2012 11:07:46 AM UTC-5, Daniele wrote: I could do that. Would I need to add the div directly in the controller or the view? My controller looks something like this now: def mypage(): form = SQLFORM(db.mytable) return dict(form=form) I guess there should be a way to edit the SQLFORM to add an extra div? Thanks guys On Thursday, November 29, 2012 3:50:25 PM UTC, Anthony wrote: Maybe you could put all the fields inside a div and then hide/show the whole div. Anthony On Thursday, November 29, 2012 7:45:22 AM UTC-5, Daniele wrote: Hmm, that gets rid of the input boxes but not of the fieldnames as well. I guess I'll have to do it manually for each field. On Thursday, November 29, 2012 9:40:29 AM UTC, Niphlod wrote: $(:input) ? On Thursday, November 29, 2012 2:29:46 AM UTC+1, Daniele wrote: Hello all :) I have a db.define_table that defines a particular role and all its fields. One of the fields is a boolean, which will display as a checkbox in the SQLFORM. What I'd like to do is hide ALL the elements in the SQLFORM if the radiobutton is unchecked, and show all the elements if it's checked. So I have something like this: script jQuery(document).ready(function(){ jQuery('#tutor_biography__row').hide(); jQuery('#tutor_is_tutor').change(function(){ if(jQuery('#tutor_is_tutor').attr('checked')) jQuery('#tutor_biography__row').show(); else jQuery('#tutor_biography__row').hide();}); }); /script What I'd like to do is not just hide one field, but hide all the fields if the radio button is unclicked. Is there a shortcut to do this or must I input all the rows manually? Also, another thing I'd like to add in the jQuery is, if the radio button was checked, filled out, and then unchecked, I want the values to not be stored but to be erased. I assume I'd have to add something like .val('') but I'm not sure where to do that. Thanks! --
[web2py] Re: Proper way to reference logged user
OK I think that's probably the easiest solution for now. How can I do this? Do I need to add auth.add_group('role', 'description') in my db.py file and then have a form that when a user submits, runs auth.add_membership(group_id, user_id) in the controller? Or do both of these go inside the controller? I guess the groups only need to be created once, which is why I am assuming the first line goes in db.py Thanks On Saturday, December 1, 2012 6:11:24 PM UTC, villas wrote: Put everyone in the auth_user table and use groups. That could save you heaps of time down the line. Otherwise I can imagine you'll start reinventing what's already available to you in web2py. Use the framework and the force will be with you! If you need to keep lots of different info depending on what group they are in, then you can always think about splitting that into different tables, but only as a last resort. Best wishes for your app, D On Saturday, 1 December 2012 13:13:13 UTC, Daniele wrote: Hmmm that's one option, but here's the problem. Basically, I want users to sign up very easily. So I'm just using web2py's default auth for that. Then, I'd like them to pick if they are tutors/students or both. There is additional information they'd have to input in some forms for both roles. While I could just create two groups, the way I have it now as tutors are a table and students are another table in the database. I guess I'm a bit lost as to how the correct way to let the signed up users be either students/tutors or both is. Should it all be part of the signed up users table? Or should I have three tables? Should I just make groups? Any advice is much appreciated, Thanks! On Friday, November 23, 2012 7:24:42 PM UTC, Joe Barnhart wrote: Why not create a group for each class -- tutor and student -- and assign group membership for each student? A student can participate in more than one group. It's easy to test for group membership -- just use the decorator: @auth.requires_membership('tutor') -- Joe B. On Tuesday, November 20, 2012 5:57:57 PM UTC-8, Daniele wrote: I am trying to build a model where each logged user can decide if he/she is a tutor or student or both. So the tutor table has to 'reference auth.settings.table_user_name' and student also has to have the same reference. The tutor/student/logged user have to be related by their id key I imagine. Is this the proper way to go about this? Moreover, how can I check that the relationship is working? --
[web2py] Re: Proper way to reference logged user
Alright I've created the two groups with the web2py appadmin interface. Now I suppose the rest of the logic goes in the controller. I have a SQLFORM right now but it probably makes more sense to just use a FORM, right? And then when that is processed, I can run the command auth.add_membership(group_id, user_id) Am I on the money or is this incorrect? Thanks guys :D On Sunday, December 2, 2012 1:27:26 PM UTC, Daniele wrote: OK I think that's probably the easiest solution for now. How can I do this? Do I need to add auth.add_group('role', 'description') in my db.py file and then have a form that when a user submits, runs auth.add_membership(group_id, user_id) in the controller? Or do both of these go inside the controller? I guess the groups only need to be created once, which is why I am assuming the first line goes in db.py Thanks On Saturday, December 1, 2012 6:11:24 PM UTC, villas wrote: Put everyone in the auth_user table and use groups. That could save you heaps of time down the line. Otherwise I can imagine you'll start reinventing what's already available to you in web2py. Use the framework and the force will be with you! If you need to keep lots of different info depending on what group they are in, then you can always think about splitting that into different tables, but only as a last resort. Best wishes for your app, D On Saturday, 1 December 2012 13:13:13 UTC, Daniele wrote: Hmmm that's one option, but here's the problem. Basically, I want users to sign up very easily. So I'm just using web2py's default auth for that. Then, I'd like them to pick if they are tutors/students or both. There is additional information they'd have to input in some forms for both roles. While I could just create two groups, the way I have it now as tutors are a table and students are another table in the database. I guess I'm a bit lost as to how the correct way to let the signed up users be either students/tutors or both is. Should it all be part of the signed up users table? Or should I have three tables? Should I just make groups? Any advice is much appreciated, Thanks! On Friday, November 23, 2012 7:24:42 PM UTC, Joe Barnhart wrote: Why not create a group for each class -- tutor and student -- and assign group membership for each student? A student can participate in more than one group. It's easy to test for group membership -- just use the decorator: @auth.requires_membership('tutor') -- Joe B. On Tuesday, November 20, 2012 5:57:57 PM UTC-8, Daniele wrote: I am trying to build a model where each logged user can decide if he/she is a tutor or student or both. So the tutor table has to 'reference auth.settings.table_user_name' and student also has to have the same reference. The tutor/student/logged user have to be related by their id key I imagine. Is this the proper way to go about this? Moreover, how can I check that the relationship is working? --
Re: [web2py] Re: Proper way to reference logged user
Hmm I'm still confused. Sorry guys. So the way I'm displaying the two forms is through two tables in the database that I've defined. Consequently, in the controller I have something like form = SQLFORM(db.tutor) Below that I will have something like if form.process().accepted: If not auth.has_membership(group): auth.add_membership(group) However, one of the elements in the form is a checkbox. If that box is unchecked, it needs to remove the user from the group. How can I check whether the checkbox is checked or not from the controller? Also, since the tables are defined in the database, this will all be going into two other tables. I don't think this is the right behavior though... On Dec 2, 2012, at 3:34 PM, lyn2py lyn...@gmail.com wrote: You can still use SQLFORM, and append additional fields. The code is here: http://web2py.com/books/default/chapter/29/07#Adding-extra-form-elements-to-SQLFORM You need to add code to ensure that the user is being added to the particular groups under form.process(). form=SQLFORM(db.table) //additional elements to add to the form goes here if form.process().accepted: // add them to the relevant group here response.flash = 'record inserted' On Sunday, December 2, 2012 9:35:38 PM UTC+8, Daniele wrote: Alright I've created the two groups with the web2py appadmin interface. Now I suppose the rest of the logic goes in the controller. I have a SQLFORM right now but it probably makes more sense to just use a FORM, right? And then when that is processed, I can run the command auth.add_membership(group_id, user_id) Am I on the money or is this incorrect? Thanks guys :D On Sunday, December 2, 2012 1:27:26 PM UTC, Daniele wrote: OK I think that's probably the easiest solution for now. How can I do this? Do I need to add auth.add_group('role', 'description') in my db.py file and then have a form that when a user submits, runs auth.add_membership(group_id, user_id) in the controller? Or do both of these go inside the controller? I guess the groups only need to be created once, which is why I am assuming the first line goes in db.py Thanks On Saturday, December 1, 2012 6:11:24 PM UTC, villas wrote: Put everyone in the auth_user table and use groups. That could save you heaps of time down the line. Otherwise I can imagine you'll start reinventing what's already available to you in web2py. Use the framework and the force will be with you! If you need to keep lots of different info depending on what group they are in, then you can always think about splitting that into different tables, but only as a last resort. Best wishes for your app, D On Saturday, 1 December 2012 13:13:13 UTC, Daniele wrote: Hmmm that's one option, but here's the problem. Basically, I want users to sign up very easily. So I'm just using web2py's default auth for that. Then, I'd like them to pick if they are tutors/students or both. There is additional information they'd have to input in some forms for both roles. While I could just create two groups, the way I have it now as tutors are a table and students are another table in the database. I guess I'm a bit lost as to how the correct way to let the signed up users be either students/tutors or both is. Should it all be part of the signed up users table? Or should I have three tables? Should I just make groups? Any advice is much appreciated, Thanks! On Friday, November 23, 2012 7:24:42 PM UTC, Joe Barnhart wrote: Why not create a group for each class -- tutor and student -- and assign group membership for each student? A student can participate in more than one group. It's easy to test for group membership -- just use the decorator: @auth.requires_membership('tutor') -- Joe B. On Tuesday, November 20, 2012 5:57:57 PM UTC-8, Daniele wrote: I am trying to build a model where each logged user can decide if he/she is a tutor or student or both. So the tutor table has to 'reference auth.settings.table_user_name' and student also has to have the same reference. The tutor/student/logged user have to be related by their id key I imagine. Is this the proper way to go about this? Moreover, how can I check that the relationship is working? -- --
[web2py] Re: Hide form and erase input
I ended up putting them in separate divs and hiding the entire div. Works like a charm! Thanks guys On Thursday, November 29, 2012 4:44:50 PM UTC, Anthony wrote: The easiest way is probably via a custom form: http://web2py.com/books/default/chapter/29/07#Custom-forms. Another option -- each table row or div containing a field input has an id that starts with [tablename]_, so you could use a jQuery selector like: jQuery('[id^=tutor_]').hide() That will hide all table rows whose id's start with tutor_, which should be all the field inputs in the form. Anthony On Thursday, November 29, 2012 11:07:46 AM UTC-5, Daniele wrote: I could do that. Would I need to add the div directly in the controller or the view? My controller looks something like this now: def mypage(): form = SQLFORM(db.mytable) return dict(form=form) I guess there should be a way to edit the SQLFORM to add an extra div? Thanks guys On Thursday, November 29, 2012 3:50:25 PM UTC, Anthony wrote: Maybe you could put all the fields inside a div and then hide/show the whole div. Anthony On Thursday, November 29, 2012 7:45:22 AM UTC-5, Daniele wrote: Hmm, that gets rid of the input boxes but not of the fieldnames as well. I guess I'll have to do it manually for each field. On Thursday, November 29, 2012 9:40:29 AM UTC, Niphlod wrote: $(:input) ? On Thursday, November 29, 2012 2:29:46 AM UTC+1, Daniele wrote: Hello all :) I have a db.define_table that defines a particular role and all its fields. One of the fields is a boolean, which will display as a checkbox in the SQLFORM. What I'd like to do is hide ALL the elements in the SQLFORM if the radiobutton is unchecked, and show all the elements if it's checked. So I have something like this: script jQuery(document).ready(function(){ jQuery('#tutor_biography__row').hide(); jQuery('#tutor_is_tutor').change(function(){ if(jQuery('#tutor_is_tutor').attr('checked')) jQuery('#tutor_biography__row').show(); else jQuery('#tutor_biography__row').hide();}); }); /script What I'd like to do is not just hide one field, but hide all the fields if the radio button is unclicked. Is there a shortcut to do this or must I input all the rows manually? Also, another thing I'd like to add in the jQuery is, if the radio button was checked, filled out, and then unchecked, I want the values to not be stored but to be erased. I assume I'd have to add something like .val('') but I'm not sure where to do that. Thanks! --
[web2py] Re: Proper way to reference logged user
Hmmm that's one option, but here's the problem. Basically, I want users to sign up very easily. So I'm just using web2py's default auth for that. Then, I'd like them to pick if they are tutors/students or both. There is additional information they'd have to input in some forms for both roles. While I could just create two groups, the way I have it now as tutors are a table and students are another table in the database. I guess I'm a bit lost as to how the correct way to let the signed up users be either students/tutors or both is. Should it all be part of the signed up users table? Or should I have three tables? Should I just make groups? Any advice is much appreciated, Thanks! On Friday, November 23, 2012 7:24:42 PM UTC, Joe Barnhart wrote: Why not create a group for each class -- tutor and student -- and assign group membership for each student? A student can participate in more than one group. It's easy to test for group membership -- just use the decorator: @auth.requires_membership('tutor') -- Joe B. On Tuesday, November 20, 2012 5:57:57 PM UTC-8, Daniele wrote: I am trying to build a model where each logged user can decide if he/she is a tutor or student or both. So the tutor table has to 'reference auth.settings.table_user_name' and student also has to have the same reference. The tutor/student/logged user have to be related by their id key I imagine. Is this the proper way to go about this? Moreover, how can I check that the relationship is working? --
[web2py] Re: Hide form and erase input
Hmm, that gets rid of the input boxes but not of the fieldnames as well. I guess I'll have to do it manually for each field. On Thursday, November 29, 2012 9:40:29 AM UTC, Niphlod wrote: $(:input) ? On Thursday, November 29, 2012 2:29:46 AM UTC+1, Daniele wrote: Hello all :) I have a db.define_table that defines a particular role and all its fields. One of the fields is a boolean, which will display as a checkbox in the SQLFORM. What I'd like to do is hide ALL the elements in the SQLFORM if the radiobutton is unchecked, and show all the elements if it's checked. So I have something like this: script jQuery(document).ready(function(){ jQuery('#tutor_biography__row').hide(); jQuery('#tutor_is_tutor').change(function(){ if(jQuery('#tutor_is_tutor').attr('checked')) jQuery('#tutor_biography__row').show(); else jQuery('#tutor_biography__row').hide();}); }); /script What I'd like to do is not just hide one field, but hide all the fields if the radio button is unclicked. Is there a shortcut to do this or must I input all the rows manually? Also, another thing I'd like to add in the jQuery is, if the radio button was checked, filled out, and then unchecked, I want the values to not be stored but to be erased. I assume I'd have to add something like .val('') but I'm not sure where to do that. Thanks! --
[web2py] Re: Hide form and erase input
I could do that. Would I need to add the div directly in the controller or the view? My controller looks something like this now: def mypage(): form = SQLFORM(db.mytable) return dict(form=form) I guess there should be a way to edit the SQLFORM to add an extra div? Thanks guys On Thursday, November 29, 2012 3:50:25 PM UTC, Anthony wrote: Maybe you could put all the fields inside a div and then hide/show the whole div. Anthony On Thursday, November 29, 2012 7:45:22 AM UTC-5, Daniele wrote: Hmm, that gets rid of the input boxes but not of the fieldnames as well. I guess I'll have to do it manually for each field. On Thursday, November 29, 2012 9:40:29 AM UTC, Niphlod wrote: $(:input) ? On Thursday, November 29, 2012 2:29:46 AM UTC+1, Daniele wrote: Hello all :) I have a db.define_table that defines a particular role and all its fields. One of the fields is a boolean, which will display as a checkbox in the SQLFORM. What I'd like to do is hide ALL the elements in the SQLFORM if the radiobutton is unchecked, and show all the elements if it's checked. So I have something like this: script jQuery(document).ready(function(){ jQuery('#tutor_biography__row').hide(); jQuery('#tutor_is_tutor').change(function(){ if(jQuery('#tutor_is_tutor').attr('checked')) jQuery('#tutor_biography__row').show(); else jQuery('#tutor_biography__row').hide();}); }); /script What I'd like to do is not just hide one field, but hide all the fields if the radio button is unclicked. Is there a shortcut to do this or must I input all the rows manually? Also, another thing I'd like to add in the jQuery is, if the radio button was checked, filled out, and then unchecked, I want the values to not be stored but to be erased. I assume I'd have to add something like .val('') but I'm not sure where to do that. Thanks! --
[web2py] Re: Changing auth validator error messages
I'd also like to change that error message value already in database or empty as I find it a pointless message. But I tried with db.auth_user.email.requires[0].error_message = T(The email you have entered has already been registered.) and it doesn't seem to change anything. Am I misplacing this? I put it in the db.py file after the auth.define_tables(username=False, signature=False) Thanks On Monday, September 17, 2012 3:21:00 AM UTC+1, Mark Li wrote: Is it possible to change the validator error messages in for auth fields like value already in database or empty, without having to redefine all the validators for that field? For example, I wanted to change the validator error message for IS_NOT_IN_DB for auth_user.email, and I wrote: db.auth_user.email.requires=IS_NOT_IN_DB(db, auth_user.email,error_message =T(Email already in use)) Would I have to define all the validators for auth_user.email now? Is there a less intrusive way of changing the error message without overriding the default validators for auth? --
[web2py] Re: Changing auth validator error messages
Thanks, that did the trick! On Thursday, November 29, 2012 12:30:31 AM UTC, Mark Li wrote: db.auth_user.email.requires[1].error_message = T(The email you have entered has already been registered.) Try using the index of 1, not 0. On Wednesday, November 28, 2012 4:55:54 PM UTC, Daniele wrote: I'd also like to change that error message value already in database or empty as I find it a pointless message. But I tried with db.auth_user.email.requires[0].error_message = T(The email you have entered has already been registered.) and it doesn't seem to change anything. Am I misplacing this? I put it in the db.py file after the auth.define_tables(username=False, signature=False) Thanks On Monday, September 17, 2012 3:21:00 AM UTC+1, Mark Li wrote: Is it possible to change the validator error messages in for auth fields like value already in database or empty, without having to redefine all the validators for that field? For example, I wanted to change the validator error message for IS_NOT_IN_DB for auth_user.email, and I wrote: db.auth_user.email.requires=IS_NOT_IN_DB(db, auth_user.email,error_message =T(Email already in use)) Would I have to define all the validators for auth_user.email now? Is there a less intrusive way of changing the error message without overriding the default validators for auth? --
[web2py] Re: web3py?
I really believe web2py will indeed become the rails for python as someone mentioned. Actually, I believe it's much better, easier to use and comprehend, and more pleasant to develop in. That said, I agree web2py needs to reach a critical mass of users because as of now, it's too hard to get the support to even simple answers, which sometime require days to be answered on google groups. A much wider user base would rapidly solve this problem quite naturally. I think the solution to this would be word of mouth: more users need to use web2py and spread the word of how good it is by mere word of mouth. It's possible, I believe the project can really outshine all the other python web frameworks. On Tuesday, November 27, 2012 4:39:06 AM UTC, User wrote: I noticed a thread over in web2py-developers web3py - important!https://groups.google.com/forum/?fromgroups=#!topic/web2py-developers/RCeiRd3Rzs0 which was exciting to read. I've flirted with web2py and there's a lot that I like about it. For some reason I find web2py exciting whereas django doesn't provide that. I've used Yii on the php side which is great framework as far as php goes and asp.net mvc which is great as well. I'd love to work with python but the main thing making me hesitate with web2py is critical mass. It seems like it wouldn't be hard for web2py to really dominate the python web framework space if some of the core criticisms were addressed. I'm not fully up to speed on what they are but I usually hear about unit testing and global variables. It feels like there is a roadblock preventing the project from skyrocketing. Python needs a rails. I understand that the design decisions are by choice with pros and cons. My questions are: 1. Will web3py likely address these often repeated core criticisms? (I saw point 5 from the thread linked to above: 5) No more global environment. Apps will do from web3py import * (see below)) 2. The developer thread is over in the developers section. Will you have a more open forum for users (as opposed to developers) to have input on web3py? --
[web2py] Hide form and erase input
Hello all :) I have a db.define_table that defines a particular role and all its fields. One of the fields is a boolean, which will display as a checkbox in the SQLFORM. What I'd like to do is hide ALL the elements in the SQLFORM if the radiobutton is unchecked, and show all the elements if it's checked. So I have something like this: script jQuery(document).ready(function(){ jQuery('#tutor_biography__row').hide(); jQuery('#tutor_is_tutor').change(function(){ if(jQuery('#tutor_is_tutor').attr('checked')) jQuery('#tutor_biography__row').show(); else jQuery('#tutor_biography__row').hide();}); }); /script What I'd like to do is not just hide one field, but hide all the fields if the radio button is unclicked. Is there a shortcut to do this or must I input all the rows manually? Also, another thing I'd like to add in the jQuery is, if the radio button was checked, filled out, and then unchecked, I want the values to not be stored but to be erased. I assume I'd have to add something like .val('') but I'm not sure where to do that. Thanks! --
[web2py] Re: How to get register_next to move on to the desired URL
Yes I have that already. I'm starting to think that the problem is with my controller, not with the db.py settings. Maybe my controller is not actually registering the users? Here's the controller for the signup: def signup(): if auth.is_logged_in(): redirect http://127.0.0.1:8000/examples/global/vars/redirect(URL http://127.0.0.1:8000/examples/global/vars/URL('dashboard')) response http://127.0.0.1:8000/examples/global/vars/response.subtitle = T http://127.0.0.1:8000/examples/global/vars/T(Sign up) form = SQLFORM http://127.0.0.1:8000/examples/global/vars/SQLFORM(auth.settings.table_user, separator = '', _class='form-horizontal') if form.process().accepted: mail.send('em...@gmail.com', 'Message subject', 'Plain text body of the message') return dict(form=form) On Saturday, November 24, 2012 3:45:09 AM UTC, Anthony wrote: Does the dashboard page require login? If so, that's why it is redirecting to the login page. If you want the user to be logged in automatically after registration, you can do: auth.settings.login_after_registration = True Anthony On Friday, November 23, 2012 8:34:01 AM UTC-5, Daniele wrote: I still cannot get this to work. Any tips? On Sunday, November 18, 2012 10:51:14 PM UTC, Daniele wrote: Hey guys, I would like to set register_next to move on to a URL upon successful registration. However, it seems to be redirecting me to the login page right now. I believe this is because I have @auth.requires_login() def mypage: in the controller. How can I make it so that when a user registers, the page automatically is redirected to a page I specify? Thanks! --
[web2py] Re: How to get register_next to move on to the desired URL
I still cannot get this to work. Any tips? On Sunday, November 18, 2012 10:51:14 PM UTC, Daniele wrote: Hey guys, I would like to set register_next to move on to a URL upon successful registration. However, it seems to be redirecting me to the login page right now. I believe this is because I have @auth.requires_login() def mypage: in the controller. How can I make it so that when a user registers, the page automatically is redirected to a page I specify? Thanks! --
[web2py] Email upon registration not working
Hello all, I'm wondering why I cannot get the email upon registration to work. I've finally gotten basic emailing to work, but it doesn't seem to send anything automatically upon user registration. Here's my db.py file: from gluon.tools import Auth, Crud, Service, PluginManager, prettydate auth = Auth(db) crud, service, plugins = Crud(db), Service(), PluginManager() ## Auth db.define_table( auth.settings.table_user_name, Field http://127.0.0.1:8000/examples/global/vars/Field('email', length=128, default=''), Field http://127.0.0.1:8000/examples/global/vars/Field('password', 'password', length=512, readable=False), Field http://127.0.0.1:8000/examples/global/vars/Field('password_verify', 'password', length=512, readable=False), Field http://127.0.0.1:8000/examples/global/vars/Field('registration_time', 'datetime', requires=IS_DATETIME http://127.0.0.1:8000/examples/global/vars/IS_DATETIME(), writable=False, readable=False, default=request http://127.0.0.1:8000/examples/global/vars/request.utcnow), Field http://127.0.0.1:8000/examples/global/vars/Field('registration_key', length=512, writable=False, readable=False, default=''), Field http://127.0.0.1:8000/examples/global/vars/Field('registration_id', length=512, writable=False, readable=False, default='') ) custom_auth_table = db[auth.settings.table_user_name] custom_auth_table.email.requires = [ IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY(error_message='Please input an email address'), IS_EMAIL http://127.0.0.1:8000/examples/global/vars/IS_EMAIL(error_message=auth.messages.invalid_email), IS_NOT_IN_DB http://127.0.0.1:8000/examples/global/vars/IS_NOT_IN_DB(db, custom_auth_table.email)] custom_auth_table.password.requires = [ IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY(error_message='Please type a password'), IS_STRONG http://127.0.0.1:8000/examples/global/vars/IS_STRONG(min=8, special=0, upper=1), CRYPT http://127.0.0.1:8000/examples/global/vars/CRYPT()] custom_auth_table.password_verify.requires = [ IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY(error_message='Please retype your password'), IS_EQUAL_TO http://127.0.0.1:8000/examples/global/vars/IS_EQUAL_TO(request http://127.0.0.1:8000/examples/global/vars/request.vars.password, error_message='Passwords do not match'), CRYPT http://127.0.0.1:8000/examples/global/vars/CRYPT()] auth.settings.table_user = custom_auth_table # tell auth to use custom_auth_table ## create all tables needed by auth if not custom tables auth.define_tables(username=False, signature=False) # configure auth settings auth.settings.long_expiration = 3600*24*30 # one month auth.settings.remember_me_form = True ## configure auth policy auth.settings.registration_requires_verification = True auth.settings.login_after_registration = True auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True auth.messages.verify_email = 'Click on the link http://' + \ request http://127.0.0.1:8000/examples/global/vars/request.env.http_host + \ URL http://127.0.0.1:8000/examples/global/vars/URL(r=request http://127.0.0.1:8000/examples/global/vars/request,f='user',args=['verify_email']) + \ '/%(key)s to verify your email' auth.messages.reset_password = 'Click on the link http://' + \ request http://127.0.0.1:8000/examples/global/vars/request.env.http_host + \ URL http://127.0.0.1:8000/examples/global/vars/URL(r=request http://127.0.0.1:8000/examples/global/vars/request,f='user',args=['reset_password']) + \ '/%(key)s to reset your password' auth.settings.register_next = URL http://127.0.0.1:8000/examples/global/vars/URL('dashboard') auth.settings.login_url = URL http://127.0.0.1:8000/examples/global/vars/URL('login') auth.settings.login_next = URL http://127.0.0.1:8000/examples/global/vars/URL('dashboard') auth.settings.logout_next = URL http://127.0.0.1:8000/examples/global/vars/URL('index') Any help would be greatly appreciated! --
[web2py] Re: Email upon registration not working
Yes, basic emailing is working, and I do have that code in my db.py file. So if I do mail.send('email', 'title', 'body') it works. The reason I had so much trouble with this was because I set up my app using the wizard. The wizard created another file called 0.py (great name) that was overwriting my mail.settings variables (great design decision). Anyways, after two days of banging my head against the desk I finally got emailing to work but now I can't get automated emailing upon user registration to work. Any suggestions? On Friday, November 23, 2012 5:54:49 PM UTC, Massimo Di Pierro wrote: To send emails you need to connect an SMTP server. For example, to send emails using your google mail account mail = auth.settings.mailer mail.settings.server = 'smtp.gmail.com:587' mail.settings.sender = 'y...@gmail.com javascript:' mail.settings.login = 'y...@gmail.com:password' Do you have similar code? On Friday, 23 November 2012 09:26:57 UTC-6, Daniele wrote: Hello all, I'm wondering why I cannot get the email upon registration to work. I've finally gotten basic emailing to work, but it doesn't seem to send anything automatically upon user registration. Here's my db.py file: from gluon.tools import Auth, Crud, Service, PluginManager, prettydate auth = Auth(db) crud, service, plugins = Crud(db), Service(), PluginManager() ## Auth db.define_table( auth.settings.table_user_name, Field http://127.0.0.1:8000/examples/global/vars/Field('email', length=128, default=''), Field http://127.0.0.1:8000/examples/global/vars/Field('password', 'password', length=512, readable=False), Field http://127.0.0.1:8000/examples/global/vars/Field('password_verify', 'password', length=512, readable=False), Field http://127.0.0.1:8000/examples/global/vars/Field('registration_time', 'datetime', requires=IS_DATETIME http://127.0.0.1:8000/examples/global/vars/IS_DATETIME(), writable=False, readable=False, default=request http://127.0.0.1:8000/examples/global/vars/request.utcnow), Field http://127.0.0.1:8000/examples/global/vars/Field('registration_key', length=512, writable=False, readable=False, default=''), Field http://127.0.0.1:8000/examples/global/vars/Field('registration_id', length=512, writable=False, readable=False, default='') ) custom_auth_table = db[auth.settings.table_user_name] custom_auth_table.email.requires = [ IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY(error_message='Please input an email address'), IS_EMAIL http://127.0.0.1:8000/examples/global/vars/IS_EMAIL(error_message=auth.messages.invalid_email), IS_NOT_IN_DB http://127.0.0.1:8000/examples/global/vars/IS_NOT_IN_DB(db, custom_auth_table.email)] custom_auth_table.password.requires = [ IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY(error_message='Please type a password'), IS_STRONG http://127.0.0.1:8000/examples/global/vars/IS_STRONG(min=8, special=0, upper=1), CRYPT http://127.0.0.1:8000/examples/global/vars/CRYPT()] custom_auth_table.password_verify.requires = [ IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY(error_message='Please retype your password'), IS_EQUAL_TO http://127.0.0.1:8000/examples/global/vars/IS_EQUAL_TO(request http://127.0.0.1:8000/examples/global/vars/request.vars.password, error_message='Passwords do not match'), CRYPT http://127.0.0.1:8000/examples/global/vars/CRYPT()] auth.settings.table_user = custom_auth_table # tell auth to use custom_auth_table ## create all tables needed by auth if not custom tables auth.define_tables(username=False, signature=False) # configure auth settings auth.settings.long_expiration = 3600*24*30 # one month auth.settings.remember_me_form = True ## configure auth policy auth.settings.registration_requires_verification = True auth.settings.login_after_registration = True auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True auth.messages.verify_email = 'Click on the link http://' + \ request http://127.0.0.1:8000/examples/global/vars/request.env.http_host + \ URL http://127.0.0.1:8000/examples/global/vars/URL(r=request http://127.0.0.1:8000/examples/global/vars/request,f='user',args=['verify_email']) + \ '/%(key)s to verify your email' auth.messages.reset_password = 'Click on the link http://' + \ request http://127.0.0.1:8000/examples/global/vars/request.env.http_host + \ URL http://127.0.0.1:8000/examples/global/vars/URL(r=request http://127.0.0.1:8000/examples/global/vars/request,f='user',args=['reset_password']) + \ '/%(key)s to reset your password' auth.settings.register_next = URL http://127.0.0.1:8000/examples/global/vars/URL('dashboard') auth.settings.login_url = URL http://127.0.0.1:8000/examples/global/vars/URL
[web2py] Re: Unable to send email in web2py
Yeah I log into the account every day so there's no problem there. I am trying to set the setting mail.settings.server = 'logging' but I do not know where it logs the messages...does anyone know where I'd find them? On Wednesday, November 21, 2012 7:32:26 PM UTC, Daniele wrote: I'm trying to send emails upon user registration. This is what I have in my models file: mail = auth.settings.mailer mail.settings.server = 'smtp.gmail.com:587' mail.settings.sender = 'em...@gmail.com' #There's a proper email here mail.settings.login = 'username:password' #There's a proper username/password combination here auth.settings.registration_requires_verification = True auth.messages.verify_email = 'Click on the link http://' + request.env.http_host + URL(r=request,f='user',args=['verify_email']) + '/%(key)s to verify your email' mail.settings.server = settings.email_server mail.settings.sender = settings.email_sender mail.settings.login = settings.email_login But every time I register a user with a valid email address, I'm getting no email. So I'm trying to do it manually with: mail.send('em...@gmail.com', 'Message subject', 'Plain text body of the message') But I'm getting an error message in the terminal that says: WARNING:web2py:Mail.send failure:[Errno 111] Connection refused How can I fix this??? --
[web2py] Re: Unable to send email in web2py
Still doesn't work. I'm starting to wonder if this isn't a problem with the fact that I have a custom signup page? On Wednesday, November 21, 2012 7:32:26 PM UTC, Daniele wrote: I'm trying to send emails upon user registration. This is what I have in my models file: mail = auth.settings.mailer mail.settings.server = 'smtp.gmail.com:587' mail.settings.sender = 'em...@gmail.com' #There's a proper email here mail.settings.login = 'username:password' #There's a proper username/password combination here auth.settings.registration_requires_verification = True auth.messages.verify_email = 'Click on the link http://' + request.env.http_host + URL(r=request,f='user',args=['verify_email']) + '/%(key)s to verify your email' mail.settings.server = settings.email_server mail.settings.sender = settings.email_sender mail.settings.login = settings.email_login But every time I register a user with a valid email address, I'm getting no email. So I'm trying to do it manually with: mail.send('em...@gmail.com', 'Message subject', 'Plain text body of the message') But I'm getting an error message in the terminal that says: WARNING:web2py:Mail.send failure:[Errno 111] Connection refused How can I fix this??? --
[web2py] Re: Unable to send email in web2py
I am trying with my mail account from Bluehost. I'm following their instructions and still can't get it to work. I've tried so many different combinations I believe I've exhausted all possible solutions. I'm starting to think this is a bug with web2py... On Wednesday, November 21, 2012 7:32:26 PM UTC, Daniele wrote: I'm trying to send emails upon user registration. This is what I have in my models file: mail = auth.settings.mailer mail.settings.server = 'smtp.gmail.com:587' mail.settings.sender = 'em...@gmail.com' #There's a proper email here mail.settings.login = 'username:password' #There's a proper username/password combination here auth.settings.registration_requires_verification = True auth.messages.verify_email = 'Click on the link http://' + request.env.http_host + URL(r=request,f='user',args=['verify_email']) + '/%(key)s to verify your email' mail.settings.server = settings.email_server mail.settings.sender = settings.email_sender mail.settings.login = settings.email_login But every time I register a user with a valid email address, I'm getting no email. So I'm trying to do it manually with: mail.send('em...@gmail.com', 'Message subject', 'Plain text body of the message') But I'm getting an error message in the terminal that says: WARNING:web2py:Mail.send failure:[Errno 111] Connection refused How can I fix this??? --
[web2py] Re: Unable to send email in web2py
Ok I got basic emailing to work. Here's what the problem was: When I made my project, I used the wizard. The wizard created a file called 0.py (GREAT NAME) that was overriding my mail.settings.* variables. So no matter how I set them, they'd get overwritten with things like ' ' Anyways, the basic e-mailing seems to work now. What doesn't work is the e-mail upon registration, which I set with auth.settings.registration_requires_verification = True auth.messages.verify_email = 'Click on the link http://' + \ request http://127.0.0.1:8000/examples/global/vars/request.env.http_host + \ URL http://127.0.0.1:8000/examples/global/vars/URL(r=request http://127.0.0.1:8000/examples/global/vars/request,f='user',args=['verify_email']) + \ '/%(key)s to verify your email' Are these values also being overwritten somewhere that you guys know of?? Thanks P.S. What a poor design decision to have mail.settings in the db.py file, then at the bottom have them reference another variable in a file called 0.pyseriously?? On Wednesday, November 21, 2012 7:32:26 PM UTC, Daniele wrote: I'm trying to send emails upon user registration. This is what I have in my models file: mail = auth.settings.mailer mail.settings.server = 'smtp.gmail.com:587' mail.settings.sender = 'em...@gmail.com' #There's a proper email here mail.settings.login = 'username:password' #There's a proper username/password combination here auth.settings.registration_requires_verification = True auth.messages.verify_email = 'Click on the link http://' + request.env.http_host + URL(r=request,f='user',args=['verify_email']) + '/%(key)s to verify your email' mail.settings.server = settings.email_server mail.settings.sender = settings.email_sender mail.settings.login = settings.email_login But every time I register a user with a valid email address, I'm getting no email. So I'm trying to do it manually with: mail.send('em...@gmail.com', 'Message subject', 'Plain text body of the message') But I'm getting an error message in the terminal that says: WARNING:web2py:Mail.send failure:[Errno 111] Connection refused How can I fix this??? --
[web2py] Re: Login error messages
Hiding the error is not my point. I want an error message when the user inputs an invalid email/password combination. However, the error message should just say something like Email or password invalid. It shouldn't be running the same check as it does when a user registers a password... On Wednesday, November 21, 2012 12:22:46 AM UTC, Daniele wrote: For some reason, I am not getting the right error messages to display on my login form. Right now, I'm getting the same errors that one should get upon registration, such as: Minimum length is 8 Must include at least 1 upper case Must include at least 1 number However, this is giving away too many clues for a mere login. I just want the message to say password or email incorrect or something along those lines. How can I do this? --
[web2py] Unable to send email in web2py
I'm trying to send emails upon user registration. This is what I have in my models file: mail = auth.settings.mailer mail.settings.server = 'smtp.gmail.com:587' mail.settings.sender = 'em...@gmail.com' #There's a proper email here mail.settings.login = 'username:password' #There's a proper username/password combination here auth.settings.registration_requires_verification = True auth.messages.verify_email = 'Click on the link http://' + request.env.http_host + URL(r=request,f='user',args=['verify_email']) + '/%(key)s to verify your email' mail.settings.server = settings.email_server mail.settings.sender = settings.email_sender mail.settings.login = settings.email_login But every time I register a user with a valid email address, I'm getting no email. How can I debug this? --
[web2py] Re: Unable to send email in web2py
I just tried port 25 as recommended on google's FAQ (http://support.google.com/mail/bin/answer.py?hl=enanswer=78775) Still nothing. I'm wondering how can I debug this? Is there a log file of what's happening behind the scenes here? On Wednesday, November 21, 2012 7:32:26 PM UTC, Daniele wrote: I'm trying to send emails upon user registration. This is what I have in my models file: mail = auth.settings.mailer mail.settings.server = 'smtp.gmail.com:587' mail.settings.sender = 'em...@gmail.com' #There's a proper email here mail.settings.login = 'username:password' #There's a proper username/password combination here auth.settings.registration_requires_verification = True auth.messages.verify_email = 'Click on the link http://' + request.env.http_host + URL(r=request,f='user',args=['verify_email']) + '/%(key)s to verify your email' mail.settings.server = settings.email_server mail.settings.sender = settings.email_sender mail.settings.login = settings.email_login But every time I register a user with a valid email address, I'm getting no email. So I'm trying to do it manually with: mail.send('em...@gmail.com', 'Message subject', 'Plain text body of the message') But I'm getting an error message in the terminal that says: WARNING:web2py:Mail.send failure:[Errno 111] Connection refused How can I fix this??? --
[web2py] Re: custom built login form
Thanks that seems to have worked. This was totally undocumented (or if it was, it was in an obscure place because I looked quite hard for how to do this.) What does that XML(%s %s % (form.tag, form._xml()[0])) line do exactly? Also, say I want to style the button now...how can I do that? On Wednesday, August 15, 2012 6:51:12 AM UTC+1, shartha wrote: Hello, Quick question: Instead of {{=auth.login()}}, I am using the following to be able to customize my login form. However the resulting form does not work and I cannot login with the same username/password that enable me to login if I had used {{=auth.login()}} -- I get the flash error: Invalid Login. Could someone please tell me what's possibly going wrong? Thanks! {{form=auth.login()}} {{=form.custom.begin}} Username: {{=form.custom.widget.username}} /br Password: {{=form.custom.widget.password}} {{=form.custom.submit}} {{=form.custom.end}} --
[web2py] Login error messages
For some reason, I am not getting the right error messages to display on my login form. Right now, I'm getting the same errors that one should get upon registration, such as: Minimum length is 8 Must include at least 1 upper case Must include at least 1 number However, this is giving away too many clues for a mere login. I just want the message to say password or email incorrect or something along those lines. How can I do this? --
[web2py] Proper way to reference logged user
I am trying to build a model where each logged user can decide if he/she is a tutor or student or both. So the tutor table has to 'reference auth.settings.table_user_name' and student also has to have the same reference. The tutor/student/logged user have to be related by their id key I imagine. Is this the proper way to go about this? Moreover, how can I check that the relationship is working? --
[web2py] Re: Time of registration
Massimo, thanks for the reply. I wasn't able to get it working with what you said but this seems to have done the trick instead: Field('registration_time', 'datetime', requires=IS_DATETIME(), writable=False, readable=False, default=request.utcnow), essentially, the requires field seems to have done some magic that the other fields weren't doing. Thanks! On Saturday, November 17, 2012 6:57:19 PM UTC, Massimo Di Pierro wrote: Field('registration_time', 'datetime') is you want the user to fill it in: Field('registration_time', 'datetime', default=request.now, writable=False, readable=False) to make it automatic. On Friday, 16 November 2012 15:44:17 UTC-6, Daniele wrote: Guys I'm wondering when I get someone to register, I'd like to have a field in my database for the datetime. In my db.py file, I have a Field('registration_time', 'datetime') However, how do I pass in that the time (now) is supposed to be taken when the user submits the form?? I'm a bit confused about this. Thanks! --
[web2py] Re: How to get register_next to move on to the desired URL
I had already tried that but it doesn't seem to be working for me. Could this be because I am using a custom sign up form? The registration is working properly though, which is odd... On Monday, November 19, 2012 4:45:52 PM UTC, peter wrote: # Instructions: Copy all of this into your db.py, and make the one change in layout.html # Solution: how to have a user redirected to a page AFTER register # in this example, the URL('user/profile') will be used. # app name: AuthRedirect - just a NEW application, with no modication # web2py Version 2.2.1 (2012-10-21 16:57:04) stable # - - - - - # in layout.html view, modify the line: # ul id=navbar class=nav pull-right{{='auth' in globals() and auth.navbar(mode=dropdown) or ''}}/ul # to # ul id=navbar class=nav pull-right{{='auth' in globals() and auth.navbar(mode=dropdown,referrer_actions=None) or ''}}/ul # this will cause the URL not to display # http://127.0.0.1:8000/AuthRedirect/default/user/login?_next=/AuthRedirect/default/index # but rather # http://127.0.0.1:8000/AuthRedirect/default/user/ # - - - - - # one line of CODE BELOW placed in : # /models/db.py - located BELOW the setting under ## configure auth policy lines auth.settings.register_next = URL('user/profile') Peter On Sunday, 18 November 2012 22:51:14 UTC, Daniele wrote: Hey guys, I would like to set register_next to move on to a URL upon successful registration. However, it seems to be redirecting me to the login page right now. I believe this is because I have @auth.requires_login() def mypage: in the controller. How can I make it so that when a user registers, the page automatically is redirected to a page I specify? Thanks! --
[web2py] Re: How to get register_next to move on to the desired URL
Here's my registration form: db.define_table( auth.settings.table_user_name, Field http://127.0.0.1:8000/examples/global/vars/Field('email', length=128, default=''), Field http://127.0.0.1:8000/examples/global/vars/Field('password', 'password', length=512, readable=False), Field http://127.0.0.1:8000/examples/global/vars/Field('password_verify', 'password', length=512, readable=False), Field http://127.0.0.1:8000/examples/global/vars/Field('registration_time', 'datetime', requires=IS_DATETIME http://127.0.0.1:8000/examples/global/vars/IS_DATETIME(), writable=False, readable=False, default=request http://127.0.0.1:8000/examples/global/vars/request.utcnow), Field http://127.0.0.1:8000/examples/global/vars/Field('registration_key', length=512, writable=False, readable=False, default=''), Field http://127.0.0.1:8000/examples/global/vars/Field('registration_id', length=512, writable=False, readable=False, default='') ) custom_auth_table = db[auth.settings.table_user_name] #get the custom_auth_table custom_auth_table.email.requires = [ IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY(error_message='Please input an email address'), IS_EMAIL http://127.0.0.1:8000/examples/global/vars/IS_EMAIL(error_message=auth.messages.invalid_email), IS_NOT_IN_DB http://127.0.0.1:8000/examples/global/vars/IS_NOT_IN_DB(db, custom_auth_table.email)] custom_auth_table.password.requires = [ IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY(error_message='Please type a password'), IS_STRONG http://127.0.0.1:8000/examples/global/vars/IS_STRONG(min=8, special=0, upper=1), CRYPT http://127.0.0.1:8000/examples/global/vars/CRYPT()] custom_auth_table.password_verify.requires = [ IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY(error_message='Please retype your password'), IS_EQUAL_TO http://127.0.0.1:8000/examples/global/vars/IS_EQUAL_TO(request http://127.0.0.1:8000/examples/global/vars/request.vars.password, error_message='Passwords do not match'), CRYPT http://127.0.0.1:8000/examples/global/vars/CRYPT()] auth.settings.table_user = custom_auth_table # tell auth to use custom_auth_table ## create all tables needed by auth if not custom tables auth.define_tables(username=False, signature=False) auth.settings.registration_requires_verification = True #To automatically login people after registration, even if they have not completed the email verification process, set the following to True auth.settings.login_after_registration = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True auth.messages.verify_email = 'Click on the link http://' + \ request http://127.0.0.1:8000/examples/global/vars/request.env.http_host + \ URL http://127.0.0.1:8000/examples/global/vars/URL(r=request http://127.0.0.1:8000/examples/global/vars/request,f='user',args=['verify_email']) + \ '/%(key)s to verify your email' auth.messages.reset_password = 'Click on the link http://' + \ request http://127.0.0.1:8000/examples/global/vars/request.env.http_host + \ URL http://127.0.0.1:8000/examples/global/vars/URL(r=request http://127.0.0.1:8000/examples/global/vars/request,f='user',args=['reset_password']) + \ '/%(key)s to reset your password' auth.settings.register_next = URL http://127.0.0.1:8000/examples/global/vars/URL('dashboard') auth.settings.login_url = URL http://127.0.0.1:8000/examples/global/vars/URL('login') auth.settings.login_next = URL http://127.0.0.1:8000/examples/global/vars/URL('dashboard') auth.settings.logout_next = URL http://127.0.0.1:8000/examples/global/vars/URL('index') but when I try registering a new user, it does not redirect to the dashboard as I'd like it to. On Sunday, November 18, 2012 10:51:14 PM UTC, Daniele wrote: Hey guys, I would like to set register_next to move on to a URL upon successful registration. However, it seems to be redirecting me to the login page right now. I believe this is because I have @auth.requires_login() def mypage: in the controller. How can I make it so that when a user registers, the page automatically is redirected to a page I specify? Thanks! --
[web2py] Re: changing the look of a form
You're going to have to change the style via CSS. If it's an inbuilt form in web2py like the login one, good luck :P you will have to use the custom form widgets and do a bunch of somersaults. Try following this guide, it may help: http://web2py.com/book/default/chapter/07#FORM On Wednesday, November 14, 2012 8:58:45 PM UTC, Hector Magnanao wrote: how do you change the look of a form (i.e. background color, fonts, etc...) ? --
[web2py] Re: custom built login form
Ah ok I just took a look at the HTML and saw that my code conflicts with what web2py is generating. Basically there's a form within a form being constructed, so it looks like this: form class=form-horizontalform action= enctype=multipart/form-data method=post To avoid this, how can I tell web2py that the login form's style has to be form-horizontal? That way it can generate the HTML automagically. On Wednesday, August 15, 2012 6:51:12 AM UTC+1, shartha wrote: Hello, Quick question: Instead of {{=auth.login()}}, I am using the following to be able to customize my login form. However the resulting form does not work and I cannot login with the same username/password that enable me to login if I had used {{=auth.login()}} -- I get the flash error: Invalid Login. Could someone please tell me what's possibly going wrong? Thanks! {{form=auth.login()}} {{=form.custom.begin}} Username: {{=form.custom.widget.username}} /br Password: {{=form.custom.widget.password}} {{=form.custom.submit}} {{=form.custom.end}} --
[web2py] How to get register_next to move on to the desired URL
Hey guys, I would like to set register_next to move on to a URL upon successful registration. However, it seems to be redirecting me to the login page right now. I believe this is because I have @auth.requires_login() def mypage: in the controller. How can I make it so that when a user registers, the page automatically is redirected to a page I specify? Thanks! --
[web2py] Encrypting password verify
I have a field in my register form for verifying the password, as such: Field http://127.0.0.1:8000/examples/global/vars/Field('password', 'password', length=512, readable=False), Field http://127.0.0.1:8000/examples/global/vars/Field('password_verify', 'password', length=512, readable=False, requires=CRYPT http://127.0.0.1:8000/examples/global/vars/CRYPT(digest_alg='sha512')) Even though I added requires CRYPT, this field gets stored as the user's actual password (without any encryption). I take it this is not a good thing. How can I encrypt even the verify password field on my registration form? Thanks --
[web2py] Re: custom built login form
I'm having a similar problem. I am making a custom form with this code in the view: {{=form.custom.begin}} div class=control-group {{if form.errors['email']:}}error{{pass}} label class=control-label for=inputEmailEmail address/label div class=controls {{=form.custom.widget.email}} /div /div div class=control-group {{if form.errors['password']:}}error{{pass}} label class=control-label for=inputPasswordPassword/label div class=controls {{=form.custom.widget.password}} /div /div div class=control-group div class=controls label class=checkbox input id=auth_user_remember class=checkbox type=checkbox value=on name=remember Remember me (for 30 days) /labelbr {{=form.custom.submit}} /div /div {{=form.custom.end}} But this does not log me in for some reason. If I use just {{=form}} here, it does login as it's supposed to. My controller looks like this: def login(): if auth.is_logged_in(): redirect(URL('dashboard')) response.subtitle = T(Login) return dict(form=auth.login()) I can't figure out why it's not logging me in with the custom form.. On Wednesday, August 15, 2012 6:51:12 AM UTC+1, shartha wrote: Hello, Quick question: Instead of {{=auth.login()}}, I am using the following to be able to customize my login form. However the resulting form does not work and I cannot login with the same username/password that enable me to login if I had used {{=auth.login()}} -- I get the flash error: Invalid Login. Could someone please tell me what's possibly going wrong? Thanks! {{form=auth.login()}} {{=form.custom.begin}} Username: {{=form.custom.widget.username}} /br Password: {{=form.custom.widget.password}} {{=form.custom.submit}} {{=form.custom.end}} --
[web2py] Time of registration
Guys I'm wondering when I get someone to register, I'd like to have a field in my database for the datetime. In my db.py file, I have a Field('registration_time', 'datetime') However, how do I pass in that the time (now) is supposed to be taken when the user submits the form?? I'm a bit confused about this. Thanks! --
[web2py] response.flash not displaying
I cannot get response.flash to display for the life of me...I'm using a vanilla version of the latest twitter bootstrap and have the following in my style.css (which I took verbatim from web2py's css file) div.flash { font-weight:bold; display:none; position:fixed; padding:10px; top:48px; right:50px; min-width:280px; opacity:0.95; margin:0px 0px 10px 10px; vertical-align:middle; cursor:pointer; color:#fff; background-color:#000; border:2px solid #fff; border-radius:8px; -o-border-radius: 8px; -moz-border-radius:8px; -webkit-border-radius:8px; background-image: -webkit-linear-gradient(top,#222,#000); background-image: -o-linear-gradient(top,#222,#000); background-image: -moz-linear-gradient(90deg, #222, #000); background-image: linear-gradient(top,#222,#000); background-repeat: repeat-x; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; z-index:2000; } div.flash:hover { opacity:0.25; } div.flash.flash-center{left:25%;right:25%;} div.flash.flash-top,div.flash.flash-top:hover{ position:relative; display:block; margin:0; padding:1em; top:0; left:0; width:100%; text-align:center; text-shadow:0 1px 0 rgba(255, 255, 255, 0.5); color:#865100; background:#feea9a; border:1px solid; border-top:0px; border-left:0px; border-right:0px; border-radius:0; opacity:1; } However, when I put something like response.flash = Hello in my controller, nothing shows up. What the heck I don't even know how to start debugging this problemNothing is being printed when I view page source either, so something on web2py's part seems to not be functioning correctly. Anyone have some insight about this?? --
[web2py] Re: step-by step instructions installing web2py on a CentOS server with cPanel installed
Bump! I'd also like to see a guide on how to do this. On Friday, January 21, 2011 9:18:12 PM UTC, stargate wrote: I as wondering if there is step-by step instructions installing web2py on a CentOS version 4.x server with cPanel installed. --
[web2py] Re: Retype password: None
Hmm I can't figure out how to get the entropy check on a custom form. I'm using a vanilla Twitter Bootstrap without all the web2py stuff because it was breaking my layout. Is there a way to get password entropy check on custom forms with plain Twitter Bootstrap css files?? On Monday, November 12, 2012 4:52:53 PM UTC, Daniele wrote: Once I have the class, how can I get the jQuery entropy check for password strength to change the background color? Again, this is on a custom form so I'm having quite some trouble with this... On Monday, November 12, 2012 3:51:48 PM UTC, Massimo Di Pierro wrote: form.element(name='email').add_class('test') On Sunday, 11 November 2012 21:03:04 UTC-6, Daniele wrote: I am writing a custom registration form. I noticed that in the controller, if I put def signup(): return dict(form=auth.register()) I get a Retype password field. However, if I put def signup(): form = SQLFORM(auth.settings.table_user, labels = {'email':'Email address'}, submit_button = 'Sign up', separator = '', _class='form-horizontal') return dict(form=form) I get None for the Retype password field. How can I fix this? Also, how can I specify the class of the fields and buttons?? Thanks! --
[web2py] Retype password: None
I am writing a custom registration form. I noticed that in the controller, if I put def signup(): return dict(form=auth.register()) I get a Retype password field. However, if I put def signup(): form = SQLFORM(auth.settings.table_user, labels = {'email':'Email address'}, submit_button = 'Sign up', separator = '', _class='form-horizontal') return dict(form=form) I get None for the Retype password field. How can I fix this? Also, how can I specify the class of the fields and buttons?? Thanks! --
[web2py] Re: Retype password: None
Once I have the class, how can I get the jQuery entropy check for password strength to change the background color? Again, this is on a custom form so I'm having quite some trouble with this... On Monday, November 12, 2012 3:51:48 PM UTC, Massimo Di Pierro wrote: form.element(name='email').add_class('test') On Sunday, 11 November 2012 21:03:04 UTC-6, Daniele wrote: I am writing a custom registration form. I noticed that in the controller, if I put def signup(): return dict(form=auth.register()) I get a Retype password field. However, if I put def signup(): form = SQLFORM(auth.settings.table_user, labels = {'email':'Email address'}, submit_button = 'Sign up', separator = '', _class='form-horizontal') return dict(form=form) I get None for the Retype password field. How can I fix this? Also, how can I specify the class of the fields and buttons?? Thanks! --
[web2py] web2py woes
I just started using web2py and am having lots of trouble with things that I think should be quite simple. I will enumerate them here in the hopes they can be answered: 1) I had made a design in Twitter bootstrap 2.2.1 which was working fine as a plain .html file. I saw that web2py used an older version of bootstrap so I replaced the defauly boostrap.min.css with the latest version. Upon uploading my views, everything seemed to work fine. However, when I switched from one page to the next I realized that the container size was changing. I finally discovered that changing the {{if left_sidebar_enabled:}} to {{if not left_sidebar_enabled:}} or {{if right_sidebar_enabled:}} to {{if not right_sidebar_enabled:}} solved the container problem: every page remained the same width. What gives? How can I prevent having to check whether the sidebar is there in order to get my templates to all format nicely? 2) With the vanilla Twitter bootstrap 2.2.1, my thumbnails class was leaving a nice padding between thumbnails. Now, it's not. Is this a problem with the web2.py css files?? 3) How can I get rid of the annoying page.com/default/goal structure? I just would like to have page.com/goal 4) The navbar by default has an Index link. How can I get rid of it? I don't see any index in the layout.html file so I don't know where this is coming from. Thanks in advance!!! --