[web2py] Re: Reverse Search with .like

2010-05-07 Thread Russell
You might want to try something like this:.

from gluon.sql import Expression
db(table1.field1.like(Expression("('%' || table2.field2 ||
'%')".select(db.table1.field1)

Not very pretty, but it does work.


On May 8, 9:13 am, mdipierro  wrote:
> Can you try
>
> from gluon.sql import Query
> print db(Query(" '%' || NEW.field_1 || '%'  LIKE table_1.field_1
> "))._select(db.table_1.field_1)
>
> Do you get the query you want?
>
> On May 7, 10:48 am, AsmanCom  wrote:
>
> > It returns nothing... even if I write in the exact value and it should
> > work like a fuzzy logic..
> > like that:
>
> > find_value= request.vars.value
>
> > db('%' + table_1.field_1 +
> > '%').lower().like(find_value).select(db.table_1.field_1)
>
> > or
>
> > db('%' + table_1.field_1 + '%').lower().like('%' + find_value +
> > '%').select(db.table_1.field_1)
>
> > Any Idea?
>
> > On 7 Mai, 17:03, mdipierro  wrote:
>
> > > This should work
>
> > > db("'%' || NEW.field_1 || '%'  LIKE
> > > table_1.field_1").select(db.table_1.field_1)
>
> > > On May 7, 9:35 am, AsmanCom  wrote:
>
> > > > Hi,
>
> > > > here is the important Code from an Sqlite trigger i use very often, is
> > > > this possible with web2py to?
>
> > > > Sqlite:
> > > > (SELECT table_1.field_1 FROM table_1 WHERE '%' || NEW.field_1 || '%'
> > > > LIKE table_1.field_1 )
>
> > > > or i can even do:
>
> > > > (SELECT table_1.field_1 FROM table_1 WHERE '%' || NEW.field_1 || '%'
> > > > LIKE  '%' || table_1.field_1  || '%'  )
>
> > > > w2p:
> > > > db.person.name.lower().like(‘m%’)


[web2py] Re: Downloading from "private" folder

2010-06-23 Thread Russell
If you look at the ReportLab example in chapter 9 of the book, it uses
the private folder to make the PDF file, which is then deleted.  So I
guess that private is for temporary working stuff - a folder that can
be cleaned out if necessary.  And, if such a file is worth keeping, I
guess it should be moved to uploads?

On Jun 24, 5:13 am, weheh  wrote:
> Massimo, thanks for the app. I'm studying it.
>
> From the doc, I'm not sure I get a crystal clear understanding of what
> the web2py convention is.
>
> Let's say my app lets you upload a music mp3 file, a file with a
> description (liner notes), and a jpeg (album cover). These get
> uploaded to "uploads". Should I allow them to be downloaded from
> uploads or do I need to move them both to "static" first?
>
> What if I mix the uploaded mp3 with some more music to make another
> mp3 file, which isn't uploaded. Should it be moved to the static
> folder?
>
> Finally, the doc says, "private files are accessed by the controllers
> but not directly by the
> developer." I've been trying to parse that statement but it makes no
> sense to me. I'm the developer. I write the controller. My controller
> tries to access private directly. Does that make me not the developer?
> So what exactly is the purpose of the private folder?
>
> On Jun 23, 3:15 am, mdipierro  wrote:
>
> > Two issues:
>
> > - you are donwloading from private not uploads folder. Thenically this
> > is ok but not a web2py convention. You should not expose the content
> > for the private folder. That is why it is called private. ;-)
>
> > - you used embed to embed a file, but it should be used to embed a
> > plugin. I have used a flash plugin for this purpose.
>
> > Here is an app to manage music files that you can use as example:
>
> >http://web2py.com/examples/static/web2py.app.music.w2p
>
> > Massimo
>
> > On Jun 22, 10:50 pm, weheh  wrote:
>
> > > Continuing this old 
> > > thread:http://groups.google.com/group/web2py/browse_thread/thread/59b66b3a24...
>
> > > I'm having trouble getting an embedded mp3 from showing up in my web
> > > page. I'm trying to implement this almost exactly as Massimo suggested
> > > in the above thread. Anybody know why my code below isn't functioning?
>
> > > #controller "audio.py"
> > > def download_audio():
> > >   f=os.path.join(request.folder,'private',request.args(0))
> > >   return response.stream(open(f,'rb'))
>
> > > #model "show_audio.py"
> > > def show_audio():
> > >   filename='audio/aab/hello_world.mp3'  # this is a hardcoded value
> > > for this test case
> > >   url=URL(r=request,c='audio',f='download_audio',args=filename)
> > >   return EMBED(_src=url,_autoplay='true')
>
> > > #view "index.html"
> > > {{=show_audio()}}


[web2py] Re: dynamically growing form?

2010-06-23 Thread Russell
I would create a form with all 10 rows, hide all but the first 2 rows,
and then use jquery to progressively display the rest of the rows.
Add something like this to each of the rows...

form.element(_id=this_reference_id).append( A(' add', _href='#',
_onclick="jQuery('#%s').show()" % next_reference_id))



On Jun 23, 1:38 pm, Doug Warren  wrote:
> I started writing this a few times but I kept deleting it as I wasn't
> very clear so I'll try again.
>
> I'm looking to create a form that has some tabular data in it, 2
> columns, but the trick is that each submission of the form will have
> between 2-10 rows.  Each submission represents a single working set
> that can be edited later to have rows added/deleted.  And the rows
> have an order.  What I'm looking for basically is a table that starts
> out with 2 rows, 2 columns and a submit button, next to each row is a
> +/- button, if you hit the + button a new row will be added to the
> table below the row you hit the + on.  If you hit - the row you hit
> the - on would be removed from the form.  On submission all the rows
> would be added to the database and a crud form could be used to go
> back and edit the table again even deleting/adding rows.
>
> Is there any slice or best practice that will do this?  I was thinking
> something with JQuery tabular plugin but not sure how to handle the
> creation/deletion of rows part.


[web2py] Re: upload bug in filename

2010-06-24 Thread Russell
As an aside, the mixing of \\ and  / is unsightly but does not seem to
cause a problem on widows.  If you want to tidy it up, it's around
line 786 of main.py:

request.folder = os.path.join(request.env.web2py_path,
'applications', request.application) + '/'



On Jun 25, 11:15 am, Yarko Tymciurak 
wrote:
> By the way -
>
> The filename in the upload directory was 194 characters --- it's
> entirely possible that windows was having trouble with this.
>
> Here is the listing of my test  uploads directory (the first was just
> a 'normal' length file):
>
> -rw-r--r--  1 yarko  staff   2642 Jun 24 17:33 test.file.
> 880c7c46ee30a1ad.696e6465782e68746d6c.html
> -rw-r--r--  1 yarko  staff  16624 Jun 24 17:40 test.file.
> 96aded454eba1b88.5468652050726963696e67206f66204f7074696f6e7320616e6420436f72706f72617465204c696162696c69746965735f4a6f75726e616c206f6620506f6c69746963616c2045636f6e6f6d792e6a7067.jpg
> -rw-r--r--  1 yarko  staff  16624 Jun 24 17:45
> test.file.a500ba489526de41.5468652050726963696e67206f66204f7074696f6e7320616e6420436f72706f72617465204c696162696c69746965735f4a6f75726e616c206f6620506f6c69746963616c2045636f6e6f6d792e6a7067.jpg
>
> Here's the paths to the links from web2py db admin (as you can see -
> all the paths are correctly formed):
>
> http://localhost:8000/test/appadmin/download/db/test.file.880c7c46ee3...http://localhost:8000/test/appadmin/download/db/test.file.96aded454eb...http://localhost:8000/test/appadmin/download/db/test.file.a500ba48952...
>
> Regards,
> - Yarko
>
> On Jun 23, 3:15 am, Swell  wrote:
>
> > Ok
> > I will post some code here to show as much as possible
>
> > here is the db definition:
>
> > db.define_table('papers',
> >   Field('title','string'),
> >   Field('author','string'),
> >   Field('file','upload'),
> >   )
>
> > then if i try to use the database administration tool available in
> > Models section and try to insert a file like
> > "The Pricing of Options and Corporate Liabilities_Journal of Political
> > Economy.pdf" i then get a ticket complaining about
>
> > IOError: [Errno 2] No such file or directory:
> > C:\\Users\\M\\Desktop\\web2py_src\\web2py\\applications\\Library/
> > databases\\..\\uploads\
> > \papers.file.a33b16f5af29f6d8.5468652050726963696e67206f66204f7074696f6e7320616e6420436f72706f72617465204c696162696c69746965735f4a6f75726e616c206f6620506f6c69746963616c2045636f6e6f6d792e706466.pdf'
>
> > i also checked the file actually has never been properly uploaded ( it
> > is not present in the upload directory). Nothing special about size of
> > the file ( if i just  change manually the filename it works ). So it
> > seems that the bug is when we receiving the file .
>
> > hope we can sort this out
> > Thx all
> > M


[web2py] Re: trying to get email to work

2010-02-03 Thread Russell
Just curious...The code shows the mail.send routine in a loop and the
whole thing could take some time to run.  Should there be some limit
to the number of records that can be thrown into such a loop?   About
how many records before this sort of thing should be handed off to a
daemon?

On Feb 4, 4:36 am, mdipierro  wrote:
> Can you try?
>
> mail.settings.server='localhost:25'
>
> On Feb 3, 12:02 am, weheh  wrote:
>
> > I'm trying to get the email module to work. In my model I say:
>
> > #model
> > mail.settings.server='localhost'            # your SMTP server
> > mail.settings.login=None                    # your credentials
> > mail.settings.sender='no-re...@foobar.com'  # your email
>
> > #controller "admin.py"
> > def email_blast():
> >   """Controller for sending email blasts to filtered user lists"""
> >   # set up crud
> >   crud.settings.create_onaccept=lambda form: send_email(form)
> >   crud.settings.update_onaccept=lambda form: None
> >   # build crud form
> >   form = crud.update(db.email_blast,request.args(2),message=T('Blast
> > sent'))
> >   # build record table
> >   rows=crud.select(db.email_blast)
> >   return dict(form=form,rows=rows)
>
> > def send_email(form):
> >   """Function sends email to all users that match query"""
> >   for user in db(db.auth_user.id>0).select():
> >     if not user.email=='testa...@foobar.com': continue
> >     context=dict(user=user)
> >     #if form.vars.approved:
> >     message = response.render('admin/message.html',context)
> >     mail.send(to=
> > [user.email],subject=form.vars.subject,message=message)
>
> > Mine is the test email address (real address in actual code). But I'm
> > never getting any email.
>
> > My server is up and running OK and an old email program that I also
> > wrote that uses localhost is working fine.
>
> > Any ideas where I'm going wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: call response.flash = "smoething" from view

2010-02-06 Thread Russell
Try this if you want to make yourself a loading gif...

http://www.ajaxload.info/


On Feb 6, 6:24 pm, Iceberg  wrote:
> Elegant and universal! Exactly what I am looking for. Thanks!
>
> On Feb6, 1:35am, sveinh  wrote:
>
> > If I understand you correctly, you want to indicate to the user that
> > it may take a while for the request to complete?
>
> > Check out this one:http://www.web2pyslices.com/main/slices/take_slice/38
>
> > -sveinh
>
> > On Feb 4, 9:56 pm, Tomas Pelka  wrote:
>
> > > -BEGIN PGP SIGNED MESSAGE-
> > > Hash: SHA1
>
> > > Hi all,
>
> > > it possible run response.flash = "smoething" from view?
>
> > > You know I need to display response.flash = "Analyzing ..." when I click
> > > on submit button and then response.flash = "Successful done" when
> > > everything is done.
>
> > > Thanks for advice.
>
> > > - --
> > > Tom

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] UnicodeDecodeError sending email

2010-02-07 Thread Russell
Hi,

Upgraded from 1.71 to 1.74.11.  This works on 1.71:

message = response.render(email_template, email_fields)
if not mail.send(to=[form.vars.email], subject=message_title,
message=message):
raise RuntimeError('Unable to send email')

But I get this on 1.74.11:

UnicodeDecodeError: 'utf8' codec can't decode byte 0x92 in position
431: unexpected code byte
File "c:\web2py\applications\main\controllers\start.py", line 160, in
send_status
  if not mail.send(to=[form.vars.email], subject=message_title,
message=message):
File "c:\web2py\gluon\tools.py", line 281, in send
  text = text.decode(encoding).encode('utf-8')
File "c:\Python25\Lib\encodings\utf_8.py", line 16, in decode
  return codecs.utf_8_decode(input, errors, True)

What's changed?

Thanks
Russell

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: csv import

2010-02-15 Thread Russell
My experience with CSV import suggests that you need to delete the id
column.

Also the lack of validation is a bit of a trap...once I edited an
exported CSV with MS Excel, which silently reformatted all the dates
to something like 1/2/2010.  The edited file was 'successfully'
imported into SQLite by web2py, but completely corrupted the table.

Also if you happen to have any text that is non-UTF-8, (in my case a
user supplied bibliographic information exported from MS Word),  that
can corrupt the table too.


On Feb 16, 9:32 am, mdipierro  wrote:
> On Feb 15, 2:05 pm, weheh  wrote:
>
> > During csv import via the admin interface, do I need to have all the
> > fields from the db table present in the csv input file, or can I have
> > just a few of the columns?
>
> as long as the other fields have default values or are not
> "required=True" you can miss them.
>
> > Also, do validators get run during import?
>
> no.
>
> > I'm trying to import a csv file from a legacy database but it's not
> > being read in and I'm not getting any error messages. How to debug
> > this?
>
> Are you importing programmatic ally or vie the web interface?
>
> Does the file has a first row with column names?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Long running tasks queue

2010-02-19 Thread Russell
Would it be possible to start/stop/monitor such a background process
from admin?  If so, it would seem to be generically useful and a
powerful compliment to cron.  A plug-in perhaps?


On Feb 19, 10:06 am, mdipierro  wrote:
> I would not use cron for this. cron starts a job at reguar intervals
> but in background processing you do know that the previous task was
> completed. I would just make a loop that extract a "todo" task from
> database queue and sleeps if not task.
>
> You can use  cron @reboot to make sure this one task starts with the
> app.
>
> On Feb 18, 2:35 pm, Kevin Bowling  wrote:
>
> > I like this, I can simply insert sleep statements to keep it from
> > being to aggressive with this approach.
>
> > Would this be best in system cron?
>
> > On Feb 18, 1:31 pm, mdipierro  wrote:
>
> > > I would run a separate process
>
> > > web2py.py -S yourapp -M -R yourscript.py
>
> > > On Feb 18, 1:31 pm, Kevin Bowling  wrote:
>
> > > > Hello,
>
> > > > I have a screen scraper that I would like to call from web2py.  I
> > > > currently have a controller method that calls it and updates data in
> > > > the DAL.  The problem is, the number of users of this app is growing
> > > > quickly.  I need to queue the updates so I don't overwhelm the server
> > > > that it is scraping.
>
> > > > I would like a cron script to fire off daily and set the queue in
> > > > motion.  I would like to limit the queue to update 5 users or so per
> > > > minute.
>
> > > > Any recommendations on attacking this problem?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Any way to close a window from the controller?

2010-02-19 Thread Russell
You could use javascript for this.  The command is 'top.close()'

For example, say you want the window to close as soon as the
controller has done it's work...


$(document).ready(function() {
top.close();
});


Alternatively if you wanted more control, you could return top.close()
from the web2py ajax function, using the ":eval" option.  See pg 274
in the book for details.

Note that with this javascript command, the security settings on most
browsers will prompt the user with "Do you want to close this window?"


On Feb 20, 12:52 pm, waTR  wrote:
> I have a window that was opened by a link. I have it go to a
> controller, but once I am finished, I would like to close the window.
> Is this possible to do from the controller via a URL() or something?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] local_import works on windows, fails on Linux

2010-03-08 Thread Russell
I have a local module in /web2py/applications/test/modules/helpers.py

Which is imported like this:

h = local_import('helpers', reload=True)

This works on my windows box, but fails when I moved the application
to Linux:

  File "gluon/compileapp.py", line 258, in 
local_import_aux(name,reload,app)
  File "gluon/compileapp.py", line 196, in local_import_aux
exec("import %s as mymodule" % name) in env
  File "", line 1, in 
ImportError: No module named applications.test.modules.helpers

Both boxes are running 1.76.3 from source.  I tried changing
permissions on the module folder and everything inside it, but no
luck.  Does anyone have any suggestions?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: local_import works on windows, fails on Linux

2010-03-08 Thread Russell
Doh!  You're right.  I had it in the application and module folder,
but forgot to check the higher level web2py/applications/ folder
itself.  Thanks Richard.

On Mar 9, 12:56 pm, Richard  wrote:
> that works for me on Linux. Do you have __init__.py in all those
> folders?
>
> On Mar 9, 10:31 am, Russell  wrote:
>
> > I have a local module in /web2py/applications/test/modules/helpers.py
>
> > Which is imported like this:
>
> > h = local_import('helpers', reload=True)
>
> > This works on my windows box, but fails when I moved the application
> > to Linux:
>
> >   File "gluon/compileapp.py", line 258, in 
> >     local_import_aux(name,reload,app)
> >   File "gluon/compileapp.py", line 196, in local_import_aux
> >     exec("import %s as mymodule" % name) in env
> >   File "", line 1, in 
> > ImportError: No module named applications.test.modules.helpers
>
> > Both boxes are running 1.76.3 from source.  I tried changing
> > permissions on the module folder and everything inside it, but no
> > luck.  Does anyone have any suggestions?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: how to access db from module

2010-03-09 Thread Russell
You might need to import the DAL?

>From 
>http://groups.google.com/group/web2py/browse_thread/thread/159b44bfbb634df2/83751f3fd6e51578

 from gluon.sql import DAL, Field
db=DAL('sqlite://storage',folder='/path/to/databases/folder/')
db.define_table()
etc. etc.

On Mar 10, 12:43 pm, Richard  wrote:
> I need to interact with the database from a module and I can't pass db
> as an argument. (This is so I can use deferred on 
> GAE:http://groups.google.com/group/web2py/browse_thread/thread/d909260458...)
>
> Can this be done?
>
> Richard

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: How to use SUM()

2010-03-09 Thread Russell
The number is stored in a dictionary called '_extra'.  The top part of
what you are getting is the dictionary key.  Do something like this to
get just the number...

row = db(...).select(db.some_table.amount.sum())[0]
answer = row.'_extra['SUM(some_table.amount) ']

See pg 169 of the book.


On Mar 10, 1:23 pm, minh  wrote:
> I couldn't find much documentation on sum() and I'm not sure how to
> use it.
>
> If I have something like
>
> define_table('some_table',
>    Field('amount', 'integer')
>   ...
>
> I try db(...).select(db.some_table.amount.sum())
>
> When I print it out, I get something like:
>
> SUM(some_table.amount)
> 300
>
> How do I get it to print just the number?
>
> Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: how to access db from module

2010-03-10 Thread Russell
If you're on GAE then sessions are already in the database.  I suppose
you could do the same with the other globals (or at least the parts
that auth uses).  Why not pickle the stuff needed into the session
itself?

On Mar 10, 5:13 pm, Richard  wrote:
> ah I didn't know about this new feature - thanks.
>
> However my tables rely on auth, which relies on being passed globals()
> containing request, response, and session. Will I need to fake them?
>
> On Mar 10, 11:01 am, Russell  wrote:> You might 
> need to import the DAL?
>
> > Fromhttp://groups.google.com/group/web2py/browse_thread/thread/159b44bfbb...
>
> >  from gluon.sql import DAL, Field
> >     db=DAL('sqlite://storage',folder='/path/to/databases/folder/')
> >     db.define_table()
> >     etc. etc.
>
> > On Mar 10, 12:43 pm, Richard  wrote:
>
> > > I need to interact with the database from a module and I can't pass db
> > > as an argument. (This is so I can use deferred on 
> > > GAE:http://groups.google.com/group/web2py/browse_thread/thread/d909260458...)
>
> > > Can this be done?
>
> > > Richard

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] using functions in an update query

2010-03-16 Thread Russell
Hi,

I'm trying to update some text fields in a database.  In SQL I would
do something like this...

UPDATE products SET product_code=substr(product_code,2);

or even...

UPDATE products SET product_name = replace(product_name, 'Tiger',
'Woods');

Does anyone have an example of how to do this with the DAL?

Thanks
Russell

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: using functions in an update query

2010-03-16 Thread Russell
Thanks mr.freeze, that's got it.  And so obvious too.

>>>db(db.products.id>0)._update(product_code=db.products.product_code[:2])
"UPDATE products SET product_code=SUBSTR(product_code,1,(2 - 0))"

I guess my question was mainly about the SQL scalar functions
supported by web2py, and the syntax for using them.

For the record, web2py DAL supports: upper(), lower(), len(), and
slicing.  But not strip() or replace().


On Mar 17, 3:09 am, "mr.freeze"  wrote:
> It will be faster if the update is performed on the set (without
> selecting each one):
>
> db(db.products.id>0).update(product_code=db.products.product_code[:2])
>
> You can do _update to see what SQL will be generated.
>
> On Mar 16, 6:12 am, selecta  wrote:
>
> > for p in db(db.products.id>0).select():
> >   p.update(product_name = 'Tiger Woods')
>
> > or
>
> > [p.update(product_name = 'Tiger Woods') for p in
> > db(db.products.id>0).select()]
>
> > On Mar 16, 12:06 pm, Russell  wrote:
>
> > > Hi,
>
> > > I'm trying to update some text fields in a database.  In SQL I would
> > > do something like this...
>
> > > UPDATE products SET product_code=substr(product_code,2);
>
> > > or even...
>
> > > UPDATE products SET product_name = replace(product_name, 'Tiger',
> > > 'Woods');
>
> > > Does anyone have an example of how to do this with the DAL?
>
> > > Thanks
> > > Russell

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] prepend a string to a field

2010-03-24 Thread Russell
Hi there,

I'm trying to prepend a string to a field.  While, this works:

>>> db(db.person.id>0).update(name = db.person.name + "x")

This does not:

>>> db(db.person.id>0).update(name = "x" + db.person.name)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: cannot concatenate 'str' and 'Expression' objects

I have found a work-around, but it is pretty ugly:

>>> db(db.person.id>0).update(name = db.person.name[0:0] + "x" + db.person.name)

Does anyone have a better solution?

Thanks
Russell

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: prepend a string to a field

2010-03-24 Thread Russell
Thanks very much for the reply.

Sorry to say that it doesn't work.  Your answer gives this...
"UPDATE person SET name='xSUBSTR(person.name,1,(1 - 0))';"


On Mar 25, 3:58 pm, "mr.freeze"  wrote:
> Whoops, backwards:
> db(db.person.id>0).update(name = "%s%s" % ("x",db.person.name))
>
> On Mar 24, 9:57 pm, "mr.freeze"  wrote:
>
> > Try this:
> > db(db.person.id>0).update(name = "%s%s" % (db.person.name,"x"))
>
> > On Mar 24, 9:52 pm, Russell  wrote:
>
> > > Hi there,
>
> > > I'm trying to prepend a string to a field.  While, this works:
>
> > > >>> db(db.person.id>0).update(name = db.person.name + "x")
>
> > > This does not:
>
> > > >>> db(db.person.id>0).update(name = "x" + db.person.name)
>
> > > Traceback (most recent call last):
> > >   File "", line 1, in 
> > > TypeError: cannot concatenate 'str' and 'Expression' objects
>
> > > I have found a work-around, but it is pretty ugly:
>
> > > >>> db(db.person.id>0).update(name = db.person.name[0:0] + "x" + 
> > > >>> db.person.name)
>
> > > Does anyone have a better solution?
>
> > > Thanks
> > > Russell

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: prepend a string to a field

2010-03-24 Thread Russell
A bigger problem...

On further testing, it looks like db(db.person.id>0).update(name =
db.person.name + "x")  does NOT work.

The DAL seems to treat this as an integer addition and the field is
updated to 0 (at least on sqlite).


On Mar 25, 4:11 pm, Russell  wrote:
> Thanks very much for the reply.
>
> Sorry to say that it doesn't work.  Your answer gives this...
> "UPDATE person SET name='xSUBSTR(person.name,1,(1 - 0))';"
>
> On Mar 25, 3:58 pm, "mr.freeze"  wrote:
>
> > Whoops, backwards:
> > db(db.person.id>0).update(name = "%s%s" % ("x",db.person.name))
>
> > On Mar 24, 9:57 pm, "mr.freeze"  wrote:
>
> > > Try this:
> > > db(db.person.id>0).update(name = "%s%s" % (db.person.name,"x"))
>
> > > On Mar 24, 9:52 pm, Russell  wrote:
>
> > > > Hi there,
>
> > > > I'm trying to prepend a string to a field.  While, this works:
>
> > > > >>> db(db.person.id>0).update(name = db.person.name + "x")
>
> > > > This does not:
>
> > > > >>> db(db.person.id>0).update(name = "x" + db.person.name)
>
> > > > Traceback (most recent call last):
> > > >   File "", line 1, in 
> > > > TypeError: cannot concatenate 'str' and 'Expression' objects
>
> > > > I have found a work-around, but it is pretty ugly:
>
> > > > >>> db(db.person.id>0).update(name = db.person.name[0:0] + "x" + 
> > > > >>> db.person.name)
>
> > > > Does anyone have a better solution?
>
> > > > Thanks
> > > > Russell

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: prepend a string to a field

2010-03-24 Thread Russell
Thanks both of you for your replies.  I've been trying to avoid doing
it in python (lots of records) so I think I'll try mr.freeze's
solution.

On Mar 25, 5:18 pm, Thadeus Burgess  wrote:
> hrm...
>
> for row in db(db.person.id > 0).select():
>    row.update_record(name = row.name + "x")
>
> This also will work, although not as efficient since the processing
> will be done in python and not the database.
>
> -Thadeus
>
> On Wed, Mar 24, 2010 at 11:10 PM, mr.freeze  wrote:
> > This is ugly but should work:
>
> > from gluon.sql import Expression
> > db(db.person.id>0).update(name = Expression('person.name || "x"'))
>
> > I'm almost positive there is a better way.
>
> > On Mar 24, 10:43 pm, Russell  wrote:
> >> A bigger problem...
>
> >> On further testing, it looks like db(db.person.id>0).update(name =
> >> db.person.name + "x")  does NOT work.
>
> >> The DAL seems to treat this as an integer addition and the field is
> >> updated to 0 (at least on sqlite).
>
> >> On Mar 25, 4:11 pm, Russell  wrote:
>
> >> > Thanks very much for the reply.
>
> >> > Sorry to say that it doesn't work.  Your answer gives this...
> >> > "UPDATE person SET name='xSUBSTR(person.name,1,(1 - 0))';"
>
> >> > On Mar 25, 3:58 pm, "mr.freeze"  wrote:
>
> >> > > Whoops, backwards:
> >> > > db(db.person.id>0).update(name = "%s%s" % ("x",db.person.name))
>
> >> > > On Mar 24, 9:57 pm, "mr.freeze"  wrote:
>
> >> > > > Try this:
> >> > > > db(db.person.id>0).update(name = "%s%s" % (db.person.name,"x"))
>
> >> > > > On Mar 24, 9:52 pm, Russell  wrote:
>
> >> > > > > Hi there,
>
> >> > > > > I'm trying to prepend a string to a field.  While, this works:
>
> >> > > > > >>> db(db.person.id>0).update(name = db.person.name + "x")
>
> >> > > > > This does not:
>
> >> > > > > >>> db(db.person.id>0).update(name = "x" + db.person.name)
>
> >> > > > > Traceback (most recent call last):
> >> > > > >   File "", line 1, in 
> >> > > > > TypeError: cannot concatenate 'str' and 'Expression' objects
>
> >> > > > > I have found a work-around, but it is pretty ugly:
>
> >> > > > > >>> db(db.person.id>0).update(name = db.person.name[0:0] + "x" + 
> >> > > > > >>> db.person.name)
>
> >> > > > > Does anyone have a better solution?
>
> >> > > > > Thanks
> >> > > > > Russell
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > web2py+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: problems using web2py ajax function

2010-03-28 Thread Russell
Is there a reason not to simply place the constant in the args?
ajax('show_month/3',[],'test')

or if you want to be explicit...
ajax('show_month?month_to_show=3',[],'test')


On Mar 29, 4:24 am, mdipierro  wrote:
> Normally if I want to pass a constant, I put it in a hidden field and
> then pass the name of the hidden field.
>
> On Mar 28, 10:14 am, salbefe  wrote:
>
> > Thanks,
>
> > Now is clear to me.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: new SQLFORM

2010-04-05 Thread Russell
Just a thought...

It occurs to me that, as SQLFORM is a set of fields, wouldn't it be
better if SQLFORMs had their own widget class?

It would allow for customization and, potentially you could then
combine SQLTABLE with SQLFORM into one tidy concept.  By this I mean
that SQLTABLE could deliver a set of SQLFORM objects (using a default
read-only widget).

Taking that the next step, for example, you could submit a read-only
row from an SQLTABLE via ajax, toggle the widget to return an edit
form...giving you automatic edit-in-place for the record set.


On Apr 3, 12:31 pm, mdipierro  wrote:
> becase form=SQLFORM() is already a server side representation of the
> DOM. It is not an abstract object.
> after form=SQLFORM() you are supposed to be able to do
> form.element(name)[attribute](value) for example and other DOM
> manipulations.
>
> If form were a more abstract object and if its DOM representation were
> to be decided later (form.as_div()) you would not be able to
> manipulate the DOM. This would 1) break backward compatibility; 2)
> break everything that is good about about it.
>
> Massimo
>
> On Apr 1, 3:24 pm, Thadeus Burgess  wrote:
>
> > So why formstyle instead of
>
> > form.as_div()
> > or
> > form.as_ul()
>
> > ??
>
> > -Thadeus
>
> > On Wed, Mar 24, 2010 at 8:18 PM, mdipierro  wrote:
> > > Thank you!
>
> > > On Mar 24, 8:21 pm, Jose  wrote:
> > >> I sent a patch to Massimo
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "web2py-users" group.
> > > To post to this group, send email to web...@googlegroups.com.
> > > To unsubscribe from this group, send email to 
> > > web2py+unsubscr...@googlegroups.com.
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] jquery submit within LOAD

2010-04-23 Thread Russell
Hi,

When I put an onchange submit into an {{=LOAD()}} it seems to submit
the main page's form and not the LOADed form.  Is there a way to have
something like this within a LOAD element?

For example, here's what I'm trying to LOAD...


Field Label

Blah





I've tried butting an ID on the loaded form but this doesn't seem to
help.

Thanks
Russell



-- 
Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en


[web2py] Re: jquery submit within LOAD

2010-04-24 Thread Russell
If it's not obvious to you then I'm sure it would take me a month of
Sunday's to figure it out.  I think I'll just leave the functionality
out!

On Apr 25, 1:58 am, mdipierro  wrote:
> You have to modify the code in web2py_ajax to support this. It is not
> obvious to me how to. If you find out a way I would take a patch to
> support it.
>
> Massimo
>
> On Apr 23, 11:59 pm, Russell  wrote:
>
> > Hi,
>
> > When I put an onchange submit into an {{=LOAD()}} it seems to submit
> > the main page's form and not the LOADed form.  Is there a way to have
> > something like this within a LOAD element?
>
> > For example, here's what I'm trying to LOAD...
>
> > 
> >     Field Label
> >         
> >             Blah
> >             
> >         
> >     
> > 
>
> > I've tried butting an ID on the loaded form but this doesn't seem to
> > help.
>
> > Thanks
> > Russell
>
> > --
> > Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en


[web2py] Can't customise auth email validators

2010-04-25 Thread Russell
Hi,

Auth.login overwrites any custom email validators that you define.
Specifically, line 1019 of tools.py overwrites
table_user[username].requires with
IS_EMAIL(error_message=self.messages.invalid_email). Why is this
necessary?  For example, it means that this does NOT work:

db.py
-
auth_table = db.define_table(
auth.settings.table_user_name,
Field('email', length=128, default='',
unique=True, writable=True),
...)

auth_table.email.requires = [
IS_LOWER(),
IS_EMAIL(error_message=auth.messages.invalid_email)]


Email must be case-sensitive?!  Anyway, I suggest the following patch
to tools.py:

Replace:
1019 table_user[username].requires = tmpvalidator
With:
1019 table_user[username].requires = table_user[username].requires or
tmpvalidator

Or if you consider this a feature, perhaps a new setting?
1019 if not self.settings.login_email_custom_validators:
table_user[username].requires = tmpvalidator

Thanks
Russell


-- 
Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en


[web2py] Re: Can't customise auth email validators

2010-04-25 Thread Russell
Okay, I've thought more about this and can see why you might want to
overwrite the validators...you don't want IS_NOT_IN_DB(db,
auth_table.email) validation on login!  So maybe just a case-sensitive
flag?

