[web2py] Making a field non-editable, but writable using SQLFORM

2011-06-16 Thread Jay Shaffstall
I have a situation where I need to adjust an SQLFORM field to be
non-editable.  I can do that with .writable = False, but that seems to
also prevents database I/O for that field.  What I'm trying to do is
set a default that cannot be changed.

Is there a way to set an SQLFORM field so that it appears as a label
on the form itself, but is still writable for the database?

For reference, I'm doing this with a field in the form returned by
auth.register, so I cannot insert code between the form creation and
the accepts call.  I believe I'm restricted to working with the model
before calling auth.register, or by using custom forms.

Jay


Re: [web2py] Making a field non-editable, but writable using SQLFORM

2011-06-16 Thread Jay Shaffstall
That doesn't seem to affect the HTML form output at all for me.  I've
also tried changing the widget to LABEL, but that results in the same
problem with the value not being transmitted back via the form.

What I'd like to be able to do is set the readonly attribute of the
input tag; but I don't know how to do that in this context, where I
cannot insert code between the creation on the SQLFORM and the accepts
call.

Jay

On Thu, Jun 16, 2011 at 2:21 PM, Bruno Rocha rochacbr...@gmail.com wrote:

 Sorry, I answered before read entire message,
 if you want to chamhe it in form only, better to use the 'represent'
 attribute
 db.table.field.represent = lambda f: label %s /label % f

 --
 Bruno Rocha
 [ About me: http://zerp.ly/rochacbruno ]



 On Thu, Jun 16, 2011 at 3:05 PM, Jay Shaffstall jshaffst...@gmail.com
 wrote:

 I have a situation where I need to adjust an SQLFORM field to be
 non-editable.  I can do that with .writable = False, but that seems to
 also prevents database I/O for that field.  What I'm trying to do is
 set a default that cannot be changed.

 Is there a way to set an SQLFORM field so that it appears as a label
 on the form itself, but is still writable for the database?

 For reference, I'm doing this with a field in the form returned by
 auth.register, so I cannot insert code between the form creation and
 the accepts call.  I believe I'm restricted to working with the model
 before calling auth.register, or by using custom forms.

 Jay




Re: [web2py] Re: Making a field non-editable, but writable using SQLFORM

2011-06-16 Thread Jay Shaffstall
I'd been thinking I needed to do that between form creation and the
accepts call, but you're right, it works even after that point.  I
make the call to auth.register, and then modify the readonly
attribute, and it works fine.

Thanks!
Jay

On Thu, Jun 16, 2011 at 5:06 PM, DenesL denes1...@yahoo.ca wrote:

 Jay, you can do:

 form.element('#tablename_fieldname')['_readonly']=True


 On Jun 16, 2:57 pm, Jay Shaffstall jshaffst...@gmail.com wrote:
 That doesn't seem to affect the HTML form output at all for me.  I've
 also tried changing the widget to LABEL, but that results in the same
 problem with the value not being transmitted back via the form.

 What I'd like to be able to do is set the readonly attribute of the
 input tag; but I don't know how to do that in this context, where I
 cannot insert code between the creation on the SQLFORM and the accepts
 call.

 Jay







 On Thu, Jun 16, 2011 at 2:21 PM, Bruno Rocha rochacbr...@gmail.com wrote:

  Sorry, I answered before read entire message,
  if you want to chamhe it in form only, better to use the 'represent'
  attribute
  db.table.field.represent = lambda f: label %s /label % f

  --
  Bruno Rocha
  [ About me: http://zerp.ly/rochacbruno ]

  On Thu, Jun 16, 2011 at 3:05 PM, Jay Shaffstall jshaffst...@gmail.com
  wrote:

  I have a situation where I need to adjust an SQLFORM field to be
  non-editable.  I can do that with .writable = False, but that seems to
  also prevents database I/O for that field.  What I'm trying to do is
  set a default that cannot be changed.

  Is there a way to set an SQLFORM field so that it appears as a label
  on the form itself, but is still writable for the database?

  For reference, I'm doing this with a field in the form returned by
  auth.register, so I cannot insert code between the form creation and
  the accepts call.  I believe I'm restricted to working with the model
  before calling auth.register, or by using custom forms.

  Jay


[web2py] Controller specific models

2011-06-15 Thread Jay Shaffstall
I've been unable to get my controller specific model to work in
1.96.4.  Here's what I've got set up, can anyone point out the error?

Controller: email.py, in app/controllers/email.py
Model: email/settings.py in app/models/email/settings.py

My understanding is that email/settings.py should be run for any page
invoked in email.py.  That isn't happening (verified with a print
statement, just to make sure something else weird wasn't going on).

Alternatively, if anyone has an example app that demonstrates using
controller specific models, I can try running that to see if I've
somehow broken web2py.

Thanks,
Jay


[web2py] Changing columns for TEXTAREA

2011-05-18 Thread Jay Shaffstall
I thought this might have gotten lost in the philosophical discussions
about line breaks, so figured I'd post it as a separate thread:

Using the advice given in a previous post, I'm doing this to try to
change the rows and columns for a TEXTAREA:

form=SQLFORM(db.contest,record=contest,submit_button=T(Save
Changes),fields=[name,description],_style='width:100%')

form.element('textarea')['_rows']=30
form.element('textarea')['_cols']=80

This works, in that the HTML output does have cols=80 and rows=30.
 And the number of rows does change appropriately.

However, the number of columns displayed for the textarea does not
change, despite the HTML having the right value.

Is there something else that could be overriding the number of
columns?  Something in Javascript perhaps?

Jay


[web2py] Two questions: one about markmin and one about SQLFORM

2011-05-16 Thread Jay Shaffstall
I've searched, but not found any information that helps me at my
current level of web2py experience.

Question 1: how do you insert a single line break (e.g. br/) in
markmin?  I've seen two spaces at the end of lines, but that doesn't
seem to work for me.  I've seen that you can use br as a separator
instead of p, but that isn't what I want.  I just want to put a
single line break in specific spots in the content.

Question 2: How can I alter the attributes of form elements using
SLQFORM?  Specifically, I want to change the number of rows and
columns in a textarea, but I could see wanting to alter attributes of
any form element.  The answer is probably to create a custom widget
for the field in the model, but I haven't been able to come up with
anything that has any effect.