On Apr 26, 12:01 pm, Russell  wrote:
> Hi,
>
> Auth.login overwrites any custom email validators that you define.
> Specifically, line 1019 of tools.py overwrites
> table_user[username].requires with
> IS_EMAIL(error_message=self.messages.invalid_email). Why is this
> necessary?  For example, it means that this does NOT work:
>
> db.py
> -
> auth_table = db.define_table(
>     auth.settings.table_user_name,
>     Field('email', length=128, default='',
>         unique=True, writable=True),
>     ...)
>
> auth_table.email.requires = [
>     IS_LOWER(),
>     IS_EMAIL(error_message=auth.messages.invalid_email)]
>
> Email must be case-sensitive?!  Anyway, I suggest the following patch
> to tools.py:
>
> Replace:
> 1019 table_user[username].requires = tmpvalidator
> With:
> 1019 table_user[username].requires = table_user[username].requires or
> tmpvalidator
>
> Or if you consider this a feature, perhaps a new setting?
> 1019 if not self.settings.login_email_custom_validators:
> table_user[username].requires = tmpvalidator
>
> Thanks
> Russell
>
> --
> Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en


[web2py] Re: Can't customise auth email validators

2010-04-25 Thread Russell
For those that are interested, a temporary work-around that does not
require editing tools.py is to put this in your db.py:

def login_email_lower(form):
form.vars.email = form.vars.email.lower()
return(form)
auth.settings.login_onvalidation = login_email_lower
auth.settings.register_onvalidation = login_email_lower
auth.settings.verify_email_onvalidation = login_email_lower


On Apr 26, 12:34 pm, mdipierro  wrote:
> I will look into this.
>
> On Apr 25, 7:26 pm, Russell  wrote:
>
> > Okay, I've thought more about this and can see why you might want to
> > overwrite the validators...you don't want IS_NOT_IN_DB(db,
> > auth_table.email) validation on login!  So maybe just a case-sensitive
> > flag?
>
> > On Apr 26, 12:01 pm, Russell  wrote:
>
> > > Hi,
>
> > > Auth.login overwrites any custom email validators that you define.
> > > Specifically, line 1019 of tools.py overwrites
> > > table_user[username].requires with
> > > IS_EMAIL(error_message=self.messages.invalid_email). Why is this
> > > necessary?  For example, it means that this does NOT work:
>
> > > db.py
> > > -
> > > auth_table = db.define_table(
> > >     auth.settings.table_user_name,
> > >     Field('email', length=128, default='',
> > >         unique=True, writable=True),
> > >     ...)
>
> > > auth_table.email.requires = [
> > >     IS_LOWER(),
> > >     IS_EMAIL(error_message=auth.messages.invalid_email)]
>
> > > Email must be case-sensitive?!  Anyway, I suggest the following patch
> > > to tools.py:
>
> > > Replace:
> > > 1019 table_user[username].requires = tmpvalidator
> > > With:
> > > 1019 table_user[username].requires = table_user[username].requires or
> > > tmpvalidator
>
> > > Or if you consider this a feature, perhaps a new setting?
> > > 1019 if not self.settings.login_email_custom_validators:
> > > table_user[username].requires = tmpvalidator
>
> > > Thanks
> > > Russell
>
> > > --
> > > Subscription 
> > > settings:http://groups.google.com/group/web2py/subscribe?hl=en


[web2py] Re: Cannot compile: there are errors in your app:

2010-04-30 Thread Russell
You might want to check any dynamic {{extend}} statements within your
views.  When the app is compiled the views are 'extended' but any
paths based on run-time objects just don't work.  For example this
works uncompiled...

{{extend os.path.join(request.controller, 'custom_layout.html')}}

But it won't compile as there is no request object at compile time.
The include path needs to be hard-coded like this...

{{extend 'controller_name/custom_layout.html'}}


On Apr 30, 4:07 pm, Thadeus Burgess  wrote:
> Something is wrong with your syntax "somewhere".
>
> You can try and temporarily patch applications/admin/compile and
> remove the exception catch, that way you can determine the exact line
> that is causing the error.
>
> --
> Thadeus
>
> On Thu, Apr 29, 2010 at 9:41 PM, DJ  wrote:
> > I checked for file permissions and they look fine. No special files in
> > my app apart from javascript files and the regular web2py files.
>
> > Version: 1.77.3 running on Ubuntu 8, python 2.5.2
>
> > Any pointers?
>
> > -Sebastian


[web2py] Re: Wiki example from book on gae

2010-05-01 Thread Russell
Initially this example didn't run for me on postgresql.  I assume that
this is because 'page' is a reserved word...changed the table name to
'webpage' and all was good.

On May 2, 7:04 am, mdipierro  wrote:
> If you comment this line:
>
> db.document.page_id.requires = IS_IN_DB(db, 'page.id', '%(title)s')
>
> do you get the errors?
>
> Which web2py version?
>
> On Apr 30, 10:43 pm, nic  wrote:
>
> > Hello All,
>
> > I am trying to run the wiki example from the book on gae.
> > It is running fine on my local machine using cherrypy but will not run
> > on the gae.
>
> > The error seems to be coming from index() in default.py
>
> > I believe there may be an error in the book that may or may not be
> > related
>
> > In Section 3.9 A Wiki in the source of the model:
> >     Line 39 says db.comment.page_id.requires = IS_IN_DB(db, 'page.id',
> > ')
> >     Line 48 says db.document.page_id.requires = IS_IN_DB(db,
> > 'page.id', ')
> > I believe this is in error as the inverted quotes are not even.
>
> > Whereas the source from the pdf book I purchased a few months ago
> > says:
> >     db.comment.page_id.requires = IS_IN_DB(db, 'page.id', '%(title)s')
> >     db.document.page_id.requires = IS_IN_DB(db, 'page.id', '%
> > (title)s')
>
> > Any help appreciated ...
>
> > The log from the gae shows:
>
> > Traceback (most recent call last):
> >   File "/Applications/web2py/gluon/restricted.py", line 178, in
> > restricted
> >     exec ccode in environment
> >   File "/Applications/web2py_2gae/applications/nikiWiki/controllers/
> > default.py:index", line 106, in 
> >   File "/Applications/web2py/gluon/globals.py", line 96, in 
> >     self._caller = lambda f: f()
> >   File "/Applications/web2py_2gae/applications/nikiWiki/controllers/
> > default.py:index", line 12, in index
> >   File "/Applications/web2py/gluon/contrib/gql.py", line 676, in
> > select
> >     (items, tablename, fields) = self._select(*fields, **attributes)
> >   File "/Applications/web2py/gluon/contrib/gql.py", line 628, in
> > _select
> >     table = self._get_table_or_raise()
> >   File "/Applications/web2py/gluon/contrib/gql.py", line 607, in
> > _get_table_or_raise
> >     raise SyntaxError, 'Set: no tables selected'
> > SyntaxError: Set: no tables selected


[web2py] Re: How to get current user_id and group_id?

2010-05-01 Thread Russell
auth.user_id and auth.user_group(auth.user_id)


On May 2, 12:37 pm, Sverre  wrote:
> How can I retrieve current user_id and group_id? I need the to put the
> ownership of something into a table.


[web2py] Re: Weird Behavior - Query returning zero rows when it should return all rows

2010-08-18 Thread Russell
Use 'T' or 'F' rather than 'True' of 'False'.  Web2py saves boolean
data as 'char' with length 1.

On Aug 19, 1:49 am, Narendran  wrote:
> Hi,
> I added a new boolean field to a table. And I manually updated the
> value of the field outside web2py. Now, I get zero rows for any
> condition I put on that field. Please see the following shell output
> for an idea:
>
> In [7]:  offers = db(db.OFFER.IS_PRICE_COMPARED == False).select()
>    ...:
>
> In [8]: len(offers)
> Out[8]: 0   #<-- This is not expected. It should return all the
> rows
>
> In [9]:  offers = db(db.OFFER.IS_PRICE_COMPARED == True).select()
>    ...:
>
> In [10]: len(offers)
> Out[10]: 0
>
> In [11]:  offers = db().select(db.OFFER.IS_PRICE_COMPARED)
>    :
>
> In [12]: len(offers)
> Out[12]: 668
>
> In [13]: offers[0]
> Out[13]:  ##<-- Notice the value
> being False here
>
> In [14]: offers[1]
> Out[14]: 


[web2py] Re: build a row base questionnaire

2010-08-22 Thread Russell
In my experience, it is a bit awkward to do this using SQLFORM.  You
could try something like this:

db.define_table('q_and_a',
Field('question'),
Field('answer'))

rows = db(db.q_and_a.id>0).select()

import random
random.seed()
asked = random.sample(rows, 3))

form=SQLFORM.factory(
Field('asked_0', label = asked [0]['question']),
Field('asked_1 ', label = asked [1]['question']),
Field('asked_2 ', label = asked [2]['question']))


But this can create more problems than it solves.  Ultimately it might
be easier to put your questions in a wide table and use something like
Massimo proposed here:

http://groups.google.com/group/web2py/browse_thread/thread/d0093fa1901b565e/ca664f76800cfbd7



On Aug 20, 1:10 pm, dlin  wrote:
> Tks, Bruno.
> I seems haven't describe the 'row base' questionaire.
>
> That is:
>
> I've already a table like:
> Question Answer
> Q1...           A1
> Q2...           A2
> Q3...           A3
> ...
> Q13...           A1
>
> Then, I'll random choose three(or by customized) questions to ask.
>
> Question  Answer
> Q3.      
> Q8.      
> Q9.      
>  [submit]
>
> sometimes, it
> Question  Answer
> Q7.      
> Q9.      
> Q13.      
>  [submit]
>
> I think it is not proper to save it fixed on 3 field on table.
>
> I'm thinking should I use following steps:
> 1. SQLTABLE to select some random rows from my question and answer .
> 2. try to form a FORM() (I haven't idea now)
> 3. when user submit form, then try to compare the answer and store the
> scores of user in another table.
>
> On Aug 19, 7:54 am, Bruno Rocha  wrote:
>
> > You can use FORM(), and also use the table configuration to define
> > questions,
> > you can use the arguments "label" and "comment" on field definition.
>
> > After that, you can use CSS to improve the form layout.
>
> > You can't create a new field to store the login info and putting by default
> > the auth.user value?
>
> > 2010/8/18 dlin 
>
> > > I want a form like:
>
> > > Question  Answer
> > > Q1.      
> > > Q2.      
> > > Q3.      
> > > [submit]
>
> > > Q1,Q2,Q3 and correct answer is stored in a table.
> > > But the 'Answer' field should combined with login user's answer.
>
> > > What's the best way to display the form to user?
> > > Do you suggest use FORM() in control or use  in view?
>
> > --
>
> >http://rochacbruno.com.br


[web2py] Re: build a row base questionnaire

2010-08-23 Thread Russell
A much more sophisticated solution Massimo!  I completely missed the
orderby='' functionality.

Going back to the original question, the point here is that when you
have a 'normalised' table of question/answers, you need to decouple
from SQLFORM (with SQLFORM.factory) and handle the db interactions
more explicitly.

On Aug 23, 2:31 pm, mdipierro  wrote:
> We need to clarify the goal. The goal is not to propose questions to
> the user. the goal is to check if he answers correctly. Should each
> correct answer be recorded for each user? should incorrect answers be
> recorded? Should the list of proposed questions be recored? Should a
> score be computed? What is the answer is "Darwin" and he answers
> "darwin" or "Charles Darwin"?
>
> Anyway, the above code can be simplified in:
>
> db.define_table('q_and_a',
>     Field('question'),
>     Field('answer'))
>
> def check(correct_answer,answer):
>     if correct_answer.lower() in answer.lower(): return 1
>     return 0
>
> def ask():
>     asked =
> db(db.q_and_a.id>0).select(orderby='',limitby=(0,3))
>     form=SQLFORM.factory(*[Field('a%s'%i, label = a.question) for i,a
> in enumerate(asked)])
>     if form.accepts(request.vars,session):
>            score = sum((check(a.answer,request.vars.get('a%s'%i,''))
> for i,a in enumerate(asked))
>            # do something with score
>     return dict(form=form)
>
> On Aug 22, 6:04 pm, Russell  wrote:
>
> > In my experience, it is a bit awkward to do this using SQLFORM.  You
> > could try something like this:
>
> > db.define_table('q_and_a',
> >     Field('question'),
> >     Field('answer'))
>
> > rows = db(db.q_and_a.id>0).select()
>
> > import random
> > random.seed()
> > asked = random.sample(rows, 3))
>
> > form=SQLFORM.factory(
> >     Field('asked_0', label = asked [0]['question']),
> >     Field('asked_1 ', label = asked [1]['question']),
> >     Field('asked_2 ', label = asked [2]['question']))
>
> > But this can create more problems than it solves.  Ultimately it might
> > be easier to put your questions in a wide table and use something like
> > Massimo proposed here:
>
> >http://groups.google.com/group/web2py/browse_thread/thread/d0093fa190...
>
> > On Aug 20, 1:10 pm, dlin  wrote:
>
> > > Tks, Bruno.
> > > I seems haven't describe the 'row base' questionaire.
>
> > > That is:
>
> > > I've already a table like:
> > > Question Answer
> > > Q1...           A1
> > > Q2...           A2
> > > Q3...           A3
> > > ...
> > > Q13...           A1
>
> > > Then, I'll random choose three(or by customized) questions to ask.
>
> > > Question  Answer
> > > Q3.      
> > > Q8.      
> > > Q9.      
> > >  [submit]
>
> > > sometimes, it
> > > Question  Answer
> > > Q7.      
> > > Q9.      
> > > Q13.      
> > >  [submit]
>
> > > I think it is not proper to save it fixed on 3 field on table.
>
> > > I'm thinking should I use following steps:
> > > 1. SQLTABLE to select some random rows from my question and answer .
> > > 2. try to form a FORM() (I haven't idea now)
> > > 3. when user submit form, then try to compare the answer and store the
> > > scores of user in another table.
>
> > > On Aug 19, 7:54 am, Bruno Rocha  wrote:
>
> > > > You can use FORM(), and also use the table configuration to define
> > > > questions,
> > > > you can use the arguments "label" and "comment" on field definition.
>
> > > > After that, you can use CSS to improve the form layout.
>
> > > > You can't create a new field to store the login info and putting by 
> > > > default
> > > > the auth.user value?
>
> > > > 2010/8/18 dlin 
>
> > > > > I want a form like:
>
> > > > > Question  Answer
> > > > > Q1.      
> > > > > Q2.      
> > > > > Q3.      
> > > > > [submit]
>
> > > > > Q1,Q2,Q3 and correct answer is stored in a table.
> > > > > But the 'Answer' field should combined with login user's answer.
>
> > > > > What's the best way to display the form to user?
> > > > > Do you suggest use FORM() in control or use  in view?
>
> > > > --
>
> > > >http://rochacbruno.com.br


[web2py:29533] Re: Modifying form auth.register() to display Password2 label

2009-08-27 Thread Russell

The example on the bottom of page 212 in the new book shows you how to
do it.

On Aug 27, 6:40 pm, ed  wrote:
> Hi,
> It tried modifying the default.py auth.register() form with the
> following code:
> def user():
>     if request.args(0)=='register':
>         response.flash=T('Register')
>         form = SQLFORM(db.auth_user, fields='first_name',
>                    'last_name','password','email',
> 'birthdate'])
>         return dict(form=form)
> Only Password is displayed. How to specify Password2 so that it will
> be displayed and comparison of the two passwords can be done
> automatically in register.
> By the way, you might wonder why I used form=SQLFORM(). After a lot of
> modifying auth_user and default.py and running register, the Password
> field failed to display.
> Thanks in advance for your help.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:31766] IS_EMAIL() validation bug?

2009-09-27 Thread Russell

Hi,

It seems that email addresses without a user portion (eg,
'@whatever.com') will pass IS_EMAIL() validation.  Is this the
intended behavior?  See the tests below.

web2py Shell Version 1.67.1 (2009-09-17 13:33:20)
 In[0]: IS_EMAIL()('whatever.com')
 Out[0]: ('whatever.com', 'invalid email!')
 In[1]: IS_EMAIL()('@whatever.com')
 Out[1]: ('@whatever.com', None)

Thanks
Russell

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:32421] Re: FORM factory

2009-10-07 Thread Russell

Personally, I like the way the widget renders the error by default -
it's pretty tidy and does what you want most of the time.  If you want
to remove the error from the widget you could look at the section
called "Switch off errors" on page 220 of the manual.

On Oct 8, 5:03 am, Thadeus Burgess  wrote:
> Massimo, how hard would it be to implement
>
> form.custom.errors.field
>
> instead of having the widget render the error?
>
> -Thadeus
>
> On Wed, Oct 7, 2009 at 10:46 AM, Thadeus Burgess wrote:
>
> > I have to perform a nasty hack to get around the form.errors displaying on
> > each radio button!
>
> > Make sure to set error_message="". Now it won't display a divs for the
> > error.
>
> > Manually in my view,
>
> > {{if form.errors.has_key('field'):}}
> > You must enter a value into this field!
> > }}
> > {{=form.custom.widget.field}}
>
> > There has got to be an easier way?
>
> > -Thadeus
>
> > On Wed, Oct 7, 2009 at 7:22 AM, leone  wrote:
>
> >> I notice that if you don't match defined Field in SQLFORM.factory and
> >> {{=form...}} in html form.results is False but form.errors is empty.
> >> The length attribute of Field-string doesn't produce a desired width
> >> of input.  There is a different way to obtain the apprioate layout?
>
> >> On 6 Ott, 21:53, mdipierro  wrote:
> >> > Let us know when you find out.
>
> >> > Massimo
>
> >> > On Oct 6, 2:43 pm, leone  wrote:
>
> >> > > Acc.!!
> >> > > It works fine, but form.accets(request.vars) returns always False.
> >> > > I have a button type=submit with an image before {{=form.custom.end}}.
> >> > > I suppose this could be an error and Ihave substitute it with
> >> > > {{=form.custom.submit}} with no result.
> >> > > I have difficult to find solutions using your manual, but it is my
> >> > > problem.
>
> >> > > On 6 Ott, 19:58, mdipierro  wrote:
>
> >> > > > It is automatic. You just need
>
> >> > > > Field('name',requires=IS_IN_SET(('a','b','c')))
>
> >> > > > or requires IS_IN_DB
>
> >> > > > On Oct 6, 11:32 am, leone  wrote:
>
> >> > > > > How can I render a   sequence by Field in
> >> > > > > SQLFORM.factory?
> >> > > > > Thanks!
>
> >> > > > > On 6 Ott, 17:14, mdipierro  wrote:
>
> >> > > > > > yes
>
> >> > > > > > form=SQLFORM.factory(Field('x'),Field('y'))
>
> >> > > > > > 
> >> > > > > > ..
> >> > > > > >  {{=form.custom.begin}}
> >> > > > > >  {{=form.custom.widget.x}}
> >> > > > > >  {{=form.custom.widget.y}}
> >> > > > > >  {{=form.custom.submit}}
> >> > > > > >  {{=form.custom.end}}
> >> > > > > >   ..
> >> > > > > >  
>
> >> > > > > > On Oct 6, 9:51 am, leone  wrote:
>
> >> > > > > > > I want use FORM object and helpers objects, but I need
> >> complete
> >> > > > > > > control over html code.
> >> > > > > > > Exists a factory method as in SQLFORM, so I can code
> >> > > > > > > 
> >> > > > > > > ..
> >> > > > > > >  {{=form.begin}}
> >> > > > > > >  {{=form.widget.x}}
> >> > > > > > >  {{=form.widget.y}}
> >> > > > > > >  {{=form.submit}}
> >> > > > > > >  {{=form.end}}
> >> > > > > > >   ..
> >> > > > > > >  
> >> > > > > > > ???
> >> > > > > > > If not, exist an alternative way to obtain the advantages of
> >> web2py
> >> > > > > > > and html flexibility?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:33896] auth.settings.controller is not backward compatible

2009-10-27 Thread Russell

Hi,

Upgrading to Version 1.68.2 broke the Auth in my applications.  The
bug: when a user is visiting a controller other than 'default' and the
the login cookie expires, the ?_next parameter incorrectly bounces
them back to the 'default' controller.

I've narrowed it down to the new auth.settings.controller, which has a
default of 'default'.  This may be a reasonable assumption, but does
not seem to be backwards compatible.

The fix that works for me is to change these two lines in tools.py:

328: self.settings.controller = 'default'
1707: self.settings.controller = 'default'

to this:

328: self.settings.controller = response.controller
1707: self.settings.controller = response.controller

If you don't mind me asking, why was this added and where is it
documented? :-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34014] DAL Rows as dictionary?

2009-10-28 Thread Russell

Hi,

The DAL Rows object returned by select is a list.  But often a
dictionary with id as the key is what is needed (ie, a frequently used
lookup table).  Typically I do this...

item_list = db(db.items.id > 0).select()
item_dict = {}
for item in item_list:
item_dict[item.id] = item

Is there a better way?  Could the framework do this automatically? Or
does the framework already have the feature, it's just that I haven't
worked out how to use it properly?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34632] Does your Response Flash get in the way?

2009-11-04 Thread Russell

Hi there,

A mild annoyance: Sometimes the response flash covers other text on
the screen and, when you are doing lots of testing, you are
continually clicking it to make it go away.

My suggestion is to replace web2py_ajax.html line 36:

jQuery('.flash').click(function() { jQuery(this).fadeOut('slow');
return false; });

with:

jQuery('.flash').hide().fadeIn(2000).animate({opacity: 1.0},
2000).animate({ opacity: 'hide' }, 2000);

This makes the response.flash fade in and then fade out.  No clicking
required.

Thanks
Russell

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34685] Re: Does your Response Flash get in the way?

2009-11-05 Thread Russell

It does seem that a nice solution would be to position or shrink the
flash message on the default layout so that it is unlikely to cover
text.  But it maybe we are trying to do too much with the flash
message?  There are some messages that only deserve a quick 'flash' -
like 'logged in'.  But there are some messages that are more important
that need to stick around.  Perhaps we need two styles in the
layout...response.flash and response.notice?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:13699] form_factory on GAE

2008-12-16 Thread Russell

Hi there,

This function works on the web2py server, but throws a syntax error on
GAE.

def _test():
from gluon.sqlhtml import form_factory
form=form_factory(SQLField('email'))
return dict(form=form)

Here's the traceback...

ERROR2008-12-17 02:49:20,437 main.py] Traceback (most recent call
last):
  File "C:\GAE\google_appengine\web2py\gluon\restricted.py", line
 62, in restricted
exec ccode in environment
  File "C:\GAE\google_appengine\web2py\applications\appy/c
ontrollers/default.py:_test", line 542, in 
  File "C:\GAE\google_appengine\web2py\gluon\globals.py", line 55
, in 
self._caller=lambda f: f()
  File "C:\GAE\google_appengine\web2py\applications\appy/c
ontrollers/default.py:_test", line 10, in _test
  File "C:\GAE\google_appengine\web2py\gluon\sqlhtml.py", line 298, in
form_factory
return SQLFORM(SQLDB(None).define_table
('no_table',*fields),**attributes)
  File "C:\GAE\google_appengine\web2py\gluon\sql.py", line 566, i
n define_table
t=self[tablename]=SQLTable(self,tablename,*fields)
  File "C:\GAE\google_appengine\web2py\gluon\sql.py", line 651, i
n __init__
raise SyntaxError, "define_table argument is not a SQLField"
SyntaxError: define_table argument is not a SQLField

Any suggestions?

Thanks

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:13721] Re: form_factory on GAE

2008-12-17 Thread Russell

Thanks.  I can't tell you how happy I am that it works!

For clarity's sake, the solution that seems easiest is...

def _test():
from gluon.sqlhtml import form_factory
from gluon.sql import SQLField
form=form_factory(SQLField('email'))
return dict(form=form)

The line " from gluon.sql import SQLField" should be added to any
form_factory import to ensure it works on GAE as well as the web2py
server.  In other words, the additional import is required to make
form_factory fully portable.

Thanks again.

On Dec 17, 7:40 pm, mdipierro  wrote:
> Yes. There are two SQLField, one defined by gluon/sql.py (the standard
> one) and one defined by gluon/contrib/gql.py (used on GAE). The latter
> is overriding the former and breaking form_factory. There are two
> solutions:
>
> 1)
>      from gluon.sql import SQLField and Field
>
> and use Field instead of SQLField in form_factory.
>
> 2) in db.py you have something like
>
>     from gluon.contrib.gql import *
>     ...
>     db.define_field(...,SQLField(),...)
>
> replace this with
>
>     from gluon.contrib.gql import SQLField
>     ...
>     db.define_field(...,db.Field(),...)
>
> so that you never import and use SQLField from gql.py
>
> On Dec 16, 9:22 pm, Russell  wrote:
>
> > Hi there,
>
> > This function works on the web2py server, but throws a syntax error on
> > GAE.
>
> > def _test():
> >     from gluon.sqlhtml import form_factory
> >     form=form_factory(SQLField('email'))
> >     return dict(form=form)
>
> > Here's the traceback...
>
> > ERROR    2008-12-17 02:49:20,437 main.py] Traceback (most recent call
> > last):
> >   File "C:\GAE\google_appengine\web2py\gluon\restricted.py", line
> >  62, in restricted
> >     exec ccode in environment
> >   File "C:\GAE\google_appengine\web2py\applications\appy/c
> > ontrollers/default.py:_test", line 542, in 
> >   File "C:\GAE\google_appengine\web2py\gluon\globals.py", line 55
> > , in 
> >     self._caller=lambda f: f()
> >   File "C:\GAE\google_appengine\web2py\applications\appy/c
> > ontrollers/default.py:_test", line 10, in _test
> >   File "C:\GAE\google_appengine\web2py\gluon\sqlhtml.py", line 298, in
> > form_factory
> >     return SQLFORM(SQLDB(None).define_table
> > ('no_table',*fields),**attributes)
> >   File "C:\GAE\google_appengine\web2py\gluon\sql.py", line 566, i
> > n define_table
> >     t=self[tablename]=SQLTable(self,tablename,*fields)
> >   File "C:\GAE\google_appengine\web2py\gluon\sql.py", line 651, i
> > n __init__
> >     raise SyntaxError, "define_table argument is not a SQLField"
> > SyntaxError: define_table argument is not a SQLField
>
> > Any suggestions?
>
> > Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:20514] Re: SQLFORM

2009-04-25 Thread Russell

You might want to look at this thread...

http://groups.google.co.nz/group/web2py/browse_thread/thread/405c0bcfc6a2df2f

It shows how you can have several "submit" buttons and then use your
controller to dynamically determine the specific redirect.


On Apr 25, 6:24 pm, jmverm...@xs4all.nl wrote:
> Denes,
>
> > About the asterisks in col3, you have to use your form's field names
> > as in:
> > col3=dict(initialen='*', naam='*', ...)
> > form[0][-1][1].append(INPUT(_type='reset',_value='Reset'))
> > form[0][-1][1].append(INPUT(_type='button',_value='Cancel'))
>
> This all works. The form[0][-1][1] code is much neater than mine.
>
> About the _onclick attribute:
>
> form[0][-1][1].append(INPUT
> (_type='button',_value='Cancel',_onclick='javascript:location
> ('%s')'%URL(r=request,f='...'))
> is all that springs to mind, how do I reference the previous page,
> which, as I said , is not in every case the same page.
>
> > See this recent 
> > thread:http://groups.google.com/group/web2py/browse_thread/thread/ec7d941c8d...
>
> This link appears to be broken ...
>
> Annet.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:21725] HTML helpers, TAG, cpickle, colgroup

2009-05-12 Thread Russell

Hi,

I've recently experienced two issues with the html helpers when trying
to implement .

First, the TAG helper doesn't seem to pickle (but all the others do).
Have I missed something here?

>>> import cPickle
>>> htm1 = cPickle.dumps(DIV())
>>> htm2 = cPickle.dumps(TAG.colgroup())
Traceback (most recent call last):
  File "", line 1, in 
PicklingError: Can't pickle : attribute
lookup gluon
.html.__tag__ failed

Second, the TABLE helper doesn't seem to treat colgroup
appropriately...

>>> table = TABLE(TAG.colgroup(),THEAD(),TBODY())
>>> print table


When something like this would seem the preferable result...



I know the work-around is to split it into two steps with "table.insert
(0,TAG.colgroup())", but that does seem a little messy (and then it
doesn't pickle anyway).  Perhaps a colgroup helper is warranted?

Thanks
Russell


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py] Re: postgresql error ... (relation "auth_user" already exists)

2010-11-16 Thread Russell
Hi,

I've had this problem come up quite a few times.  It appears to be a
migration issue and is usually fixed by this...

auth.define_tables(migrate=False)

Thanks
Russell


On Nov 17, 8:48 am, Carlos  wrote:
> Hi Massimo,
>
> I'll send you the requested files if/when I get the error again (I
> deleted the previous ones).
>
> Btw it was not a custom auth_user.
>
> Johann, please send the files when you get this error too.
>
> Thanks,
>
>    Carlos
>
> On Nov 16, 7:06 am, mdipierro  wrote:
>
> > The error you are getting:
>
> > ProgrammingError: relation "auth_user" already exists
>
> > This is not a migration problem. The DB is not complaining about an
> > ALTER TABLE but about a CREATE TABLE.
>
> > This means your database/*_auth_user.table is either missing or
> > corrupted.
> > It would be useful to have steps to reproduce the problem.
>
> > Check in your database folder. You should have two of those files (one
> > for sqlite and one for postgresql). Can you send them to me? I am
> > assuming you have a custom auth_user. Can you send me that too?
>
> > Massimo
>
> > On Nov 16, 6:57 am, Carlos  wrote:
>
> > > So, based on Johann's confirmation, then this is a problem, isn't it?.
>
> > > Regards,
>
> > >    Carlos
>
> > > On Nov 16, 12:05 am, Johann Spies  wrote:
>
> > > > On 15 November 2010 18:17, Carlos  wrote:
>
> > > > > From what Johann said, I understood the table definitions were changed
> > > > > in web2py (using postgresql as the backend), not in postgresql
> > > > > directly ... or did I misunderstand it?.
>
> > > > Yes, that is what I meant.
>
> > > > Regards
> > > > Johann
> > > > --
> > > >  May grace and peace be yours in abundance through the full knowledge 
> > > > of God
> > > > and of Jesus our Lord!  His divine power has given us everything we 
> > > > need for
> > > > life and godliness through the full knowledge of the one who called us 
> > > > by
> > > > his own glory and excellence.
> > > >                                                     2 Pet. 1:2b,3a
>
>


[web2py] Re: prevent post on reload

2011-01-16 Thread Russell
This JavaScript will refresh the page without reposting the data:
window.location = window.location;


On Jan 17, 4:04 am, weheh  wrote:
> I'm using components, not typical web2py way of doing things.
>
> On Jan 16, 3:51 am, Kenneth Lundström 
> wrote:
>
> > But isn t web2py taking care of this already. Have you tried this double
> > posting? If you answer yes on browsers question do you get two sets of
> > answer in your database?
>
> > Kenneth
>
> > > That is my suspicion, too.
>
> > > On Jan 16, 2:59 am, Robby O'Connor  wrote:
> > >> I believe (somebody can correct me if i'm wrong) that this is a browser
> > >> issue.
> > >> On 1/16/2011 2:22 AM, weheh wrote:
>
> > >>> Anyone know how to prevent posting on reload? Right after submitting a
> > >>> form, if I reload, I'm always asked whether or not I want to re-post
> > >>> the previous form values. Is there a way to override this behavior?
> > >>> It's probably not a web2py issue, but maybe I'll get lucky ...
>
>


[web2py] Re: SQLFORM.factory - RuntimeError: you must specify a Field(...,uploadfolder=...)

2011-03-29 Thread Russell
I've just been struck by the same issue when upgrading to Version
1.94.6 (2011-03-27 18:20:38).

To be clear, this used to work, but does NOT work anymore:
form=SQLFORM.factory(Field('document', 'upload'))

This works on the current version:
form=SQLFORM.factory(Field('document', 'upload',
uploadfolder=os.path.join(request.folder,'uploads')))

The problem is dal.py around line 4900.  With SQLFORM.factory there is
no db._adapter.folder and, therefore, no path to specify a default
upload folder.  It also seems that dal.py doesn't assume, nor have,
access to the request?  Is there a way to restore the default for
SQLFORM.factory and maintain backward compatability?


On Mar 2, 11:23 am, Lisandro  wrote:
> Hi Carlos.
> Your solution worked perfectly. Though, I think this is a bug that has
> to be fixed in next version.
>
> Regards,
>   Lisandro.
>
> On 23 feb, 19:28, Carlos  wrote:
>
> > Hi Lisandro,
>
> > A workaround is to manually assign the following 'uploadfolder' value for
> > the 'upload' type fields in the 'define_table' statements:
>
> >    os.path.join(request.folder,'uploads')
>
> > I hope that helps.
>
> >    Carlos
>
>


[web2py] Re: Best practice to start background process

2011-04-27 Thread Russell
I think that a simple system cron is the most reliable (per minute,
per hour, per day).  Then use some type of locking mechanism in your
web2py script (either database or file).  For example:

locked = db((db.report_queue.status=='SystemLock')).select().first()
if not locked:
locked = db.report_queue.insert(status='SystemLock')
db.commit()
# and so on


On Apr 28, 5:04 am, teemu  wrote:
> Hi,
>
> I would like to know what would be the best way to start background
> process in production environment. I have implemented background
> process by using the web2py book chapter as a template 
> ("http://www.web2py.com/book/default/chapter/04#Background-Processes-and-Task-...";).
> I start background process manually on my development machine
> (Winddows 7, web2py webserver) and it works great. Now it is time to
> publish my app on production server (debian linux, apache2, mod_wsgi).
> I was wondering what would be the best and the most simple way to
> start this background process together with apache/mod_wsgi? Ideal
> solution would be cross-platform compatible but this is not
> mandatory.
>
> As far as i know there are several different options but I do not know
> what is the best and what are advantages and disadvantages of
> different methods:
>
> 1) manually from shell:
> - laborious and should be done upon every server reboot
>
> 2) init script:
> - good option and can be integrated with apache2 init script
>
> 3) web2py-cron-@reboot:
> - is this even possible or recommended? However, this would be the
> only cross-platform alternative
>
> 3) system cron:
> - cron job could check if background process is still running and
> restart process if it has been crashed
>
> How have you guys done this? Any suggestions?
>
> Teemu


[web2py] Re: Need advice on Cron in production

2011-05-17 Thread Russell
This works for me.  I have a system crontab like this...

*/5 * * * * python /home/www-data/web2py/web2py.py -S init -M -N -R /
home/www-data/web2py/applications/init/modules/cron.py

And cron.py runs just like it should.  Here's a basic layout that you
can use to test it's working...

==modules/cron.py==
#!/usr/bin/env python
# coding: utf8

import os
import sys
import datetime
message_log = ['Started at %s' % datetime.datetime.now()]

try:
# Put your processing stuff here

db.commit()
message_log.append('Process good')
except:
import traceback
message_log.append('Cron Failure: %s' % traceback.format_exc())

message_log.append('Ended at %s' % datetime.datetime.now())
mail.send(settings.system_email, "Cron Report",
'\n'.join(message_log))





On May 17, 12:42 pm, pbreit  wrote:
> I'm still struggling with how to deploy cron in production.
>
> I currently have a crontab on my production server set up with:
>
> 0-59/1 * * * * cd /var/web2py && python web2py.py -C -D 1 >>
> /tmp/cron.output 2>&1
>
> And a couple tasks in my web2py crontab:
> */1 * * * * root *cron/email_watchlist
> 0 2 * * * root *cron/google_feed
>
> It seems like the */1 tasks get run but not the 0 2 one.
>
> I'm about to give up and just wget URLs:
> */1 * * * * wgethttp://localhost/cron/email_watchlist>/dev/null 2>&1
> 00 2 * * * wgethttp://localhost/cron/google_feed>/dev/null 2>&1
>
> Is this how external cron is supposed to work? What are other people doing
> that works? Any suggestions?


[web2py] Re: Need advice on Cron in production

2011-05-17 Thread Russell
Yes, I have two lines in the crontab.  A five minute one, and a daily
one...


*/5 * * * * python /home/www-data/web2py/web2py.py -S init -M -N -R /
home/www-data/web2py/applications/init/modules/scripts/cron_fivemin.py
1 22 * * 1-5 python /home/www-data/web2py/web2py.py -S init -M -N -R /
home/www-data/web2py/applications/init/modules/scripts/cron_daily.py


On May 18, 12:13 pm, pbreit  wrote:
> Cool, thanks or the examples. So do you have one line in our system crontab
> for each job? And then one cronXX.py file on modules for each task?
>
> I have some tasks that go every minute and some that go daily.
>
> There's no way to specify a function through the command line, correct?


[web2py] Re: Strange Error: Field does not belong to the table

2011-06-16 Thread Russell
Looks like the form.accepts is trying to update the database with the
is_administrator value.  You may need to deal with the update
explicitly.  Have you tried form.accepts(request.vars, session,
dbio=False)?


On Jun 14, 1:21 pm, Ross Peoples  wrote:
> I am trying to provide an editor for auth_user using SQLFORM. I also am
> trying to add a checkbox to the bottom of the form to set whether or not the
> user is an administrator. If so, then the user gets added to an
> Administrators group when calling form.accepts().
>
> The strange part is, the code works fine if you check the box, then click
> submit, but if you try to uncheck the box, that's when you get the following
> traceback:
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
> 21.
> 22.
>
> Traceback (most recent call last):
>   File "/media/psf/Python/web2py/gluon/restricted.py", line 192, in restricted
>     exec ccode in environment
>   File 
> "/Users/rosspeoples/Dropbox/Code/Python/web2py/applications/init/controllers/administration.py"
>  , line 
> 650, in 
>   File "/media/psf/Python/web2py/gluon/globals.py", line 137, in 
>     self._caller = lambda f: f()
>   File "/Users/rosspeoples/Dropbox/Code/Python/web2py/gluon/tools.py", line 
> 2485, in f
>     return action(*a, **b)
>   File 
> "/Users/rosspeoples/Dropbox/Code/Python/web2py/applications/init/controllers/administration.py"
>  , line 
> 148, in security
>     return update()
>   File 
> "/Users/rosspeoples/Dropbox/Code/Python/web2py/applications/init/controllers/administration.py"
>  , line 
> 143, in update
>     return user_form(user)
>   File 
> "/Users/rosspeoples/Dropbox/Code/Python/web2py/applications/init/controllers/administration.py"
>  , line 
> 120, in user_form
>     if form.accepts(request.vars, session):
>   File "/media/psf/Python/web2py/gluon/sqlhtml.py", line 1203, in accepts
>     self.table._db(self.table._id == self.record.id).update(**fields)
>   File "/Users/rosspeoples/Dropbox/Code/Python/web2py/gluon/dal.py", line 
> 5401, in update
>     fields = self.db[tablename]._listify(update_fields,update=True)
>   File "/Users/rosspeoples/Dropbox/Code/Python/web2py/gluon/dal.py", line 
> 4677, in _listify
>     raise SyntaxError, 'Field %s does not belong to the table' % name
> SyntaxError: Field is_administrator does not belong to the table
>
> And here is the controller that is adding the checkbox:
>
>         form = SQLFORM(db.auth_user, user, showid=False)
>         form[0].insert(-1, TR((
>             TD(LABEL('Is Administrator',
> _for='auth_user_is_administrator')),
>             TD(INPUT(_type='checkbox', _name='is_administrator',
> _id='auth_user_is_administrator'))
>         )))
>
>         form.vars.is_administrator = False
>         if user:
>             if auth.has_membership(user_id=user.id, role='Administrators'):
>                 form.vars.is_administrator = True
>
>         if form.accepts(request.vars, session):
>             admin_group =
> db(db.auth_group.role=='Administrators').select().first()
>             db((db.auth_membership.user_id==user.id) &
> (db.auth_membership.group_id==admin_group.id)).delete()
>
>             if form.vars.is_administrator:
>                 db.auth_membership.insert(group_id=admin_group.id,
> user_id=user.id)
>
>             return 'OK'
>
>         return dict(form=form)
>
> The thing that is driving me nuts is that I am doing exactly what the book
> says to do:
>
> http://web2py.com/book/default/chapter/07#Adding-extra-form-elements-...
>
> Any thoughts? Thanks.


Re: [web2py] Re: nyroModal

2011-11-06 Thread Russell McMurray
Hi Kenneth,

nyroModalRemove() is a standard nyroModal call.  What version of nyroModal
are you using?  I'm using 1.6.2, which I see has been replaced by version
2, so maybe the call is depreciated?  My only other thought is...are you
opening nyroModal in an iframe?  I initiate the modal window from the
parent view like this:

  $('.nyroEdit').click(function(e) {
e.preventDefault();
$.nyroModalManual({
  url: $(this).attr('href'),
  forceType: 'iframe'
});
return false;
  });
With links that look like this...

name_goes_here

It works for me.

2011/11/5 Kenneth Lundström 

> Hi Russell,
>
> Have you defined nyroModalRemove somewhere? I'm getting
> "parent.$.nyroModalRemove is not a function" when using your suggested
> three lines.
>
>
> Kenneth
>
> return_script = ['parent.$.nyroModalRemove();'**]
>> return_script.append('parent.**window.location.reload();')
>> return HTML(BODY(SCRIPT(''.join(**return_script.xml()
>>
>
>


Re: [web2py] 3 forms in 1

2013-06-18 Thread Tom Russell
Yes I was just reading and understood that the reason for my fields not
showing up was because the fields in many of the tables have the same
names. Changing that resolved that issue.

It's actually a great book too, just wished I could read faster.

Thanks.


On Tue, Jun 18, 2013 at 1:04 PM, Richard Vézina  wrote:

> I think you have 1 form for 3 tables...
>
> You should package a dummy app with the code above to help us helping
> you...
>
> As far as I understand you got the id only because you didn't set requires
> in your model. Read the book about validators and search for "requires" in
> the book.
>
> Richard
>
>
> On Tue, Jun 18, 2013 at 11:40 AM,  wrote:
>
>> I have one page where I want to show 3 forms. I have a main table with 2
>> tables that are related to it.
>>
>> So in my models file I have:
>>
>> db.define_table(
>> 'dependents',
>> Field('dep_id',db.patient),
>> Field('first_name'),
>> Field('middle_name'),
>> Field('last_name'),
>> Field('relationship', 'text'))
>>
>> db.define_table(
>> 'emergencycontacts',
>> Field('ec_id',db.patient),
>> Field('first_name'),
>> Field('middle_name'),
>> Field('last_name'),
>> Field('address1'),
>> Field('address2'),
>> Field('city'),
>> Field('state'),
>> Field('zipcode'),
>> Field('country'),
>> Field('phone'),
>> Field('relationship'))
>>
>> And db.patient is another table.
>>
>> So in my form I have:
>>
>> def register_patient():
>> form=SQLFORM.factory(db.patient,db.emergencycontacts, db.dependents)
>> if form.process().accepted:
>> id = db.patient.insert(**db.patient._filter_fields(form.vars))
>> form.vars.patient=id
>> id =
>> db.emergencycontacts.insert(**db.emergencycontacts._filter_fields(form.vars))
>> response.flash='Thanks for filling the form'
>> id =
>> db.dependents.insert(**db.dependents._filter_fields(form.vars))
>> form.vars.dependents=id
>> # and get a list of all persons
>> records =
>> SQLTABLE(db().select(db.patient.ALL),headers='fieldname:capitalize')
>>
>> return dict(form=form, records=records)
>>
>> So the form displays correctly but I was expecting that the other fields
>> for dependents and emergencycontacts would be there for input as well but I
>> only get the id fields showing up for input.
>>
>> Am I doing what I want to do incorrectly?
>>
>> Thanks,
>>
>> Tom
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: 3 forms in 1

2013-06-18 Thread Tom Russell
Yes I am using smartgrid elsewhere, very nice. I did do the 3 forms but
used the factory to do it. Works nicely so far.


On Tue, Jun 18, 2013 at 1:24 PM, villas  wrote:

> I don't believe you can use SQLFORM in that way,  you'll have to create
> your own form - maybe try SQLFORM.factory.  Better still,  try
> SQLFORM.smartgrid which could allow you a very flexible way to manage all
> three tables.
>
>
>
> On Tuesday, 18 June 2013 16:40:40 UTC+1, t...@caregointl.com wrote:
>>
>> I have one page where I want to show 3 forms. I have a main table with 2
>> tables that are related to it.
>>
>> So in my models file I have:
>>
>> db.define_table(
>> 'dependents',
>> Field('dep_id',db.patient),
>> Field('first_name'),
>> Field('middle_name'),
>> Field('last_name'),
>> Field('relationship', 'text'))
>>
>> db.define_table(
>> 'emergencycontacts',
>> Field('ec_id',db.patient),
>> Field('first_name'),
>> Field('middle_name'),
>> Field('last_name'),
>> Field('address1'),
>> Field('address2'),
>> Field('city'),
>> Field('state'),
>> Field('zipcode'),
>> Field('country'),
>> Field('phone'),
>> Field('relationship'))
>>
>> And db.patient is another table.
>>
>> So in my form I have:
>>
>> def register_patient():
>> form=SQLFORM.factory(db.**patient,db.emergencycontacts,
>> db.dependents)
>> if form.process().accepted:
>> id = db.patient.insert(**db.**patient._filter_fields(form.**
>> vars))
>> form.vars.patient=id
>> id = db.emergencycontacts.insert(
>> db.emergencycontacts._filter_**fields(form.vars))
>> response.flash='Thanks for filling the form'
>> id = db.dependents.insert(**db.**dependents._filter_fields(**
>> form.vars))
>> form.vars.dependents=id
>> # and get a list of all persons
>> records = SQLTABLE(db().select(db.**patient.ALL),headers='**
>> fieldname:capitalize')
>>
>> return dict(form=form, records=records)
>>
>> So the form displays correctly but I was expecting that the other fields
>> for dependents and emergencycontacts would be there for input as well but I
>> only get the id fields showing up for input.
>>
>> Am I doing what I want to do incorrectly?
>>
>> Thanks,
>>
>> Tom
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: SmartGrid

2013-06-19 Thread Tom Russell
aha that would be it.


On Wed, Jun 19, 2013 at 5:26 PM, Niphlod  wrote:

> are you logged-in ?
> For security reasons any modification to tables in grids is prevented on
> anonymous access.
> You can still give "write permissions" using user_signature=False, but
> it's highly discouraged
>
> On Wednesday, June 19, 2013 5:25:58 PM UTC+2, t...@caregointl.com wrote:
>>
>> I have a smartgrid set up like this:
>>
>> def manage_patients():
>> grid = SQLFORM.smartgrid(db.patient, deletable=True, editable=True,
>> create=True, linked_tables=['**emergencycontacts','**dependents'])
>> return dict(grid=grid)
>>
>>
>> It displays fine but only has a view button to the far right. How do I
>> have the add, edit and delete buttons as well?
>>
>> Thanks.
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Change form layout

2013-06-24 Thread Tom Russell
I have a SQLForm and use the formset DIV for it but its not what I really
want. Rather than having just one column with all of the fields required to
be filled out, how do I set it so its like 3-4 columns?

For example:

Name  Address  City  State

Instead of:

Name
Address
City
State

Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Change form layout

2013-06-24 Thread Tom Russell
Thanks for the response. So now I am really confused because I have no idea
where to put this code if I am using a SQLFORM.factory?

Basically I just want to add row fluid to make the layout a little easier
to navigate. I do not have a html file to set this code in for this form.

Thanks.


On Mon, Jun 24, 2013 at 9:04 AM, Anthony  wrote:

> http://web2py.com/books/default/chapter/29/07#Custom-forms
>
> I don't think it's in the book yet, but you can also create a custom
> formstyle if you need to use the layout in multiple places:
> https://groups.google.com/d/msg/web2py/QmoRmapiOwA/tZqeEbii6QgJ
>
> Anthony
>
>
> On Monday, June 24, 2013 8:53:16 AM UTC-4, Tom Russell wrote:
>>
>> I have a SQLForm and use the formset DIV for it but its not what I really
>> want. Rather than having just one column with all of the fields required to
>> be filled out, how do I set it so its like 3-4 columns?
>>
>> For example:
>>
>> Name  Address  City  State
>>
>> Instead of:
>>
>> Name
>> Address
>> City
>> State
>>
>> Thanks.
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Change form layout

2013-06-24 Thread Tom Russell
Thanks for the responses.

The formstyle looks interesting but I cannot make heads or tails out of the
way to use it. Are there any examples of this some place?

Thanks


On Mon, Jun 24, 2013 at 9:55 AM, Anthony  wrote:

> I assume that means you are relying on a generic view to display your
> table. If so, you can instead create a non-generic view (which you should
> probably do anyway), or you can build the form DOM on the server using
> web2py HTML helpers (probably not the way to go). The custom formstyle
> option also does not require any HTML coding.
>
> Anthony
>
>
> On Monday, June 24, 2013 9:35:31 AM UTC-4, Tom Russell wrote:
>
>> Thanks for the response. So now I am really confused because I have no
>> idea where to put this code if I am using a SQLFORM.factory?
>>
>> Basically I just want to add row fluid to make the layout a little easier
>> to navigate. I do not have a html file to set this code in for this form.
>>
>> Thanks.
>>
>>
>> On Mon, Jun 24, 2013 at 9:04 AM, Anthony  wrote:
>>
>>> http://web2py.com/books/**default/chapter/29/07#Custom-**forms<http://web2py.com/books/default/chapter/29/07#Custom-forms>
>>>
>>> I don't think it's in the book yet, but you can also create a custom
>>> formstyle if you need to use the layout in multiple places:
>>> https://groups.google.**com/d/msg/web2py/QmoRmapiOwA/**tZqeEbii6QgJ<https://groups.google.com/d/msg/web2py/QmoRmapiOwA/tZqeEbii6QgJ>
>>>
>>> Anthony
>>>
>>>
>>> On Monday, June 24, 2013 8:53:16 AM UTC-4, Tom Russell wrote:
>>>>
>>>> I have a SQLForm and use the formset DIV for it but its not what I
>>>> really want. Rather than having just one column with all of the fields
>>>> required to be filled out, how do I set it so its like 3-4 columns?
>>>>
>>>> For example:
>>>>
>>>> Name  Address  City  State
>>>>
>>>> Instead of:
>>>>
>>>> Name
>>>> Address
>>>> City
>>>> State
>>>>
>>>> Thanks.
>>>>
>>>  --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+un...@**googlegroups.com.
>>>
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Change form layout

2013-06-24 Thread Tom Russell
Thanks again for the info.

I guess I still do not get it though if I set my formstyle to table3cols
would'nt my form at least be laid out like:

Name Address City
State

Or am I not looking at this correctly?


On Mon, Jun 24, 2013 at 10:16 AM, Anthony  wrote:

> Your best bet is to look at how the built-in ones work, starting here:
> https://code.google.com/p/web2py/source/browse/gluon/sqlhtml.py#752. Copy
> the one of those that is closest to what you want and modify it as
> necessary.
>
> def myformstyle():
> [custom code here]
>
> form = SQLFORM(..., formstyle=myformstyle)
>
> Anthony
>
>
> On Monday, June 24, 2013 10:07:49 AM UTC-4, Tom Russell wrote:
>
>> Thanks for the responses.
>>
>> The formstyle looks interesting but I cannot make heads or tails out of
>> the way to use it. Are there any examples of this some place?
>>
>> Thanks
>>
>>
>> On Mon, Jun 24, 2013 at 9:55 AM, Anthony  wrote:
>>
>>> I assume that means you are relying on a generic view to display your
>>> table. If so, you can instead create a non-generic view (which you should
>>> probably do anyway), or you can build the form DOM on the server using
>>> web2py HTML helpers (probably not the way to go). The custom formstyle
>>> option also does not require any HTML coding.
>>>
>>> Anthony
>>>
>>>
>>> On Monday, June 24, 2013 9:35:31 AM UTC-4, Tom Russell wrote:
>>>
>>>> Thanks for the response. So now I am really confused because I have no
>>>> idea where to put this code if I am using a SQLFORM.factory?
>>>>
>>>> Basically I just want to add row fluid to make the layout a little
>>>> easier to navigate. I do not have a html file to set this code in for this
>>>> form.
>>>>
>>>> Thanks.
>>>>
>>>>
>>>> On Mon, Jun 24, 2013 at 9:04 AM, Anthony  wrote:
>>>>
>>>>> http://web2py.com/books/**defaul**t/chapter/29/07#Custom-**forms<http://web2py.com/books/default/chapter/29/07#Custom-forms>
>>>>>
>>>>> I don't think it's in the book yet, but you can also create a custom
>>>>> formstyle if you need to use the layout in multiple places:
>>>>> https://groups.google.com/d/msg/web2py/QmoRmapiOwA/**t**
>>>>> ZqeEbii6QgJ<https://groups.google.com/d/msg/web2py/QmoRmapiOwA/tZqeEbii6QgJ>
>>>>>
>>>>> Anthony
>>>>>
>>>>>
>>>>> On Monday, June 24, 2013 8:53:16 AM UTC-4, Tom Russell wrote:
>>>>>>
>>>>>> I have a SQLForm and use the formset DIV for it but its not what I
>>>>>> really want. Rather than having just one column with all of the fields
>>>>>> required to be filled out, how do I set it so its like 3-4 columns?
>>>>>>
>>>>>> For example:
>>>>>>
>>>>>> Name  Address  City  State
>>>>>>
>>>>>> Instead of:
>>>>>>
>>>>>> Name
>>>>>> Address
>>>>>> City
>>>>>> State
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>  --
>>>>>
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "web2py-users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to web2py+un...@**googlegroups.com.
>>>>>
>>>>> For more options, visit 
>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out>
>>>>> .
>>>>>
>>>>>
>>>>>
>>>>
>>>>  --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+un...@**googlegroups.com.
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Change form layout

2013-06-24 Thread Tom Russell
Ah, I see now.

Thanks


On Mon, Jun 24, 2013 at 10:50 AM, Anthony  wrote:

> No, 3 columns means:
>
> Col 1   Col 2 Col 3
> label   widget   comment
>
> It's still one field per row. When in doubt, try it out. :-)
>
> Anthony
>
>
> On Monday, June 24, 2013 10:26:08 AM UTC-4, Tom Russell wrote:
>
>> Thanks again for the info.
>>
>> I guess I still do not get it though if I set my formstyle to table3cols
>> would'nt my form at least be laid out like:
>>
>> Name Address City
>> State
>>
>> Or am I not looking at this correctly?
>>
>>
>> On Mon, Jun 24, 2013 at 10:16 AM, Anthony  wrote:
>>
>>> Your best bet is to look at how the built-in ones work, starting here:
>>> https://code.google.com/**p/web2py/source/browse/gluon/**sqlhtml.py#752<https://code.google.com/p/web2py/source/browse/gluon/sqlhtml.py#752>.
>>> Copy the one of those that is closest to what you want and modify it as
>>> necessary.
>>>
>>> def myformstyle():
>>> [custom code here]
>>>
>>> form = SQLFORM(..., formstyle=myformstyle)
>>>
>>> Anthony
>>>
>>>
>>> On Monday, June 24, 2013 10:07:49 AM UTC-4, Tom Russell wrote:
>>>
>>>> Thanks for the responses.
>>>>
>>>> The formstyle looks interesting but I cannot make heads or tails out of
>>>> the way to use it. Are there any examples of this some place?
>>>>
>>>> Thanks
>>>>
>>>>
>>>> On Mon, Jun 24, 2013 at 9:55 AM, Anthony  wrote:
>>>>
>>>>> I assume that means you are relying on a generic view to display your
>>>>> table. If so, you can instead create a non-generic view (which you should
>>>>> probably do anyway), or you can build the form DOM on the server using
>>>>> web2py HTML helpers (probably not the way to go). The custom formstyle
>>>>> option also does not require any HTML coding.
>>>>>
>>>>> Anthony
>>>>>
>>>>>
>>>>> On Monday, June 24, 2013 9:35:31 AM UTC-4, Tom Russell wrote:
>>>>>
>>>>>> Thanks for the response. So now I am really confused because I have
>>>>>> no idea where to put this code if I am using a SQLFORM.factory?
>>>>>>
>>>>>> Basically I just want to add row fluid to make the layout a little
>>>>>> easier to navigate. I do not have a html file to set this code in for 
>>>>>> this
>>>>>> form.
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>>
>>>>>> On Mon, Jun 24, 2013 at 9:04 AM, Anthony  wrote:
>>>>>>
>>>>>>> http://web2py.com/books/**default/chapter/29/07#Custom-**forms<http://web2py.com/books/default/chapter/29/07#Custom-forms>
>>>>>>>
>>>>>>> I don't think it's in the book yet, but you can also create a custom
>>>>>>> formstyle if you need to use the layout in multiple places:
>>>>>>> https://groups.google.**com/d/msg/web2py/QmoRmapiOwA/**t
>>>>>>> ZqeEbii6QgJ<https://groups.google.com/d/msg/web2py/QmoRmapiOwA/tZqeEbii6QgJ>
>>>>>>>
>>>>>>> Anthony
>>>>>>>
>>>>>>>
>>>>>>> On Monday, June 24, 2013 8:53:16 AM UTC-4, Tom Russell wrote:
>>>>>>>>
>>>>>>>> I have a SQLForm and use the formset DIV for it but its not what I
>>>>>>>> really want. Rather than having just one column with all of the fields
>>>>>>>> required to be filled out, how do I set it so its like 3-4 columns?
>>>>>>>>
>>>>>>>> For example:
>>>>>>>>
>>>>>>>> Name  Address  City  State
>>>>>>>>
>>>>>>>> Instead of:
>>>>>>>>
>>>>>>>> Name
>>>>>>>> Address
>>>>>>>> City
>>>>>>>> State
>>>>>>>>
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>  --
>>>>>>>
>>>>>>> ---
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "we

[web2py] SQLForm Factory

2013-06-24 Thread Tom Russell
If I have a form factory with 3 tables, how would I define the fields I
wanted shown for each?

This is the code for my controller. I have tried to set it in several spots
but all of them throw an error.

def register_patient():
mark_not_empty(db.patient)
mark_not_empty(db.emergencycontacts)
mark_not_empty(db.dependents)
form=SQLFORM.factory(db.patient, db.emergencycontacts, db.dependents,
formstyle = 'table3cols')
fs0=form[0][:28] # the first two name rows
fs1=form[0][28:40]   # the wine data rows (all but the last)
fs2=form[0][40:45] # submit row (last)
fs3=form[0][-1] # submit row (last)

form.vars.medical_record_number = 'KND' + str(date.today().year) +
'' + str(random.randrange(1, 999+1))

form[0]=TABLE(
FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
FIELDSET(TAG.legend("Emergency Contact
Info"),TABLE(fs1),_id="register1"),
FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
TABLE(fs3))
if form.process().accepted:
id = db.patient.insert(**db.patient._filter_fields(form.vars))
form.vars.patient=id
id =
db.emergencycontacts.insert(**db.emergencycontacts._filter_fields(form.vars))
response.flash='Thanks for filling the form'
id = db.dependents.insert(**db.dependents._filter_fields(form.vars))
form.vars.dependents=id
# and get a list of all persons
redirect(URL('manage_patients'))

style = STYLE(""".not_empty {color:#d00;}""")

return dict(form=DIV(style,form))


Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: SQLForm Factory

2013-06-24 Thread Tom Russell
I tried doing the specific fields like:

form=SQLFORM.factory(db.patient(fields=['first_name']),
db.emergencycontacts, db.dependents, formstyle = 'table3cols')

but that just throws an error saying no tables selected. I guess what I am
trying to do is set certain fields to be show for each table and read the
book but do not see how I would set it in my code as such. All of the
examples I have seen so far show only 1 table at a time.


On Mon, Jun 24, 2013 at 11:29 AM, Anthony  wrote:

> You can set the readable and writable attributes of the fields, or
> .factory() can take a list of specific fields rather than entire tables.
>
> Anthony
>
>
> On Monday, June 24, 2013 11:15:28 AM UTC-4, Tom Russell wrote:
>>
>> If I have a form factory with 3 tables, how would I define the fields I
>> wanted shown for each?
>>
>> This is the code for my controller. I have tried to set it in several
>> spots but all of them throw an error.
>>
>> def register_patient():
>> mark_not_empty(db.patient)
>> mark_not_empty(db.**emergencycontacts)
>> mark_not_empty(db.dependents)
>> form=SQLFORM.factory(db.**patient, db.emergencycontacts,
>> db.dependents, formstyle = 'table3cols')
>> fs0=form[0][:28] # the first two name rows
>> fs1=form[0][28:40]   # the wine data rows (all but the last)
>> fs2=form[0][40:45] # submit row (last)
>> fs3=form[0][-1] # submit row (last)
>>
>> form.vars.medical_record_**number = 'KND' + str(date.today().year) +
>> '' + str(random.randrange(1, 999+1))
>>
>> form[0]=TABLE(
>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="**register0"),
>> FIELDSET(TAG.legend("Emergency Contact Info"),TABLE(fs1),_id="**
>> register1"),
>> FIELDSET(TAG.legend("**Dependents"),TABLE(fs2),_id="**register2"),
>> TABLE(fs3))
>> if form.process().accepted:
>> id = db.patient.insert(**db.**patient._filter_fields(form.**
>> vars))
>> form.vars.patient=id
>> id = db.emergencycontacts.insert(
>> db.emergencycontacts._filter_**fields(form.vars))
>> response.flash='Thanks for filling the form'
>> id = db.dependents.insert(**db.**dependents._filter_fields(**
>> form.vars))
>> form.vars.dependents=id
>> # and get a list of all persons
>> redirect(URL('manage_patients'**))
>>
>> style = STYLE(""".not_empty {color:#d00;}""")
>>
>> return dict(form=DIV(style,form))
>>
>>
>> Thanks.
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: SQLForm Factory

2013-06-24 Thread Tom Russell
Thanks for the tip.

I did set one field to not be readable like this:

Field('alternatepid', label='Alternate PID', readable=False),

but it still shows on my form.

Should'nt be there should it?

Thanks.


On Mon, Jun 24, 2013 at 1:57 PM, Anthony  wrote:

> db.patient(fields=['first_name'])
>
> No, the above isn't web2py syntax -- don't know where you saw that. As I
> mentioned, to control which fields are shown, you can set the readable and
> writable attributes of the fields (check the book), or you can list
> individual fields instead of entire tables:
>
> SQLFORM.factory(db.mytable.myfield, db.mytable.myotherfield, db.wholetable
> )
>
> Anthony
>
>
> On Monday, June 24, 2013 11:49:43 AM UTC-4, Tom Russell wrote:
>
>> I tried doing the specific fields like:
>>
>> form=SQLFORM.factory(db.**patient(fields=['first_name'])**,
>> db.emergencycontacts, db.dependents, formstyle = 'table3cols')
>>
>> but that just throws an error saying no tables selected. I guess what I
>> am trying to do is set certain fields to be show for each table and read
>> the book but do not see how I would set it in my code as such. All of the
>> examples I have seen so far show only 1 table at a time.
>>
>>
>> On Mon, Jun 24, 2013 at 11:29 AM, Anthony  wrote:
>>
>>> You can set the readable and writable attributes of the fields, or
>>> .factory() can take a list of specific fields rather than entire tables.
>>>
>>> Anthony
>>>
>>>
>>> On Monday, June 24, 2013 11:15:28 AM UTC-4, Tom Russell wrote:
>>>>
>>>> If I have a form factory with 3 tables, how would I define the fields I
>>>> wanted shown for each?
>>>>
>>>> This is the code for my controller. I have tried to set it in several
>>>> spots but all of them throw an error.
>>>>
>>>> def register_patient():
>>>> mark_not_empty(db.patient)
>>>> mark_not_empty(db.**emergencycon**tacts)
>>>> mark_not_empty(db.dependents)
>>>> form=SQLFORM.factory(db.**patien**t, db.emergencycontacts,
>>>> db.dependents, formstyle = 'table3cols')
>>>> fs0=form[0][:28] # the first two name rows
>>>> fs1=form[0][28:40]   # the wine data rows (all but the last)
>>>> fs2=form[0][40:45] # submit row (last)
>>>> fs3=form[0][-1] # submit row (last)
>>>>
>>>> form.vars.medical_record_**numbe**r = 'KND' +
>>>> str(date.today().year) + '' + str(random.randrange(1, 999+1))
>>>>
>>>> form[0]=TABLE(
>>>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="**registe**
>>>> r0"),
>>>> FIELDSET(TAG.legend("Emergency Contact Info"),TABLE(fs1),_id="**
>>>> registe**r1"),
>>>> FIELDSET(TAG.legend("**Dependent**s"),TABLE(fs2),_id="**register2"*
>>>> *),
>>>> TABLE(fs3))
>>>> if form.process().accepted:
>>>> id = db.patient.insert(**db.**patient**._filter_fields(form.**
>>>> vars))
>>>> form.vars.patient=id
>>>> id = db.emergencycontacts.insert(**
>>>> db.emergencycontacts._filter_**f**ields(form.vars))
>>>> response.flash='Thanks for filling the form'
>>>> id = db.dependents.insert(**db.**depe**ndents._filter_fields(**
>>>> form.**vars))
>>>> form.vars.dependents=id
>>>> # and get a list of all persons
>>>> redirect(URL('manage_patients'))
>>>>
>>>> style = STYLE(""".not_empty {color:#d00;}""")
>>>>
>>>> return dict(form=DIV(style,form))
>>>>
>>>>
>>>> Thanks.
>>>>
>>>  --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+un...@**googlegroups.com.
>>>
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: SQLForm Factory

2013-06-24 Thread Tom Russell
Ah yes both readable and writable have to be defined. Thanks again


On Mon, Jun 24, 2013 at 6:12 PM, Anthony  wrote:

> Try writable=False.
>
>
> On Monday, June 24, 2013 6:04:43 PM UTC-4, Tom Russell wrote:
>
>> Thanks for the tip.
>>
>> I did set one field to not be readable like this:
>>
>> Field('alternatepid', label='Alternate PID', readable=False),
>>
>> but it still shows on my form.
>>
>> Should'nt be there should it?
>>
>> Thanks.
>>
>>
>> On Mon, Jun 24, 2013 at 1:57 PM, Anthony  wrote:
>>
>>> db.patient(fields=['first_**name'])
>>>
>>> No, the above isn't web2py syntax -- don't know where you saw that. As I
>>> mentioned, to control which fields are shown, you can set the readable and
>>> writable attributes of the fields (check the book), or you can list
>>> individual fields instead of entire tables:
>>>
>>> SQLFORM.factory(db.mytable.myf**ield, db.mytable.myotherfield, db.
>>> wholetable)
>>>
>>> Anthony
>>>
>>>
>>> On Monday, June 24, 2013 11:49:43 AM UTC-4, Tom Russell wrote:
>>>
>>>> I tried doing the specific fields like:
>>>>
>>>> form=SQLFORM.factory(db.**patien**t(fields=['first_name'])**,
>>>> db.emergencycontacts, db.dependents, formstyle = 'table3cols')
>>>>
>>>> but that just throws an error saying no tables selected. I guess what I
>>>> am trying to do is set certain fields to be show for each table and read
>>>> the book but do not see how I would set it in my code as such. All of the
>>>> examples I have seen so far show only 1 table at a time.
>>>>
>>>>
>>>> On Mon, Jun 24, 2013 at 11:29 AM, Anthony  wrote:
>>>>
>>>>> You can set the readable and writable attributes of the fields, or
>>>>> .factory() can take a list of specific fields rather than entire tables.
>>>>>
>>>>> Anthony
>>>>>
>>>>>
>>>>> On Monday, June 24, 2013 11:15:28 AM UTC-4, Tom Russell wrote:
>>>>>>
>>>>>> If I have a form factory with 3 tables, how would I define the fields
>>>>>> I wanted shown for each?
>>>>>>
>>>>>> This is the code for my controller. I have tried to set it in several
>>>>>> spots but all of them throw an error.
>>>>>>
>>>>>> def register_patient():
>>>>>> mark_not_empty(db.patient)
>>>>>> mark_not_empty(db.**emergencycontacts)
>>>>>> mark_not_empty(db.dependents)
>>>>>> form=SQLFORM.factory(db.**patient, db.emergencycontacts,
>>>>>> db.dependents, formstyle = 'table3cols')
>>>>>> fs0=form[0][:28] # the first two name rows
>>>>>> fs1=form[0][28:40]   # the wine data rows (all but the last)
>>>>>> fs2=form[0][40:45] # submit row (last)
>>>>>> fs3=form[0][-1] # submit row (last)
>>>>>>
>>>>>> form.vars.medical_record_**number = 'KND' +
>>>>>> str(date.today().year) + '' + str(random.randrange(1, 999+1))
>>>>>>
>>>>>> form[0]=TABLE(
>>>>>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="**registe
>>>>>> r0"),
>>>>>> FIELDSET(TAG.legend("Emergency Contact Info"),TABLE(fs1),_id="**
>>>>>> register1"),
>>>>>> FIELDSET(TAG.legend("**Dependents"),TABLE(fs2),_id="**
>>>>>> register2"),
>>>>>> TABLE(fs3))
>>>>>> if form.process().accepted:
>>>>>> id = db.patient.insert(**db.**patient
>>>>>> ._filter_fields(form.**vars))
>>>>>> form.vars.patient=id
>>>>>> id = db.emergencycontacts.insert(
>>>>>> db.emergencycontacts._filter_**fields(form.vars))
>>>>>> response.flash='Thanks for filling the form'
>>>>>> id = db.dependents.insert(**db.**depe
>>>>>> ndents._filter_fields(**form.**var**s))
>>>>>> form.vars.dependents=id
>>>>>> # and get a list of all pers

[web2py] Form Field

2013-06-24 Thread Tom Russell
I have a form and I load a pre existing value that I generate internally
before I call the form. What I want to see on the form is the value shown
up but just as plain text so the user cannot modify it. If I do
readable-False then it just shows None for the value rather than the value.

How would I make that happen on the form then?

Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Form Field

2013-06-24 Thread Tom Russell
Yes I tried that:

Field('medical_record_number',  label='MRN', writable=False, readable=True,
requires=IS_NOT_EMPTY()),

Still just shows none for the field on the form.

In my controller this is what I am doing:

form.vars.medical_record_number = 'KND' + str(date.today().year) + '' +
str(random.randrange(1, 999+1))

If I set both to True then it shows the value no problem.

Thanks,

Tom


On Mon, Jun 24, 2013 at 11:17 PM, Anthony  wrote:

> db.mytable.myfield.default = some_value
> db.mytable.myfield.writable = False
>
> Leave readable at True in order to show the value but not allow it to be
> edited.
>
> Anthony
>
>
> On Monday, June 24, 2013 11:00:59 PM UTC-4, Tom Russell wrote:
>>
>> I have a form and I load a pre existing value that I generate internally
>> before I call the form. What I want to see on the form is the value shown
>> up but just as plain text so the user cannot modify it. If I do
>> readable-False then it just shows None for the value rather than the value.
>>
>> How would I make that happen on the form then?
>>
>> Thanks.
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Form Field

2013-06-24 Thread Tom Russell
I ended up doing this in the controller which works for what I need:

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


On Tue, Jun 25, 2013 at 12:03 AM, Anthony  wrote:

> I'm not sure that method will work for readonly fields, so you may have to
> use the method I showed (i.e., set the default value for the field before
> creating the form).
>
> Anthony
>
>
> On Monday, June 24, 2013 11:23:01 PM UTC-4, Tom Russell wrote:
>
>> Yes I tried that:
>>
>> Field('medical_record_number',  label='MRN', writable=False,
>> readable=True, requires=IS_NOT_EMPTY()),
>>
>> Still just shows none for the field on the form.
>>
>> In my controller this is what I am doing:
>>
>> form.vars.medical_record_**number = 'KND' + str(date.today().year) +
>> '' + str(random.randrange(1, 999+1))
>>
>> If I set both to True then it shows the value no problem.
>>
>> Thanks,
>>
>> Tom
>>
>>
>> On Mon, Jun 24, 2013 at 11:17 PM, Anthony  wrote:
>>
>>> db.mytable.myfield.default = some_value
>>> db.mytable.myfield.writable = False
>>>
>>> Leave readable at True in order to show the value but not allow it to be
>>> edited.
>>>
>>> Anthony
>>>
>>>
>>> On Monday, June 24, 2013 11:00:59 PM UTC-4, Tom Russell wrote:
>>>>
>>>> I have a form and I load a pre existing value that I generate
>>>> internally before I call the form. What I want to see on the form is the
>>>> value shown up but just as plain text so the user cannot modify it. If I do
>>>> readable-False then it just shows None for the value rather than the value.
>>>>
>>>> How would I make that happen on the form then?
>>>>
>>>> Thanks.
>>>>
>>>  --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+un...@**googlegroups.com.
>>>
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Form Field

2013-06-24 Thread Tom Russell
Yes I understand that. What would be the best way to handle this?
Seemingly, the couple of items suggested did not work for me so I am not
sure where that leaves me.


On Tue, Jun 25, 2013 at 12:35 AM, Anthony  wrote:

> Yes that works, though it's not as secure because someone can still submit
> a value for that field if they are determined, so you might want to check
> for that variable on the server and delete it if submitted.
>
> Anthony
>
>
> On Tuesday, June 25, 2013 12:15:04 AM UTC-4, Tom Russell wrote:
>
>> I ended up doing this in the controller which works for what I need:
>>
>> form.element('#no_table_**medical_record_number')['_**readonly']=True
>>
>>
>> On Tue, Jun 25, 2013 at 12:03 AM, Anthony  wrote:
>>
>>> I'm not sure that method will work for readonly fields, so you may have
>>> to use the method I showed (i.e., set the default value for the field
>>> before creating the form).
>>>
>>> Anthony
>>>
>>>
>>> On Monday, June 24, 2013 11:23:01 PM UTC-4, Tom Russell wrote:
>>>
>>>> Yes I tried that:
>>>>
>>>> Field('medical_record_number',  label='MRN', writable=False,
>>>> readable=True, requires=IS_NOT_EMPTY()),
>>>>
>>>> Still just shows none for the field on the form.
>>>>
>>>> In my controller this is what I am doing:
>>>>
>>>> form.vars.medical_record_**numbe**r = 'KND' + str(date.today().year) +
>>>> '' + str(random.randrange(1, 999+1))
>>>>
>>>> If I set both to True then it shows the value no problem.
>>>>
>>>> Thanks,
>>>>
>>>> Tom
>>>>
>>>>
>>>> On Mon, Jun 24, 2013 at 11:17 PM, Anthony  wrote:
>>>>
>>>>>  db.mytable.myfield.default = some_value
>>>>> db.mytable.myfield.writable = False
>>>>>
>>>>> Leave readable at True in order to show the value but not allow it to
>>>>> be edited.
>>>>>
>>>>> Anthony
>>>>>
>>>>>
>>>>> On Monday, June 24, 2013 11:00:59 PM UTC-4, Tom Russell wrote:
>>>>>>
>>>>>> I have a form and I load a pre existing value that I generate
>>>>>> internally before I call the form. What I want to see on the form is the
>>>>>> value shown up but just as plain text so the user cannot modify it. If I 
>>>>>> do
>>>>>> readable-False then it just shows None for the value rather than the 
>>>>>> value.
>>>>>>
>>>>>> How would I make that happen on the form then?
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>  --
>>>>>
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "web2py-users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to web2py+un...@**googlegroups.com.
>>>>>
>>>>> For more options, visit 
>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out>
>>>>> .
>>>>>
>>>>>
>>>>>
>>>>
>>>>  --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+un...@**googlegroups.com.
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Form Field

2013-06-24 Thread Tom Russell
Yes I just tried it and that works fine. That works as expected. Thanks for
the help. Exactly what I was looking for to begin with.


On Tue, Jun 25, 2013 at 1:23 AM, Anthony  wrote:

> Did you try this method (setting these before creating the form):
>
> db.mytable.myfield.default = some_value
> db.mytable.myfield.writable = False
>
> Anthony
>
> On Tuesday, June 25, 2013 1:02:40 AM UTC-4, Tom Russell wrote:
>
>> Yes I understand that. What would be the best way to handle this?
>> Seemingly, the couple of items suggested did not work for me so I am not
>> sure where that leaves me.
>>
>>
>> On Tue, Jun 25, 2013 at 12:35 AM, Anthony  wrote:
>>
>>> Yes that works, though it's not as secure because someone can still
>>> submit a value for that field if they are determined, so you might want to
>>> check for that variable on the server and delete it if submitted.
>>>
>>> Anthony
>>>
>>>
>>> On Tuesday, June 25, 2013 12:15:04 AM UTC-4, Tom Russell wrote:
>>>
>>>> I ended up doing this in the controller which works for what I need:
>>>>
>>>> form.element('#no_table_**medica**l_record_number')['_**readonly']**
>>>> =True
>>>>
>>>>
>>>> On Tue, Jun 25, 2013 at 12:03 AM, Anthony  wrote:
>>>>
>>>>> I'm not sure that method will work for readonly fields, so you may
>>>>> have to use the method I showed (i.e., set the default value for the field
>>>>> before creating the form).
>>>>>
>>>>> Anthony
>>>>>
>>>>>
>>>>> On Monday, June 24, 2013 11:23:01 PM UTC-4, Tom Russell wrote:
>>>>>
>>>>>> Yes I tried that:
>>>>>>
>>>>>> Field('medical_record_number',  label='MRN', writable=False,
>>>>>> readable=True, requires=IS_NOT_EMPTY()),
>>>>>>
>>>>>> Still just shows none for the field on the form.
>>>>>>
>>>>>> In my controller this is what I am doing:
>>>>>>
>>>>>> form.vars.medical_record_**number = 'KND' +
>>>>>> str(date.today().year) + '' + str(random.randrange(1, 999+1))
>>>>>>
>>>>>> If I set both to True then it shows the value no problem.
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Tom
>>>>>>
>>>>>>
>>>>>> On Mon, Jun 24, 2013 at 11:17 PM, Anthony  wrote:
>>>>>>
>>>>>>>  db.mytable.myfield.default = some_value
>>>>>>> db.mytable.myfield.writable = False
>>>>>>>
>>>>>>> Leave readable at True in order to show the value but not allow it
>>>>>>> to be edited.
>>>>>>>
>>>>>>> Anthony
>>>>>>>
>>>>>>>
>>>>>>> On Monday, June 24, 2013 11:00:59 PM UTC-4, Tom Russell wrote:
>>>>>>>>
>>>>>>>> I have a form and I load a pre existing value that I generate
>>>>>>>> internally before I call the form. What I want to see on the form is 
>>>>>>>> the
>>>>>>>> value shown up but just as plain text so the user cannot modify it. If 
>>>>>>>> I do
>>>>>>>> readable-False then it just shows None for the value rather than the 
>>>>>>>> value.
>>>>>>>>
>>>>>>>> How would I make that happen on the form then?
>>>>>>>>
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>  --
>>>>>>>
>>>>>>> ---
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "web2py-users" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to web2py+un...@**googlegroups.com.
>>>>>>>
>>>>>>> For more options, visit https://groups.google.com/**grou
>>>>>>> ps/opt_out <https://groups.google.com/groups/opt_out>.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>  --
>>>>>
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "web2py-users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to web2py+un...@**googlegroups.com.
>>>>> For more options, visit 
>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out>
>>>>> .
>>>>>
>>>>>
>>>>>
>>>>
>>>>  --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+un...@**googlegroups.com.
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Confused about app

2013-06-24 Thread Tom Russell
So I took and modified the welcome app to my needs and added another app.
If I login with the welcome app and with a link, open the other app and
have it set with auth.requires_login(), it requires the user to login
again. How does one handle this stuff in web2py? Do I need another app the
way I have it now?

I am in the mindset of how they do things in django.

Thanks,

Tom

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Confused about app

2013-06-25 Thread Tom Russell
Well agreed, but I set that up in the welcome app so it would seem like
that should move over to my other app as well?


On Tue, Jun 25, 2013 at 2:24 AM, Niphlod  wrote:

> every app has its own auth system. If you want multiple apps to share the
> same "auth system", look at
>
> http://web2py.com/books/default/chapter/29/09#Central-Authentication-Service
>
> Il giorno martedì 25 giugno 2013 07:51:08 UTC+2, Tom Russell ha scritto:
>
>> So I took and modified the welcome app to my needs and added another app.
>> If I login with the welcome app and with a link, open the other app and
>> have it set with auth.requires_login(), it requires the user to login
>> again. How does one handle this stuff in web2py? Do I need another app the
>> way I have it now?
>>
>> I am in the mindset of how they do things in django.
>>
>> Thanks,
>>
>> Tom
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Multi Table Form

2013-06-25 Thread Tom Russell
I have the following form that uses 3 different tables and when I submit
the data it all seems to submit correctly but when I view the data in a
smart grid with linked tables in the columns clicking on the link does not
show any record for the row of linked data.

My smartgrid code:

def manage_patients():
db.patient.id.readable=False # Since we do not want to expose the id
field on the grid
grid = SQLFORM.smartgrid(db.patient, deletable=True, editable=True,
create=True, maxtextlength=64, paginate=25,
linked_tables=['emergencycontacts','dependents'])
return dict(grid=grid)

My linked tables:

db.define_table(
'dependents',
Field('dep_id',db.patient, writable=False, readable=False),
Field('dep_firstname', label='First Name'),
Field('dep_middlename', label='Middle Name'),
Field('dep_lastname', label='Last Name'),
Field('dep_relationship', label='Relationship',
requires=IS_IN_SET(['Aunt', 'Uncle', 'Parent', 'Sibling', 'Spouse',
'Guardian'])),
auth.signature)

db.define_table(
'emergencycontacts',
Field('ec_id',db.patient, writable=False, readable=False),
Field('em_first_name', label='First Name'),
Field('em_middle_name', label='Middle Name'),
Field('em_last_name', label='Last Name'),
Field('em_address1', label='Address1'),
Field('em_address2', label='Address2'),
Field('em_city', label='City'),
Field('em_state', label='State'),
Field('em_zipcode', label='Zip Code'),
Field('em_country', label='Country'),
Field('em_phone', label='Phone'),
Field('em_relationship', label='Relationship',
requires=IS_IN_SET(['Aunt', 'Uncle', 'Parent', 'Sibling', 'Spouse',
'Guardian'])),
auth.signature)

I believe I am doing this correctly but cannot bring up the data for each
row to the linked tables.

Any ideas?

Thanks

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Confused about app

2013-06-25 Thread Tom Russell
Yes I customized welcome and then added a new app via the admin interface.
I did not directly copy the welcome app, just modified the html etc.

Now I am really confused about how this all works. So when I fire up web2py
and create a new app via the admin, should that be my only app then?

So I did implement the CAS stuff but now I get an error saying 'DAL' object
has no attribute 'auth_user' for the app I have.


On Tue, Jun 25, 2013 at 10:53 AM, Anthony  wrote:

> On Tuesday, June 25, 2013 10:12:32 AM UTC-4, Tom Russell wrote:
>
>> Well agreed, but I set that up in the welcome app so it would seem like
>> that should move over to my other app as well?
>>
>
> Are you saying you customized the welcome app and then used admin to
> create a new app? In that case, note that new apps are not created by
> directly copying the existing welcome app folder. Instead, they are created
> by unpacking the welcome.w2p file in the /web2py root folder.
>
> Even if you did get an exact copy of your custom welcome app, including
> the database with the records in db.auth_user (or a connection to a shared
> database), logging into one app would not log you into the other. The
> reason is that login status is held in the session, and by default,
> sessions are not shared across apps (though they can be shared if desired).
> If you want Auth to work across multiple apps, the best option is probably
> http://web2py.com/books/**default/chapter/29/09#Central-**
> Authentication-Service<http://web2py.com/books/default/chapter/29/09#Central-Authentication-Service>
> .
>
> Anthony
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Confused about app

2013-06-25 Thread Tom Russell
But I do like this:

## create all tables needed by auth if not custom tables
auth.define_tables(username=True, signature=True)

I was using auth.signature for each table but that gave me an error after
setting the CAS stuff. Once commented out it works fine. I was getting
a 'DAL' object has no attribute 'auth_user'


On Tue, Jun 25, 2013 at 11:14 AM, Anthony  wrote:

> On Tuesday, June 25, 2013 11:04:22 AM UTC-4, Tom Russell wrote:
>
>> Yes I customized welcome and then added a new app via the admin
>> interface. I did not directly copy the welcome app, just modified the html
>> etc.
>>
>> Now I am really confused about how this all works. So when I fire up
>> web2py and create a new app via the admin, should that be my only app then?
>>
>
> No, create as many apps as you like. However, each app is separate (a
> web2py app is more like a Django project).
>
>
>>  So I did implement the CAS stuff but now I get an error saying 'DAL'
>> object has no attribute 'auth_user' for the app I have.
>>
>
> Sounds like you didn't call auth.define_tables() in the second app.
>
> Anthony
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Smartgrid Links

2013-06-25 Thread Tom Russell
I have a smartgrid with a link like so:

links = [lambda row: A(T('Create
Appointment'),_href=URL("AppointmentManager","appointment_create",args=[
row.id]))]

grid = SQLFORM.smartgrid(db.patient, deletable=True, editable=True,
create=True, maxtextlength=64, paginate=25, links=links,
links_in_grid=True, linked_tables=['emergencycontacts','dependents'])
return dict(grid=grid)

Problem is that AppointmentManager is another app and the url points to
/currentapp/AppointmentManager/ etc, so how do I have it redirect to the
other app?

I looked in the book but could'nt find this.

Thanks

Tom

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Confused about app

2013-06-25 Thread Tom Russell
Ah, I forgot to add the following line to my consumer app:

auth = Auth(db,cas_provider = '
http://127.0.0.1:8000/welcome/default/user/cas')


On Tue, Jun 25, 2013 at 10:12 AM, Tom Russell  wrote:

> Well agreed, but I set that up in the welcome app so it would seem like
> that should move over to my other app as well?
>
>
> On Tue, Jun 25, 2013 at 2:24 AM, Niphlod  wrote:
>
>> every app has its own auth system. If you want multiple apps to share the
>> same "auth system", look at
>>
>> http://web2py.com/books/default/chapter/29/09#Central-Authentication-Service
>>
>> Il giorno martedì 25 giugno 2013 07:51:08 UTC+2, Tom Russell ha scritto:
>>
>>> So I took and modified the welcome app to my needs and added another
>>> app. If I login with the welcome app and with a link, open the other app
>>> and have it set with auth.requires_login(), it requires the user to login
>>> again. How does one handle this stuff in web2py? Do I need another app the
>>> way I have it now?
>>>
>>> I am in the mindset of how they do things in django.
>>>
>>> Thanks,
>>>
>>> Tom
>>>
>>  --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Smartgrid Links

2013-06-25 Thread Tom Russell
Ah I see now, Thanks.


On Tue, Jun 25, 2013 at 1:31 PM, Anthony  wrote:

> If you only provide two positional args to URL, it assumes they are the
> controller and function. In this case, you'll need to specify the
> application, controller, and function:
>
> URL("AppointmentManager", "yourcontroller", "appointment_create", args=[
> row.id])
>
> You can also used keyword arguments "a", "c", and "f" with URL().
>
> Anthony
>
> On Tuesday, June 25, 2013 12:08:57 PM UTC-4, Tom Russell wrote:
>>
>> I have a smartgrid with a link like so:
>>
>> links = [lambda row: A(T('Create Appointment'),_href=URL("**
>> AppointmentManager","**appointment_create",args=[row.**id <http://row.id>
>> ]))]
>>
>> grid = SQLFORM.smartgrid(db.patient, deletable=True, editable=True,
>> create=True, maxtextlength=64, paginate=25, links=links,
>> links_in_grid=True, linked_tables=['**emergencycontacts','**
>> dependents'])
>> return dict(grid=grid)
>>
>> Problem is that AppointmentManager is another app and the url points to
>> /currentapp/**AppointmentManager/ etc, so how do I have it redirect to
>> the other app?
>>
>> I looked in the book but could'nt find this.
>>
>> Thanks
>>
>> Tom
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] SQLFORM.smartgrid

2013-06-25 Thread Tom Russell
Another question on the smartgrid.

I have linked tables in my smartgrid like:

grid = SQLFORM.smartgrid(db.patient, deletable=True, editable=True,
create=False, maxtextlength=64, paginate=25, links=links,
links_in_grid=True, linked_tables=['emergencycontacts','dependents'])

When clicking on the linked table it shows the id of patient since thats
what reference but how can I show the name of the patient rather than the
id of patient?

Thanks,

Tom

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: SQLFORM.smartgrid

2013-06-26 Thread Tom Russell
Apparently something is not correct as I cannot figure out what the syntax
erro is based on the example you gave here.

This is what I have:

Field('patient name', db.linked patient, represent=lambda c, row:first_name
of patient(c), requires=IS_IN_DB(db,'field.id','%(patient)s')),


On Wed, Jun 26, 2013 at 2:49 AM, Rohitraj Sharma <
rohitraj.sha...@themislexsol.com> wrote:

> You can use labda function in your db
>
> Field('companyField name',db.linked table name, represent=lambda c,
> row:field name of linked table(c), requires=IS_IN_DB(db,'field.id
> ','%(patient)s')),
>
>
> On Wednesday, 26 June 2013 10:36:03 UTC+5:30, Tom Russell wrote:
>>
>> Another question on the smartgrid.
>>
>> I have linked tables in my smartgrid like:
>>
>> grid = SQLFORM.smartgrid(db.patient, deletable=True, editable=True,
>> create=False, maxtextlength=64, paginate=25, links=links,
>> links_in_grid=True, linked_tables=['**emergencycontacts','**
>> dependents'])
>>
>> When clicking on the linked table it shows the id of patient since thats
>> what reference but how can I show the name of the patient rather than the
>> id of patient?
>>
>> Thanks,
>>
>> Tom
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: SQLFORM.smartgrid

2013-06-26 Thread Tom Russell
db.define_table('patient',
#db.patient.id.readable=False # Since we do not want to expose the id
field on the grid
Field('alternatepid', label='Alternate PID', writable=False,
readable=False),
Field('first_name', label='First Name', requires=IS_NOT_EMPTY()),
Field('middle_name', label='Middle Name'),
Field('last_name', label='Last Name', requires=IS_NOT_EMPTY()),
Field('suffix', label='Suffix', requires=IS_IN_SET(['I', 'II', 'III',
'IV', 'V', 'Jr', 'Sr'])),
Field('date_of_birth', 'date', label='Date of Birth',
required=IS_DATE(), requires=IS_NOT_EMPTY()),
Field('gender', label='Gender', requires=IS_IN_SET(['Male', 'Female',
'Other'])),
Field('full_name',  label='Full Name', writable=False, readable=False),
Field('address1', label='Address1', requires=IS_NOT_EMPTY()),
Field('address2', label='Address2'),
Field('city',  label='City', requires=IS_NOT_EMPTY()),
Field('state',  label='State', requires=IS_NOT_EMPTY()),
Field('zipcode',  label='Zip Code', requires=IS_NOT_EMPTY()),
Field('addresstype',  label='AddressType'),
Field('county',  label='County', ),
Field('country',  label='Country', requires=IS_IN_SET(COUNTRIES)),
Field('phone',  label='Phone', ),
Field('mobile_phone',  label='Mobile Phone'),
Field('emailaddress',  label='Email Address', requires =
IS_EMAIL(error_message='invalid email!')),
Field('ethnicity',  label='Ethnicity', requires=IS_IN_SET(['Caucasian',
'Hispanic', 'Chinese'])),
Field('age', label='Age'),
Field('marital_status',  label='Marital Status',
requires=IS_IN_SET(['Single', 'Married', 'Divorced', 'Separated',
'Widowed'])),
Field('comment', 'text', label='Comment'),
Field('government_id_number',  label='Government ID Number',
requires=IS_NOT_EMPTY()),
Field('is_newborn', 'boolean',  label='Is Newborn', ),
Field('medical_record_number',  label='MRN', readable=True,
requires=IS_NOT_EMPTY()),
Field('other_id_type',  label='Other ID Type',
requires=IS_IN_SET(['Work', 'Library Card', 'Drivers License', 'School ID',
'Other'])),
Field('other_id', label='Other ID'),
)


db.define_table(
'dependents',
#Field('patient name', db.linked patient, represent=lambda c,
row:first_name of patient(c), requires=IS_IN_DB(db,'field.id
','%(patient)s')),
Field('patient','reference patient', writable=False, readable=False),
Field('dep_firstname', label='First Name'),
Field('dep_middlename', label='Middle Name'),
Field('dep_lastname', label='Last Name'),
Field('dep_relationship', label='Relationship',
requires=IS_IN_SET(['Son', 'Daughter', 'Other'])),
)

db.define_table(
'emergencycontacts',
Field('patient','reference patient', writable=False, readable=False),
Field('em_first_name', label='First Name'),
Field('em_middle_name', label='Middle Name'),
Field('em_last_name', label='Last Name'),
Field('em_address1', label='Address1'),
Field('em_address2', label='Address2'),
Field('em_city', label='City'),
Field('em_state', label='State'),
Field('em_zipcode', label='Zip Code'),
Field('em_country', label='Country', requires=IS_IN_SET(COUNTRIES)),
Field('em_phone', label='Phone'),
Field('em_relationship', label='Relationship',
requires=IS_IN_SET(['Aunt', 'Uncle', 'Parent', 'Sibling', 'Spouse',
'Guardian'])),
)

I'd like to reference the first and last name of the patient the record is
associated with.

Thanks.


On Wed, Jun 26, 2013 at 10:20 AM, Anthony  wrote:

> Can you show your three table definitions? The simplest method is just to
> specify a "format" attribute for db.patient, which will be used by any
> referencing fields.
>
> Anthony
>
>
> On Wednesday, June 26, 2013 1:06:03 AM UTC-4, Tom Russell wrote:
>>
>> Another question on the smartgrid.
>>
>> I have linked tables in my smartgrid like:
>>
>> grid = SQLFORM.smartgrid(db.patient, deletable=True, editable=True,
>> create=False, maxtextlength=64, paginate=25, links=links,
>> links_in_grid=True, linked_tables=['**emergencycontacts','**
>> dependents'])
>>
>> When clicking on the linked table it shows the id of patient since thats
>> what reference but how can I show the name of the patient rather than the
>> id of patient?
>>
>> Thanks,
>>
>> Tom
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: SQLFORM.smartgrid

2013-06-26 Thread Tom Russell
That is awesome, I did not know that! Just when you think its more
complicated than not, its easy.

So how do I reference that from the dependents table so that in my smart
grid it shows the patients name associated with the dependent?

Thanks


On Wed, Jun 26, 2013 at 10:43 AM, Anthony  wrote:

> db.define_table('patient',
> ...,
> format='%(first_name)s %(last_name)s')
>
> "format" can also be a function that takes a row object and generates the
> desired output.
>
> The "format" attribute is used to create a default "represent" attribute
> for any reference fields that reference this table.
>
> Anthony
>
>
> On Wednesday, June 26, 2013 10:24:32 AM UTC-4, Tom Russell wrote:
>
>> db.define_table('patient',
>> #db.patient.id.readable=False # Since we do not want to expose the id
>> field on the grid
>> Field('alternatepid', label='Alternate PID', writable=False,
>> readable=False),
>> Field('first_name', label='First Name', requires=IS_NOT_EMPTY()),
>> Field('middle_name', label='Middle Name'),
>> Field('last_name', label='Last Name', requires=IS_NOT_EMPTY()),
>> Field('suffix', label='Suffix', requires=IS_IN_SET(['I', 'II', 'III',
>> 'IV', 'V', 'Jr', 'Sr'])),
>> Field('date_of_birth', 'date', label='Date of Birth',
>> required=IS_DATE(), requires=IS_NOT_EMPTY()),
>> Field('gender', label='Gender', requires=IS_IN_SET(['Male', 'Female',
>> 'Other'])),
>> Field('full_name',  label='Full Name', writable=False,
>> readable=False),
>> Field('address1', label='Address1', requires=IS_NOT_EMPTY()),
>> Field('address2', label='Address2'),
>> Field('city',  label='City', requires=IS_NOT_EMPTY()),
>> Field('state',  label='State', requires=IS_NOT_EMPTY()),
>> Field('zipcode',  label='Zip Code', requires=IS_NOT_EMPTY()),
>> Field('addresstype',  label='AddressType'),
>> Field('county',  label='County', ),
>> Field('country',  label='Country', requires=IS_IN_SET(COUNTRIES))**,
>> Field('phone',  label='Phone', ),
>> Field('mobile_phone',  label='Mobile Phone'),
>> Field('emailaddress',  label='Email Address', requires =
>> IS_EMAIL(error_message='**invalid email!')),
>> Field('ethnicity',  label='Ethnicity', requires=IS_IN_SET(['**Caucasian',
>> 'Hispanic', 'Chinese'])),
>> Field('age', label='Age'),
>> Field('marital_status',  label='Marital Status',
>> requires=IS_IN_SET(['Single', 'Married', 'Divorced', 'Separated',
>> 'Widowed'])),
>> Field('comment', 'text', label='Comment'),
>> Field('government_id_number',  label='Government ID Number',
>> requires=IS_NOT_EMPTY()),
>> Field('is_newborn', 'boolean',  label='Is Newborn', ),
>> Field('medical_record_number',  label='MRN', readable=True,
>> requires=IS_NOT_EMPTY()),
>> Field('other_id_type',  label='Other ID Type',
>> requires=IS_IN_SET(['Work', 'Library Card', 'Drivers License', 'School ID',
>> 'Other'])),
>> Field('other_id', label='Other ID'),
>> )
>>
>>
>> db.define_table(
>> 'dependents',
>> #Field('patient name', db.linked patient, represent=lambda c,
>> row:first_name of patient(c), requires=IS_IN_DB(db,'field.id**
>> ','%(patient)s')),
>> Field('patient','reference patient', writable=False, readable=False),
>> Field('dep_firstname', label='First Name'),
>> Field('dep_middlename', label='Middle Name'),
>>     Field('dep_lastname', label='Last Name'),
>> Field('dep_relationship', label='Relationship',
>> requires=IS_IN_SET(['Son', 'Daughter', 'Other'])),
>> )
&

[web2py] Add button to smartgrid?

2013-06-26 Thread Tom Russell
I need to add a button to the smartgrid but not like doing create=True
because I have a form factory that has 2 other tables associated with the
one. I know in html I can simply add a line for a button but since I am not
using html for this how would I add a button to that page to reference my
own view?

Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] sqlform.factory widget in field problem

2013-06-26 Thread Tom Russell
To group inside a field I do something like this with 3 different tables:

form=SQLFORM.factory(db.patient, db.emergencycontacts, db.dependents)
fs0=form[0][:26] #patient rows
fs1=form[0][26:37]   #emergency contacts
fs2=form[0][37:41] #dependents
fs3=form[0][-1] # submit row (last)

form[0]=TABLE(
FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
FIELDSET(TAG.legend("Emergency Contact
Info"),TABLE(fs1),_id="register1"),
FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
TABLE(fs3))


HTH


On Wed, Jun 26, 2013 at 11:58 AM, António Ramos wrote:

> Just drafting something but here is the problem
>
> My context:
> I have 3 tables
>
> table form
> table steps
> table fields
>
> A form can have many steps
> a step can have many fields
>
> This way i can have one form with 3 steps, each with some fields and
> another form with 10 steps , each with some more fields.
>
> i read these tables to create a form using factory.
>
> i have 2 problems
>
>
> *1 i need to mark the input fields with a "step" tag *
>
> here is my code:
>
> def my_string_widget(field, value,step):
>
> return INPUT(_name=field.name,
>   _id="%s_%s" % (field._tablename, field.name),
>   _class=field.type,
>   _value='',
>   *_step=step,*
>   requires=field.requires)
>
> def index():
> cont=0
> fields=[]
> formid=db.form(request.args(0) or 1)
> steps=formid.steps.select()
> for step in steps:
> print "step id-",step.id
> for field in step.fields.select():
> print "field...",field.step
> fields.append(Field(field.nome,widget=lambda
> field,value:my_string_widget(field,value,*step.id*)))
>
> form=SQLFORM.factory(*fields)
> print form
> if form.process().accepted:
> response.flash='a gravar registo'
> return dict(nome=formid.nome,form=form)
>
>
> The problem is:
> It marks all fields with the same "step" value, the last value in *step.id,
> why?*
> *
> *
> *2 - sqlformfactory *
> how do i group sqlformfactory fields inside a div?
> i want to create a section for each step in the form to style with css
>
> Best regards
> António
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Ref another table in another app

2013-06-26 Thread Tom Russell
How would I do this:

I need to create an appointment for a patient so from my list of patients i
have a link to call another app to do the appointment. I have the link set
so it looks like this:

links = [lambda row: A(T('Create
Appointment'),_href=URL("AppointmentManager","default",
"appointment_create"), args=[row.id])]

In the appointment app how do I let it know what to use for the patient?
Basically I want to pass in the patient info to the other app and have that
displayed in the app. I know you can reference another table but not sure
how to do this in this situation.

Any suggestions?

Thanks.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] sqlform.factory widget in field problem

2013-06-26 Thread Tom Russell
Saved mine too, got it originally from
http://www.web2pyslices.com/slice/show/1457/adding-fieldset-and-legend-to-forms


On Wed, Jun 26, 2013 at 12:39 PM, António Ramos wrote:

> That is a very clever solution.
> Saved my day.
>
> Thank you
>
>
>
>
> 2013/6/26 Tom Russell 
>
>> form[0]=TABLE(
>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
>> FIELDSET(TAG.legend("Emergency Contact
>> Info"),TABLE(fs1),_id="register1"),
>> FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
>> TABLE(fs3))
>>
>
>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Appointment Manager

2013-06-26 Thread Tom Russell
I am using the appointment manager from
https://github.com/mdipierro/web2py-appliances/tree/master/AppointmentManager
.

I have tweaked it to my needs and works well so far but there is an issue
trying to use SQLFORM.grid.

I get an error
 () takes exactly 1 argument (2 given)

by doing this:

def appointment_select():
grid = SQLFORM.grid(db.t_appointment, deletable=True, editable=True,
create=False, maxtextlength=64, paginate=25)

return dict(grid=grid)

I cannot figure out why it is doing this.

Any ideas?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Appointment Manager

2013-06-26 Thread Tom Russell
Well I updated to the latest fullcalendar and it seems to work good, but do
not know if the memory leak still exists. By any chance could you share
what you did? Also, any chance you added views for week/day in it?

You can see in the example here http://arshaw.com/fullcalendar/ that it has
buttons for day and week also. I tried fiddling with some examples to get
it to show but am not successful yet.

Thanks.


On Wed, Jun 26, 2013 at 1:22 PM, Richard Vézina  wrote:

> Letting FullCalendar consume the json feed...
>
>
> On Wed, Jun 26, 2013 at 1:21 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>>  Take care, I don't know if it has been solve, but I found a memory leak
>> in this app caused by the way FullCalendar is integrated... I solve the
>> issue for my own need by using the json feed feature of FullCalendar doing
>> a simple json feed function returning a well formatted json object with
>> simplejson dump.
>>
>> Richard
>>
>>
>> On Wed, Jun 26, 2013 at 12:55 PM, Tom Russell  wrote:
>>
>>> I am using the appointment manager from
>>> https://github.com/mdipierro/web2py-appliances/tree/master/AppointmentManager
>>> .
>>>
>>> I have tweaked it to my needs and works well so far but there is an
>>> issue trying to use SQLFORM.grid.
>>>
>>> I get an error
>>>  () takes exactly 1 argument (2
>>> given)
>>>
>>> by doing this:
>>>
>>> def appointment_select():
>>> grid = SQLFORM.grid(db.t_appointment, deletable=True, editable=True,
>>> create=False, maxtextlength=64, paginate=25)
>>>
>>> return dict(grid=grid)
>>>
>>> I cannot figure out why it is doing this.
>>>
>>> Any ideas?
>>>
>>> --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] sqlform.factory widget in field problem

2013-06-26 Thread Tom Russell
Another solution can be:

{{extend 'layout.html'}}

 Education CV {{=education_form}}

Student {{=student_form}}

School {{=school_form}}


On Wed, Jun 26, 2013 at 12:47 PM, Tom Russell  wrote:

> Saved mine too, got it originally from
> http://www.web2pyslices.com/slice/show/1457/adding-fieldset-and-legend-to-forms
>
>
> On Wed, Jun 26, 2013 at 12:39 PM, António Ramos wrote:
>
>> That is a very clever solution.
>> Saved my day.
>>
>> Thank you
>>
>>
>>
>>
>> 2013/6/26 Tom Russell 
>>
>>> form[0]=TABLE(
>>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
>>> FIELDSET(TAG.legend("Emergency Contact
>>> Info"),TABLE(fs1),_id="register1"),
>>> FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
>>> TABLE(fs3))
>>>
>>
>>
>>  --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Appointment Manager

2013-06-26 Thread Tom Russell
/public/basic</a>
>> ',
>> // className: 'gcal-event',
>> // currentTimezone: 'America/Montreal'},
>> {url:
>> '/your_app_name/your_controller/calendar_json_feed', 'color': 'rgb(84, 132,
>> 237)', cache: true},
>> // you can insert here all the other json feed you want
>> for the stuff you want to display, you can change color to make those
>> differents groups of events distinctive
>> ],
>> // feed by simplejson function
>> //[
>> //{
>> //title: "S-20120215-U219-2p",
>> //allDay: false,
>> //start: "2013-03-22 08:30:00", // Leading zero is
>> important for Firefox, comment 2 in answer :
>> <a  rel="nofollow" href="http://stackoverflow.com/questions/12771886/jquery-fullcalendar-plugin-events-are-limited-to-3-in-ie-and-firefox">http://stackoverflow.com/questions/12771886/jquery-fullcalendar-plugin-events-are-limited-to-3-in-ie-and-firefox</a>
>> //end: "2013-03-22 09:30:00",
>> //url: '/sgddms/lotns/read/lotns_sample/623'
>> //}
>> //],
>> header: {
>> left:   'today prevYear,nextYear prev,next',
>> center: 'title',
>> right:  'month,basicWeek,basicDay'
>> },
>> {{if T.accepted_language.split('-')[0] == 'fr':}}
>> timeFormat: 'H(:mm)', // uppercase H for 24-hour clock
>> {{pass}}
>> monthNames: ["{{=T('January')}}",
>> "{{=T('February')}}",
>> "{{=T('March')}}",
>> "{{=T('April')}}",
>> "{{=T('May')}}",
>> "{{=T('June')}}",
>> "{{=T('July')}}",
>> "{{=T('August')}}",
>> "{{=T('September')}}",
>> "{{=T('October')}}",
>> "{{=T('November')}}",
>> "{{=T('December')}}"],
>> dayNames: ["{{=T('Sunday')}}",
>> "{{=T('Monday')}}",
>> "{{=T('Tuesday')}}",
>> "{{=T('Wednesday')}}",
>> "{{=T('Thursday')}}",
>> "{{=T('Friday')}}",
>> "{{=T('Saturday')}}"],
>> dayNamesShort: ["{{=T('Sun')}}",
>> "{{=T('Mon')}}",
>> "{{=T('Tue')}}",
>> "{{=T('Wed')}}",
>> "{{=T('Thu')}}",
>> "{{=T('Fri')}}",
>> "{{=T('Sat')}}"],
>> buttonText: {
>> prev: '&nbsp;&#9668;&nbsp;',  // left triangle
>> next: '&nbsp;&#9658;&nbsp;',  // right triangle
>> prevYear: '&nbsp;&#9668;&#9668;&nbsp;', // <<
>> nextYear: '&nbsp;&#9658;&#9658;&nbsp;', // >>
>> today:"{{=T('today')}}",
>> month:"{{=T('month')}}",
>> week: "{{=T('week')}}",
>> day:  "{{=T('day')}}"
>> }
>>
>> });
>>
>> });
>> 
>>
>>
>> Since I save you a lot of time you can consider to update the
>> AppointmentManager app with this example to return to community :
>>
>>
>> https://github.com/mdipierro/web2py-appliances/tree/master/AppointmentManager
>>
>> Richard
>>
>>
>>
>> On Wed, Jun 26, 2013 at 1:31 PM, Tom Russell  wrote:
>>
>>> Well I updated to the latest fullcalendar and it seems to work good, but
>>> do not know if the memory leak still exists. By any chance could y

[web2py] JQuery Issue

2013-06-26 Thread Tom Russell
I cannot seem to get some jquery code to work right and not sure why.
Basically when I click a checkbox I want another field to appear below that
one.

This is my form code:

@auth.requires_login()
def register_patient():
mark_not_empty(db.patient)
mark_not_empty(db.emergencycontacts)
mark_not_empty(db.dependents)
db.patient.medical_record_number.default = 'KND' +
str(date.today().year) + '' + str(random.randrange(1, 999+1))
db.patient.medical_record_number.writable = False
form=SQLFORM.factory(db.patient, db.emergencycontacts, db.dependents)

fs0=form[0][:27] #patient rows
fs1=form[0][27:38]   #emergency contacts
fs2=form[0][38:42] #dependents
fs3=form[0][-1] # submit row (last)

form[0]=TABLE(
FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
FIELDSET(TAG.legend("Emergency Contact
Info"),TABLE(fs1),_id="register1"),
FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
TABLE(fs3))
if form.process().accepted:
id = db.patient.insert(**db.patient._filter_fields(form.vars))
form.vars.patient=id
id =
db.emergencycontacts.insert(**db.emergencycontacts._filter_fields(form.vars))
id = db.dependents.insert(**db.dependents._filter_fields(form.vars))
#form.vars.dependents=id
# and get a list of all persons
redirect(URL('manage_patients'))

style = STYLE(""".not_empty {color:#d00;}""")

return dict(form=DIV(style,form))

My html code:

{{left_sidebar_enabled=True}}
{{extend 'layout.html'}}

{{block left_sidebar}}
  Home
  
  Home(Physician)
  Home(Front Desk)
  Home(Nurse)
  Home(Lab)
  Home(Radiology)
  Home(Pharmacist)
  Home(Cashier)
  
  Patients
  Task Lists
  Appointment
  Order
  Consumables
  Prescriptions
  Immunization
  Laboratory Orders
  Radiology Orders
  Patient Accounting
  Admin

{{end}}


Register Patient

{{=form}}


jQuery(document).ready(function(){
   jQuery('#no_table_mothers_name__row').hide();
   jQuery('#is_newborn').change(function(){
if(jQuery('#is_newborn').attr('checked'))
jQuery('#no_table_mothers_name__row').show();
else jQuery('#no_table_mothers_name__row').hide();});
});



And this is the info from the page source showing the id's for what fields
I am working with:

Is Newborn: 

Mothers Name:
https://groups.google.com/groups/opt_out.




Re: [web2py] Re: JQuery Issue

2013-06-27 Thread Tom Russell
Thats weird, now it will not hide the the field but has no effect either
when you check the checkbox.


On Thu, Jun 27, 2013 at 12:11 AM, Jim S  wrote:

> Try this, you need brackets for your if statements in javascript.
>
> jQuery(document).ready(function(){
>  jQuery('#no_table_mothers_name__row').hide();
>  jQuery('#is_newborn').change(function(){
>if(jQuery('#is_newborn').attr('checked')) {
>  jQuery('#no_table_mothers_name__row').show();
>} else {
>  jQuery('#no_table_mothers_name__row').hide();
>});
>  });
> });
>
>
> On Wednesday, June 26, 2013 9:09:00 PM UTC-5, Tom Russell wrote:
>>
>> I cannot seem to get some jquery code to work right and not sure why.
>> Basically when I click a checkbox I want another field to appear below that
>> one.
>>
>> This is my form code:
>>
>> @auth.requires_login()
>> def register_patient():
>> mark_not_empty(db.patient)
>> mark_not_empty(db.emergencycontacts)
>> mark_not_empty(db.dependents)
>> db.patient.medical_record_number.default = 'KND' +
>> str(date.today().year) + '' + str(random.randrange(1, 999+1))
>> db.patient.medical_record_number.writable = False
>> form=SQLFORM.factory(db.patient, db.emergencycontacts, db.dependents)
>>
>> fs0=form[0][:27] #patient rows
>> fs1=form[0][27:38]   #emergency contacts
>> fs2=form[0][38:42] #dependents
>> fs3=form[0][-1] # submit row (last)
>>
>> form[0]=TABLE(
>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
>> FIELDSET(TAG.legend("Emergency Contact
>> Info"),TABLE(fs1),_id="register1"),
>> FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
>> TABLE(fs3))
>> if form.process().accepted:
>> id = db.patient.insert(**db.patient._filter_fields(form.vars))
>> form.vars.patient=id
>> id =
>> db.emergencycontacts.insert(**db.emergencycontacts._filter_fields(form.vars))
>> id =
>> db.dependents.insert(**db.dependents._filter_fields(form.vars))
>> #form.vars.dependents=id
>> # and get a list of all persons
>> redirect(URL('manage_patients'))
>>
>> style = STYLE(""".not_empty {color:#d00;}""")
>>
>> return dict(form=DIV(style,form))
>>
>> My html code:
>>
>> {{left_sidebar_enabled=True}}
>> {{extend 'layout.html'}}
>>
>> {{block left_sidebar}}
>>   Home
>>   
>>   Home(Physician)
>>   Home(Front Desk)
>>   Home(Nurse)
>>   Home(Lab)
>>   Home(Radiology)
>>   Home(Pharmacist)
>>   Home(Cashier)
>>   
>>   > href="/patient/default/manage_patients">Patients
>>   Task Lists
>>   Appointment
>>   Order
>>   Consumables
>>   Prescriptions
>>   Immunization
>>   Laboratory Orders
>>   Radiology Orders
>>   Patient Accounting
>>   Admin
>>
>> {{end}}
>>
>>
>> Register Patient
>>
>> {{=form}}
>>
>> 
>> jQuery(document).ready(function(){
>>jQuery('#no_table_mothers_name__row').hide();
>>jQuery('#is_newborn').change(function(){
>> if(jQuery('#is_newborn').attr('checked'))
>> jQuery('#no_table_mothers_name__row').show();
>> else jQuery('#no_table_mothers_name__row').hide();});
>> });
>> 
>>
>>
>> And this is the info from the page source showing the id's for what
>> fields I am working with:
>>
>> Is Newborn: 
>> > name="is_newborn" type="checkbox" value="on" />
>> > for="no_table_mothers_name" id="no_table_mothers_name__label">Mothers
>> Name: >
>> I think I have the right code for the jquery but nothing happens when I
>> try this.
>>
>> Any ideas?
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: JQuery Issue

2013-06-27 Thread Tom Russell
k thanks I will try that



On Thu, Jun 27, 2013 at 10:58 AM, Jim Steil  wrote:

> I'd try putting some alert() messages in to try to trace the flow and
> check the values of variables.
>
>
>
> On Thu, Jun 27, 2013 at 9:53 AM, Tom Russell  wrote:
>
>> Thats weird, now it will not hide the the field but has no effect either
>> when you check the checkbox.
>>
>>
>> On Thu, Jun 27, 2013 at 12:11 AM, Jim S  wrote:
>>
>>> Try this, you need brackets for your if statements in javascript.
>>>
>>> jQuery(document).ready(function(){
>>>  jQuery('#no_table_mothers_name__row').hide();
>>>  jQuery('#is_newborn').change(function(){
>>>if(jQuery('#is_newborn').attr('checked')) {
>>>  jQuery('#no_table_mothers_name__row').show();
>>>} else {
>>>  jQuery('#no_table_mothers_name__row').hide();
>>>});
>>>  });
>>> });
>>>
>>>
>>> On Wednesday, June 26, 2013 9:09:00 PM UTC-5, Tom Russell wrote:
>>>>
>>>> I cannot seem to get some jquery code to work right and not sure why.
>>>> Basically when I click a checkbox I want another field to appear below that
>>>> one.
>>>>
>>>> This is my form code:
>>>>
>>>> @auth.requires_login()
>>>> def register_patient():
>>>> mark_not_empty(db.patient)
>>>> mark_not_empty(db.emergencycontacts)
>>>> mark_not_empty(db.dependents)
>>>> db.patient.medical_record_number.default = 'KND' +
>>>> str(date.today().year) + '' + str(random.randrange(1, 999+1))
>>>> db.patient.medical_record_number.writable = False
>>>> form=SQLFORM.factory(db.patient, db.emergencycontacts,
>>>> db.dependents)
>>>>
>>>> fs0=form[0][:27] #patient rows
>>>> fs1=form[0][27:38]   #emergency contacts
>>>> fs2=form[0][38:42] #dependents
>>>> fs3=form[0][-1] # submit row (last)
>>>>
>>>> form[0]=TABLE(
>>>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
>>>> FIELDSET(TAG.legend("Emergency Contact
>>>> Info"),TABLE(fs1),_id="register1"),
>>>> FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
>>>> TABLE(fs3))
>>>> if form.process().accepted:
>>>> id = db.patient.insert(**db.patient._filter_fields(form.vars))
>>>> form.vars.patient=id
>>>> id =
>>>> db.emergencycontacts.insert(**db.emergencycontacts._filter_fields(form.vars))
>>>> id =
>>>> db.dependents.insert(**db.dependents._filter_fields(form.vars))
>>>> #form.vars.dependents=id
>>>> # and get a list of all persons
>>>> redirect(URL('manage_patients'))
>>>>
>>>> style = STYLE(""".not_empty {color:#d00;}""")
>>>>
>>>> return dict(form=DIV(style,form))
>>>>
>>>> My html code:
>>>>
>>>> {{left_sidebar_enabled=True}}
>>>> {{extend 'layout.html'}}
>>>>
>>>> {{block left_sidebar}}
>>>>   Home
>>>>   
>>>>   Home(Physician)
>>>>   Home(Front Desk)
>>>>   Home(Nurse)
>>>>   Home(Lab)
>>>>   Home(Radiology)
>>>>   Home(Pharmacist)
>>>>   Home(Cashier)
>>>>   
>>>>   >>> href="/patient/default/manage_patients">Patients
>>>>   Task Lists
>>>>   Appointment
>>>>   Order
>>>>   Consumables
>>>>   Prescriptions
>>>>   Immunization
>>>>   Laboratory Orders
>>>>   Radiology Orders
>>>>   Patient
>>>> Accounting
>>>>   Admin
>>>>
>>>> {{end}}
>>>>
>>>>
>>>> Register Patient
>>>>
>>>> {{=form}}
>>>>
>>>> 
>>>> jQuery(document).ready(function(){
>>>>jQuery('#no_tab

Re: [web2py] Re: JQuery Issue

2013-06-27 Thread Tom Russell
So If I do something like:

jAlert('This is a custom alert box', 'Alert Dialog');

and nothing shows up, could it be that the jquery lib is not being made
available?


On Thu, Jun 27, 2013 at 11:00 AM, Tom Russell  wrote:

> k thanks I will try that
>
>
>
> On Thu, Jun 27, 2013 at 10:58 AM, Jim Steil  wrote:
>
>> I'd try putting some alert() messages in to try to trace the flow and
>> check the values of variables.
>>
>>
>>
>> On Thu, Jun 27, 2013 at 9:53 AM, Tom Russell  wrote:
>>
>>> Thats weird, now it will not hide the the field but has no effect either
>>> when you check the checkbox.
>>>
>>>
>>> On Thu, Jun 27, 2013 at 12:11 AM, Jim S  wrote:
>>>
>>>> Try this, you need brackets for your if statements in javascript.
>>>>
>>>> jQuery(document).ready(function(){
>>>>  jQuery('#no_table_mothers_name__row').hide();
>>>>  jQuery('#is_newborn').change(function(){
>>>>if(jQuery('#is_newborn').attr('checked')) {
>>>>  jQuery('#no_table_mothers_name__row').show();
>>>>} else {
>>>>  jQuery('#no_table_mothers_name__row').hide();
>>>>});
>>>>  });
>>>> });
>>>>
>>>>
>>>> On Wednesday, June 26, 2013 9:09:00 PM UTC-5, Tom Russell wrote:
>>>>>
>>>>> I cannot seem to get some jquery code to work right and not sure why.
>>>>> Basically when I click a checkbox I want another field to appear below 
>>>>> that
>>>>> one.
>>>>>
>>>>> This is my form code:
>>>>>
>>>>> @auth.requires_login()
>>>>> def register_patient():
>>>>> mark_not_empty(db.patient)
>>>>> mark_not_empty(db.emergencycontacts)
>>>>> mark_not_empty(db.dependents)
>>>>> db.patient.medical_record_number.default = 'KND' +
>>>>> str(date.today().year) + '' + str(random.randrange(1, 999+1))
>>>>> db.patient.medical_record_number.writable = False
>>>>> form=SQLFORM.factory(db.patient, db.emergencycontacts,
>>>>> db.dependents)
>>>>>
>>>>> fs0=form[0][:27] #patient rows
>>>>> fs1=form[0][27:38]   #emergency contacts
>>>>> fs2=form[0][38:42] #dependents
>>>>> fs3=form[0][-1] # submit row (last)
>>>>>
>>>>> form[0]=TABLE(
>>>>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
>>>>> FIELDSET(TAG.legend("Emergency Contact
>>>>> Info"),TABLE(fs1),_id="register1"),
>>>>> FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
>>>>> TABLE(fs3))
>>>>> if form.process().accepted:
>>>>> id = db.patient.insert(**db.patient._filter_fields(form.vars))
>>>>> form.vars.patient=id
>>>>> id =
>>>>> db.emergencycontacts.insert(**db.emergencycontacts._filter_fields(form.vars))
>>>>> id =
>>>>> db.dependents.insert(**db.dependents._filter_fields(form.vars))
>>>>> #form.vars.dependents=id
>>>>> # and get a list of all persons
>>>>> redirect(URL('manage_patients'))
>>>>>
>>>>> style = STYLE(""".not_empty {color:#d00;}""")
>>>>>
>>>>> return dict(form=DIV(style,form))
>>>>>
>>>>> My html code:
>>>>>
>>>>> {{left_sidebar_enabled=True}}
>>>>> {{extend 'layout.html'}}
>>>>>
>>>>> {{block left_sidebar}}
>>>>>   Home
>>>>>   
>>>>>   Home(Physician)
>>>>>   Home(Front Desk)
>>>>>   Home(Nurse)
>>>>>   Home(Lab)
>>>>>   Home(Radiology)
>>>>>   Home(Pharmacist)
>>>>>   Home(Cashier)
>>>>>   
>>>>>   >>>> href="/patient/default/manage_patients">Patients
>>>>>   Task Lists
>>>>>   Appo

[web2py] Use model in another app

2013-06-27 Thread Tom Russell
I have 2 apps and one I want to use the model/db from it in the other in a
SQLFORM.grid. I have read through and googled and cannot find a way to do
this.

Is this possible and how?

Thanks,

Tom

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: JQuery Issue

2013-06-27 Thread Tom Russell
I use chrome but I will have to try that. Thanks.


On Thu, Jun 27, 2013 at 3:31 PM, Jim S  wrote:

> Do you use firefox and firebug?
>
> You can use the javascript console there to display to you any errors that
> might be occurring in your javascript.  You may have an issue earlier on in
> your page (with javascript) that is preventing the execution of your stuff
> later on.
>
> -Jim
>
> On Thursday, June 27, 2013 10:26:56 AM UTC-5, Tom Russell wrote:
>
>> So If I do something like:
>>
>> jAlert('This is a custom alert box', 'Alert Dialog');
>>
>> and nothing shows up, could it be that the jquery lib is not being made
>> available?
>>
>>
>> On Thu, Jun 27, 2013 at 11:00 AM, Tom Russell wrote:
>>
>>> k thanks I will try that
>>>
>>>
>>>
>>> On Thu, Jun 27, 2013 at 10:58 AM, Jim Steil  wrote:
>>>
>>>> I'd try putting some alert() messages in to try to trace the flow and
>>>> check the values of variables.
>>>>
>>>>
>>>>
>>>> On Thu, Jun 27, 2013 at 9:53 AM, Tom Russell wrote:
>>>>
>>>>> Thats weird, now it will not hide the the field but has no effect
>>>>> either when you check the checkbox.
>>>>>
>>>>>
>>>>> On Thu, Jun 27, 2013 at 12:11 AM, Jim S  wrote:
>>>>>
>>>>>> Try this, you need brackets for your if statements in javascript.
>>>>>>
>>>>>> jQuery(document).ready(functio**n(){
>>>>>>  jQuery('#no_table_mothers_**name__row').hide();
>>>>>>  jQuery('#is_newborn').change(**function(){
>>>>>>if(jQuery('#is_newborn').attr**('checked')) {
>>>>>>  jQuery('#no_table_mothers_**name__row').show();
>>>>>>} else {
>>>>>>  jQuery('#no_table_mothers_**name__row').hide();
>>>>>>});
>>>>>>  });
>>>>>> });
>>>>>>
>>>>>>
>>>>>> On Wednesday, June 26, 2013 9:09:00 PM UTC-5, Tom Russell wrote:
>>>>>>>
>>>>>>> I cannot seem to get some jquery code to work right and not sure
>>>>>>> why. Basically when I click a checkbox I want another field to appear 
>>>>>>> below
>>>>>>> that one.
>>>>>>>
>>>>>>> This is my form code:
>>>>>>>
>>>>>>> @auth.requires_login()
>>>>>>> def register_patient():
>>>>>>> mark_not_empty(db.patient)
>>>>>>> mark_not_empty(db.**emergencycontacts)
>>>>>>> mark_not_empty(db.dependents)
>>>>>>> db.patient.medical_record_**number.default = 'KND' +
>>>>>>> str(date.today().year) + '' + str(random.randrange(1, 999+1))
>>>>>>> db.patient.medical_record_**number.writable = False
>>>>>>> form=SQLFORM.factory(db.**patient, db.emergencycontacts,
>>>>>>> db.dependents)
>>>>>>>
>>>>>>> fs0=form[0][:27] #patient rows
>>>>>>> fs1=form[0][27:38]   #emergency contacts
>>>>>>> fs2=form[0][38:42] #dependents
>>>>>>> fs3=form[0][-1] # submit row (last)
>>>>>>>
>>>>>>> form[0]=TABLE(
>>>>>>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="**
>>>>>>> register0"),
>>>>>>> FIELDSET(TAG.legend("Emergency Contact Info"),TABLE(fs1),_id="**
>>>>>>> register1"),
>>>>>>> FIELDSET(TAG.legend("**Dependents"),TABLE(fs2),_id="**
>>>>>>> register2"),
>>>>>>> TABLE(fs3))
>>>>>>> if form.process().accepted:
>>>>>>> id = db.patient.insert(**db.**patient._filter_fields(form.**
>>>>>>> vars))
>>>>>>> form.vars.patient=id
>>>>>>> id = db.emergencycontacts.insert(
>>>>>>> db.emergencycontacts._filter_**fields(form.vars))
>>>>>>> id = db.dependents.insert(**db.**dependents._filter_fields(*
>>>>>>> *form.vars))
>>>

Re: [web2py] sqlform.factory widget in field problem

2013-06-27 Thread Tom Russell
Here's the rest of my code doing what I posted before...

if form.process().accepted:
id = db.patient.insert(**db.patient._filter_fields(form.vars))
form.vars.patient=id
id =
db.emergencycontacts.insert(**db.emergencycontacts._filter_fields(form.vars))
id = db.dependents.insert(**db.dependents._filter_fields(form.vars))
#form.vars.dependents=id
# and get a list of all persons
redirect(URL('manage_patients'))

style = STYLE(""".not_empty {color:#d00;}""")

return dict(form=DIV(style,form))


On Thu, Jun 27, 2013 at 5:31 PM, António Ramos  wrote:

> Using this suggestion , my submit button is inside the last fieldset.
> How do i take it outside?
>
>
> 2013/6/26 Tom Russell 
>
>> To group inside a field I do something like this with 3 different tables:
>>
>> form=SQLFORM.factory(db.patient, db.emergencycontacts, db.dependents)
>> fs0=form[0][:26] #patient rows
>> fs1=form[0][26:37]   #emergency contacts
>> fs2=form[0][37:41] #dependents
>> fs3=form[0][-1] # submit row (last)
>>
>> form[0]=TABLE(
>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
>> FIELDSET(TAG.legend("Emergency Contact
>> Info"),TABLE(fs1),_id="register1"),
>> FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
>> TABLE(fs3))
>>
>>
>> HTH
>>
>>
>> On Wed, Jun 26, 2013 at 11:58 AM, António Ramos wrote:
>>
>>> Just drafting something but here is the problem
>>>
>>> My context:
>>> I have 3 tables
>>>
>>> table form
>>> table steps
>>> table fields
>>>
>>> A form can have many steps
>>> a step can have many fields
>>>
>>> This way i can have one form with 3 steps, each with some fields and
>>> another form with 10 steps , each with some more fields.
>>>
>>> i read these tables to create a form using factory.
>>>
>>> i have 2 problems
>>>
>>>
>>> *1 i need to mark the input fields with a "step" tag *
>>>
>>> here is my code:
>>>
>>> def my_string_widget(field, value,step):
>>>
>>> return INPUT(_name=field.name,
>>>   _id="%s_%s" % (field._tablename, field.name),
>>>   _class=field.type,
>>>   _value='',
>>>   *_step=step,*
>>>   requires=field.requires)
>>>
>>> def index():
>>> cont=0
>>> fields=[]
>>> formid=db.form(request.args(0) or 1)
>>> steps=formid.steps.select()
>>> for step in steps:
>>> print "step id-",step.id
>>> for field in step.fields.select():
>>> print "field...",field.step
>>> fields.append(Field(field.nome,widget=lambda
>>> field,value:my_string_widget(field,value,*step.id*)))
>>>
>>> form=SQLFORM.factory(*fields)
>>> print form
>>> if form.process().accepted:
>>> response.flash='a gravar registo'
>>> return dict(nome=formid.nome,form=form)
>>>
>>>
>>> The problem is:
>>> It marks all fields with the same "step" value, the last value in *
>>> step.id, why?*
>>> *
>>> *
>>> *2 - sqlformfactory *
>>> how do i group sqlformfactory fields inside a div?
>>> i want to create a section for each step in the form to style with css
>>>
>>> Best regards
>>> António
>>>
>>> --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>  --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] sqlform.factory widget in field problem

2013-06-28 Thread Tom Russell
Actually probably just comment out the line:

fs3=form[0][-1] # submit row (last)

and that I think will put the submit outside the fieldset.


On Fri, Jun 28, 2013 at 2:50 AM, António Ramos  wrote:

> I dont understand how that gets the submit  button out of the last fieldset
>
>
> 2013/6/28 Tom Russell 
>
>> Here's the rest of my code doing what I posted before...
>>
>> if form.process().accepted:
>> id = db.patient.insert(**db.patient._filter_fields(form.vars))
>> form.vars.patient=id
>> id =
>> db.emergencycontacts.insert(**db.emergencycontacts._filter_fields(form.vars))
>> id =
>> db.dependents.insert(**db.dependents._filter_fields(form.vars))
>> #form.vars.dependents=id
>> # and get a list of all persons
>> redirect(URL('manage_patients'))
>>
>> style = STYLE(""".not_empty {color:#d00;}""")
>>
>> return dict(form=DIV(style,form))
>>
>>
>> On Thu, Jun 27, 2013 at 5:31 PM, António Ramos wrote:
>>
>>> Using this suggestion , my submit button is inside the last fieldset.
>>> How do i take it outside?
>>>
>>>
>>> 2013/6/26 Tom Russell 
>>>
>>>> To group inside a field I do something like this with 3 different
>>>> tables:
>>>>
>>>> form=SQLFORM.factory(db.patient, db.emergencycontacts, db.dependents)
>>>> fs0=form[0][:26] #patient rows
>>>> fs1=form[0][26:37]   #emergency contacts
>>>> fs2=form[0][37:41] #dependents
>>>> fs3=form[0][-1] # submit row (last)
>>>>
>>>> form[0]=TABLE(
>>>> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="register0"),
>>>> FIELDSET(TAG.legend("Emergency Contact
>>>> Info"),TABLE(fs1),_id="register1"),
>>>> FIELDSET(TAG.legend("Dependents"),TABLE(fs2),_id="register2"),
>>>> TABLE(fs3))
>>>>
>>>>
>>>> HTH
>>>>
>>>>
>>>> On Wed, Jun 26, 2013 at 11:58 AM, António Ramos 
>>>> wrote:
>>>>
>>>>> Just drafting something but here is the problem
>>>>>
>>>>> My context:
>>>>> I have 3 tables
>>>>>
>>>>> table form
>>>>> table steps
>>>>> table fields
>>>>>
>>>>> A form can have many steps
>>>>> a step can have many fields
>>>>>
>>>>> This way i can have one form with 3 steps, each with some fields and
>>>>> another form with 10 steps , each with some more fields.
>>>>>
>>>>> i read these tables to create a form using factory.
>>>>>
>>>>> i have 2 problems
>>>>>
>>>>>
>>>>> *1 i need to mark the input fields with a "step" tag *
>>>>>
>>>>> here is my code:
>>>>>
>>>>> def my_string_widget(field, value,step):
>>>>>
>>>>> return INPUT(_name=field.name,
>>>>>   _id="%s_%s" % (field._tablename, field.name),
>>>>>   _class=field.type,
>>>>>   _value='',
>>>>>   *_step=step,*
>>>>>   requires=field.requires)
>>>>>
>>>>> def index():
>>>>> cont=0
>>>>> fields=[]
>>>>> formid=db.form(request.args(0) or 1)
>>>>> steps=formid.steps.select()
>>>>> for step in steps:
>>>>> print "step id-",step.id
>>>>> for field in step.fields.select():
>>>>> print "field...",field.step
>>>>> fields.append(Field(field.nome,widget=lambda
>>>>> field,value:my_string_widget(field,value,*step.id*)))
>>>>>
>>>>> form=SQLFORM.factory(*fields)
>>>>> print form
>>>>> if form.process().accepted:
>>>>> response.flash='a gravar registo'
>>>>> return dict(nome=formid.nome,form=form)
>>>>>
>>>>>
>>>>> The problem is:
>>>>> It marks all fields with the same "step" value, the last value in *
>>>>> step.id, why?*
>>>>> *
>>>>> *
>>>>> *2 - sql

[web2py] confused about db.py settings

2013-06-28 Thread Tom Russell
I am confused about how I have my db.py set up for tables etc.

At the top I have what is generated for me:

if not request.env.web2py_runtime_gae:
## if NOT running on Google App Engine use SQLite or other DB
db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
else:
## connect to Google BigTable (optional 'google:datastore://namespace')
db = DAL('google:datastore')
## store sessions and tickets there
session.connect(request, response, db=db)
## or store session in Memcache, Redis, etc.
## from gluon.contrib.memdb import MEMDB
## from google.appengine.api.memcache import Client
## session.connect(request, response, db = MEMDB(Client()))

from gluon.tools import Auth, Crud, Service, PluginManager, prettydate,
Mail
auth = Auth(db)
crud, service, plugins = Crud(db), Service(), PluginManager()
db._common_fields.append(auth.signature) ## adds signature fields to all
tables
## create all tables needed by auth if not custom tables
auth.define_tables(username=True, signature=True)

And then from examples I have for my db down a ways is:

db = DAL('sqlite://webform.sqlite')

then I define my tables...


Problem with this is though I am trying to use
http://www.web2pyslices.com/slice/show/1542/manage-users-and-memebership-in-the-same-formbecause
I need that feature but when trying to use it I get an error cause
auth_user doesnt exist. Well it doesnt because I set db =
DAL('sqlite://webform.sqlite') but in default.py I do have:

def user():
"""
exposes:
http:///[app]/default/user/login
http:///[app]/default/user/logout
http:///[app]/default/user/register
http:///[app]/default/user/profile
http:///[app]/default/user/retrieve_password
http:///[app]/default/user/change_password
http:///[app]/default/user/manage_users (requires membership in
use @auth.requires_login()
@auth.requires_membership('group name')
@auth.requires_permission('read','table name',record_id)
to decorate functions that need access control
"""
return dict(form=auth())

So bottom line, how do I get around or use auth_user in my app. If I
comment out my
db = DAL('sqlite://webform.sqlite') but in default.py, nothing works.

Any help?

Thanks

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: confused about db.py settings

2013-06-28 Thread Tom Russell
Yea thanks I tried that as well with no luck. I ended up just creating a
new db_wizard.py in my model and this set up works great now. Its mentioned
in the book but thats it, just mentioned. For new users there should be a
guide to setting all of this up correctly. Maybe there is? I could write
something up when I am done sorting it all out.

Thanks


On Fri, Jun 28, 2013 at 12:51 PM, LightDot  wrote:

> Well, you have:
>
>
> db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
>
> defined, then you initiate auth with:
>
> auth.define_tables(username=True, signature=True)
>
> which sets up auth tables etc. in the above database. But then you
> override the previously set db with:
>
>
> db = DAL('sqlite://webform.sqlite')
>
> in which you define your own tables. So basically you have set up auth in
> one database, then you stop using it and use another database, which has no
> auth set up. That can't work.
>
> Simply define db just once, not twice. Use the definition web2py has
> suggested for you and change the database name if you want to.
>
> Regards,
> Ales
>
>
>
> On Friday, June 28, 2013 5:05:50 PM UTC+2, Tom Russell wrote:
>>
>> I am confused about how I have my db.py set up for tables etc.
>>
>> At the top I have what is generated for me:
>>
>> if not request.env.web2py_runtime_**gae:
>> ## if NOT running on Google App Engine use SQLite or other DB
>> db = DAL('sqlite://storage.sqlite',**pool_size=1,check_reserved=['**
>> all'])
>> else:
>> ## connect to Google BigTable (optional 'google:datastore://namespace'
>> **)
>> db = DAL('google:datastore')
>> ## store sessions and tickets there
>> session.connect(request, response, db=db)
>> ## or store session in Memcache, Redis, etc.
>> ## from gluon.contrib.memdb import MEMDB
>> ## from google.appengine.api.memcache import Client
>> ## session.connect(request, response, db = MEMDB(Client()))
>>
>> from gluon.tools import Auth, Crud, Service, PluginManager,
>> prettydate, Mail
>> auth = Auth(db)
>> crud, service, plugins = Crud(db), Service(), PluginManager()
>> db._common_fields.append(auth.**signature) ## adds signature fields to
>> all tables
>> ## create all tables needed by auth if not custom tables
>> auth.define_tables(username=**True, signature=True)
>>
>> And then from examples I have for my db down a ways is:
>>
>> db = DAL('sqlite://webform.sqlite')
>>
>> then I define my tables...
>>
>>
>> Problem with this is though I am trying to use http://www.web2pyslices.**
>> com/slice/show/1542/manage-**users-and-memebership-in-the-**same-form<http://www.web2pyslices.com/slice/show/1542/manage-users-and-memebership-in-the-same-form>because
>>  I need that feature but when trying to use it I get an error cause
>> auth_user doesnt exist. Well it doesnt because I set db =
>> DAL('sqlite://webform.sqlite') but in default.py I do have:
>>
>> def user():
>> """
>> exposes:
>> http:///[app]/default/**user/login
>> http:///[app]/default/**user/logout
>> http:///[app]/default/**user/register
>> http:///[app]/default/**user/profile
>> http:///[app]/default/**user/retrieve_password
>> http:///[app]/default/**user/change_password
>> http:///[app]/default/**user/manage_users (requires membership
>> in
>> use @auth.requires_login()
>> @auth.requires_membership('**group name')
>> @auth.requires_permission('**read','table name',record_id)
>> to decorate functions that need access control
>> """
>> return dict(form=auth())
>>
>> So bottom line, how do I get around or use auth_user in my app. If I
>> comment out my
>> db = DAL('sqlite://webform.sqlite') but in default.py, nothing works.
>>
>> Any help?
>>
>> Thanks
>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




  1   2   >