[web2py] Re: sqlform.factory, inserting variable number of records in an other table

2011-01-20 Thread Arun K.Rajeevan
The more dynamic the site develops into, I think it's better to use 
something like GWT (or pyjams)

You don't have to sacrifice SEO by building complete site in GWT but only 
parts of it.
That way, you can utilize best of both worlds. 
If you are using gwt you utilize many other grate libraries available (like 
ext-js wrapper for gwt)

May be this is not what you want. but an attempt to use gwt (or pyjams) 
helps to write code in same language as we develop and is more manageable ( 
for me at least)


Re: [web2py] Re: sqlform.factory, inserting variable number of records in an other table

2011-01-20 Thread Richard Vézina
I am hacking a lot to build a function to parse the resultant form to insert
as many rows as there is added with the js I write...

It is quite tricky for me since I am not so experienced in the web2py dev...
I dev app... But dev web2py is something else. I will propose something far
from be complete solution. And I don't know if it will not introduce
security concern into web2py.

I need to be able to load more then one table at a time and let user add the
number of sub table rows he needs... Maybe I am not doing it the right
way...

Maybe I should add input fields from python and regenerate a new form each
time don't know... Will see what Massimo and other users think.

I hope I have something working tomorrow.

I have not actually look at what will happen with validator... It is mostly
work in progress.

;-)

Richard



On Thu, Jan 20, 2011 at 3:11 PM, Arun K.Rajeevan the1.a...@gmail.comwrote:

 The more dynamic the site develops into, I think it's better to use
 something like GWT (or pyjams)

 You don't have to sacrifice SEO by building complete site in GWT but only
 parts of it.
 That way, you can utilize best of both worlds.
 If you are using gwt you utilize many other grate libraries available (like
 ext-js wrapper for gwt)

 May be this is not what you want. but an attempt to use gwt (or pyjams)
 helps to write code in same language as we develop and is more manageable (
 for me at least)



[web2py] Re: sqlform.factory, inserting variable number of records in an other table

2011-01-20 Thread mart
I would really look at the Massimo's audit trail sample to do what
you are saying (or a mix of both?)... This is how I manage the request
app I mentioned (Like a recipe : many tables with few Fields (like
name:value) are put together... with a large enough inventory of
tables it becomes easy to extend and  move forward with changing
demand... Anyways, I still need to try a few things that you mentioned
yesterday... The mental picture I keep in the back of my mind when
looking at what you sent looks like something I would use to manage
monthly bills (add a field for a new bill, and link it to a
category)... Here I would use a drop down to choose a table (like work
expense, or house expense, or kids, etc )... Does that define what
you are looking to do?

On Jan 20, 3:54 pm, Richard Vézina ml.richard.vez...@gmail.com
wrote:
 I am hacking a lot to build a function to parse the resultant form to insert
 as many rows as there is added with the js I write...

 It is quite tricky for me since I am not so experienced in the web2py dev...
 I dev app... But dev web2py is something else. I will propose something far
 from be complete solution. And I don't know if it will not introduce
 security concern into web2py.

 I need to be able to load more then one table at a time and let user add the
 number of sub table rows he needs... Maybe I am not doing it the right
 way...

 Maybe I should add input fields from python and regenerate a new form each
 time don't know... Will see what Massimo and other users think.

 I hope I have something working tomorrow.

 I have not actually look at what will happen with validator... It is mostly
 work in progress.

 ;-)

 Richard

 On Thu, Jan 20, 2011 at 3:11 PM, Arun K.Rajeevan the1.a...@gmail.comwrote:







  The more dynamic the site develops into, I think it's better to use
  something like GWT (or pyjams)

  You don't have to sacrifice SEO by building complete site in GWT but only
  parts of it.
  That way, you can utilize best of both worlds.
  If you are using gwt you utilize many other grate libraries available (like
  ext-js wrapper for gwt)

  May be this is not what you want. but an attempt to use gwt (or pyjams)
  helps to write code in same language as we develop and is more manageable (
  for me at least)


Re: [web2py] Re: sqlform.factory, inserting variable number of records in an other table

2011-01-20 Thread Richard Vézina
Client
Address


1 client can have many address...

In web2py as far as I know you will do form creating client 1 in Client
table

Then go in form address and add as many address you need to to a client that
you pick in a dropdown.

I would like to add the many address in one form :

Here the fields of the form :

Name
Street
City

So

Name is Client field

Street and city are Address field

You can handle the form generation with SQLFORM.factory(db.client,
db.address)

Then the js I wrote let you add as many input you want for subform or table
Address.

So you get a new form from the view and you need to process the inputs to
insert street and city from each inputs by pairs...

street input1
city input1
insert

street input2
city input2
insert

Etc.

I near of it...

Richard




On Thu, Jan 20, 2011 at 4:47 PM, mart msenecal...@gmail.com wrote:

 I would really look at the Massimo's audit trail sample to do what
 you are saying (or a mix of both?)... This is how I manage the request
 app I mentioned (Like a recipe : many tables with few Fields (like
 name:value) are put together... with a large enough inventory of
 tables it becomes easy to extend and  move forward with changing
 demand... Anyways, I still need to try a few things that you mentioned
 yesterday... The mental picture I keep in the back of my mind when
 looking at what you sent looks like something I would use to manage
 monthly bills (add a field for a new bill, and link it to a
 category)... Here I would use a drop down to choose a table (like work
 expense, or house expense, or kids, etc )... Does that define what
 you are looking to do?

 On Jan 20, 3:54 pm, Richard Vézina ml.richard.vez...@gmail.com
 wrote:
  I am hacking a lot to build a function to parse the resultant form to
 insert
  as many rows as there is added with the js I write...
 
  It is quite tricky for me since I am not so experienced in the web2py
 dev...
  I dev app... But dev web2py is something else. I will propose something
 far
  from be complete solution. And I don't know if it will not introduce
  security concern into web2py.
 
  I need to be able to load more then one table at a time and let user add
 the
  number of sub table rows he needs... Maybe I am not doing it the right
  way...
 
  Maybe I should add input fields from python and regenerate a new form
 each
  time don't know... Will see what Massimo and other users think.
 
  I hope I have something working tomorrow.
 
  I have not actually look at what will happen with validator... It is
 mostly
  work in progress.
 
  ;-)
 
  Richard
 
  On Thu, Jan 20, 2011 at 3:11 PM, Arun K.Rajeevan the1.a...@gmail.com
 wrote:
 
 
 
 
 
 
 
   The more dynamic the site develops into, I think it's better to use
   something like GWT (or pyjams)
 
   You don't have to sacrifice SEO by building complete site in GWT but
 only
   parts of it.
   That way, you can utilize best of both worlds.
   If you are using gwt you utilize many other grate libraries available
 (like
   ext-js wrapper for gwt)
 
   May be this is not what you want. but an attempt to use gwt (or pyjams)
   helps to write code in same language as we develop and is more
 manageable (
   for me at least)



Re: [web2py] Re: sqlform.factory, inserting variable number of records in an other table

2011-01-17 Thread Richard Vézina
Thanks Mart... I read back my mail and my english was terrible. ;-)

I thought about it after sent the mail and I realise that subform seems what
I was searching for.

I will try what you propose and give feedback here.

Richard

On Sun, Jan 16, 2011 at 10:43 PM, mart msenecal...@gmail.com wrote:

 You know, I discovered a week or 2 ago a way to make a form appear to
 have sub-forms (or sub-templates). Massimo's 'Audit Trail' (i think I
 saw it on web2pyslices) serves this purpose extremely well. To that,
 it becomes very easy to write scripts to generate all sorts of
 combinations of tables that exist to those that can be generated
 dynamically. Anyways, from the Audit trail idea, I made a requests
 app, that serves many different categories and types of requests,
 where forms can be created/generated on the fly.

 If I were doing something like you described, I would probably try
 something like this

 test_1=db.Table(None,'test_1',
 Field('results','??')
Field('whomadethetest','string'),
Field('date','date'))

 test_2=db.Table(None,'test_2',
 Field('results','??')
Field('whomadethetest','string'),
Field('date','date'))

 then you could do this (or have scripts generate it):

 db.define_table('result',
Field('length','integer'),
Field('width','integer'),
 Field('result','integer'),
test_1)

 or

 db.define_table('result',
Field('length','integer'),
Field('width','integer'),
 Field('result','integer'),
test_1,
test2)

 or just the test results:

 db.define_table('result',test_1,test2)

 etc...

 Hope it helps,
 Mart :)


 On Jan 16, 4:38 pm, Richard Vézina ml.richard.vez...@gmail.com
 wrote:
  Hello,
 
  Let me expose my problem. I have a test (experience test that I made in
 lab)
  that I have to redo many time. At time point 1 there is only one result,
 but
  at the other time point the is one more result to store each time. So at
  time point 2 there is two results, at time point 3 there is 3 results and
 so
  on.
 
  Since the number of time point is not fixed I can create a given number
 of
  columns to handle this probleme in a not normalized way. Say fill with
 null
  the empty columns when the results are not available for a particular
 record
  (or a given time point).
 
  To normalize the schema I can do :
 
  db.define_table('result',
  Field('length','integer'),
  Field('width','integer'),
  Field('result','integer'))
 
  db.define_table('test1',
  Field('results','list:integer result')
  Field('whomadethetest','string'),
  Field('date','date'))
 
  db.test1.results.requires = IS_IN_DB(db,'result.id',db.
  result._format,multiple=True)
 
  I could add my result one by one in the result table and then pick them
  up...
 
  But I would do something sexier then that.
 
  I would like to be able to add any number of record by adding the row of
  result table in the same form of test1 table.
 
  So my model should be :
 
  db.define_table('test1',
  Field('results','??')
  Field('whomadethetest','string'),
  Field('date','date'))
 
  db.define_table('result',
  Field('length','integer'),
  Field('width','integer'),
  Field('result','integer'),
  Field('test1_id','db.test1')
 
  I have now a 1:n relation that is stored in result table.
 
  I would build a widget that let insert all the fields of an other table
 row
  by row. So if I have one result generated at time point 1 there will be
 one
  row in my form. But if I am a later time point there will have 2 rows for
  time point 2 and 3 for time point 3, etc.
 
  It could has a button to add more empty row that could be filled out.
 
  I read an search a lot. I found web2py_component that could be of some
  utility, but I am not sure since it seams to work with form in a global
  manner and not support field. SQLFORM.factory look the way to go before
  build the whole thing from scratch with form...
 
  If any of you have a android phone, I would make a form that looks and
 works
  like the contact app. You can add any number of phone number for the same
  contact by pressing + button to add an other empty box (field).
 
  Do I must made a custom widget (widget seams to be reserved to a single
 form
  processing), build custom form with helpers, or could SQLFORM.factory is
  enough???
 
  Thanks
 
  Richard



Re: [web2py] Re: sqlform.factory, inserting variable number of records in an other table

2011-01-17 Thread Richard Vézina
Not exactly what I seaching for...

As far as I understand... It only let you simplified code by isolated
repetitive piece of model code. Since it's only create one table I can't
have a normalized schema.

I would do something like this :

http://charlie.griefer.com/blog/index.cfm/2009/9/17/jQuery--Dynamically-Adding-Form-Elements
see
demo link in page

This snippet seems much more interresting since you can even pick the type
of input field you want to create :
http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-elements-via-javascript/
second
example

This can let me insert the other form field (or subform) in my first form
then I could use jQuery to add more row in my second table or subform... But
I have 2 submit buttons and I will have to set the ID of the first form as a
foreigh key for the second form or table manually :
http://www.mail-archive.com/web2py@googlegroups.com/msg31293.html

Richard


On Mon, Jan 17, 2011 at 8:46 AM, Richard Vézina ml.richard.vez...@gmail.com
 wrote:

 Thanks Mart... I read back my mail and my english was terrible. ;-)

 I thought about it after sent the mail and I realise that subform seems
 what I was searching for.

  I will try what you propose and give feedback here.

 Richard

 On Sun, Jan 16, 2011 at 10:43 PM, mart msenecal...@gmail.com wrote:

 You know, I discovered a week or 2 ago a way to make a form appear to
 have sub-forms (or sub-templates). Massimo's 'Audit Trail' (i think I
 saw it on web2pyslices) serves this purpose extremely well. To that,
 it becomes very easy to write scripts to generate all sorts of
 combinations of tables that exist to those that can be generated
 dynamically. Anyways, from the Audit trail idea, I made a requests
 app, that serves many different categories and types of requests,
 where forms can be created/generated on the fly.

 If I were doing something like you described, I would probably try
 something like this

 test_1=db.Table(None,'test_1',
 Field('results','??')
Field('whomadethetest','string'),
Field('date','date'))

 test_2=db.Table(None,'test_2',
 Field('results','??')
Field('whomadethetest','string'),
Field('date','date'))

 then you could do this (or have scripts generate it):

 db.define_table('result',
Field('length','integer'),
Field('width','integer'),
 Field('result','integer'),
test_1)

 or

 db.define_table('result',
Field('length','integer'),
Field('width','integer'),
 Field('result','integer'),
test_1,
test2)

 or just the test results:

 db.define_table('result',test_1,test2)

 etc...

 Hope it helps,
 Mart :)


 On Jan 16, 4:38 pm, Richard Vézina ml.richard.vez...@gmail.com
 wrote:
  Hello,
 
  Let me expose my problem. I have a test (experience test that I made in
 lab)
  that I have to redo many time. At time point 1 there is only one result,
 but
  at the other time point the is one more result to store each time. So at
  time point 2 there is two results, at time point 3 there is 3 results
 and so
  on.
 
  Since the number of time point is not fixed I can create a given number
 of
  columns to handle this probleme in a not normalized way. Say fill with
 null
  the empty columns when the results are not available for a particular
 record
  (or a given time point).
 
  To normalize the schema I can do :
 
  db.define_table('result',
  Field('length','integer'),
  Field('width','integer'),
  Field('result','integer'))
 
  db.define_table('test1',
  Field('results','list:integer result')
  Field('whomadethetest','string'),
  Field('date','date'))
 
  db.test1.results.requires = IS_IN_DB(db,'result.id',db.
  result._format,multiple=True)
 
  I could add my result one by one in the result table and then pick them
  up...
 
  But I would do something sexier then that.
 
  I would like to be able to add any number of record by adding the row of
  result table in the same form of test1 table.
 
  So my model should be :
 
  db.define_table('test1',
  Field('results','??')
  Field('whomadethetest','string'),
  Field('date','date'))
 
  db.define_table('result',
  Field('length','integer'),
  Field('width','integer'),
  Field('result','integer'),
  Field('test1_id','db.test1')
 
  I have now a 1:n relation that is stored in result table.
 
  I would build a widget that let insert all the fields of an other table
 row
  by row. So if I have one result generated at time point 1 there will be
 one
  row in my form. But if I am a later time point there will have 2 rows
 for
  time point 2 and 3 for time point 3, etc.
 
  It could has a button to add more empty row that could be filled out.
 
  I read an search a lot. I found web2py_component that could be of some
  utility, but I am not sure since it seams to work with form in a global
  manner and not support field. SQLFORM.factory look the way to go before
  build the whole thing from scratch with form...
 
  If any of you 

[web2py] Re: sqlform.factory, inserting variable number of records in an other table

2011-01-17 Thread mart
yes, I see what you mean... that is interesting... Now, you have me
wanting to look into that too ;) Could be very useful as a plugin (or
ready made snippet of code), you are right with that.

Mart :)

On Jan 17, 1:08 pm, Richard Vézina ml.richard.vez...@gmail.com
wrote:
 Not exactly what I seaching for...

 As far as I understand... It only let you simplified code by isolated
 repetitive piece of model code. Since it's only create one table I can't
 have a normalized schema.

 I would do something like this :

 http://charlie.griefer.com/blog/index.cfm/2009/9/17/jQuery--Dynamical...
 see
 demo link in page

 This snippet seems much more interresting since you can even pick the type
 of input field you want to create 
 :http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-...
 second
 example

 This can let me insert the other form field (or subform) in my first form
 then I could use jQuery to add more row in my second table or subform... But
 I have 2 submit buttons and I will have to set the ID of the first form as a
 foreigh key for the second form or table manually 
 :http://www.mail-archive.com/web2py@googlegroups.com/msg31293.html

 Richard

 On Mon, Jan 17, 2011 at 8:46 AM, Richard Vézina ml.richard.vez...@gmail.com







  wrote:
  Thanks Mart... I read back my mail and my english was terrible. ;-)

  I thought about it after sent the mail and I realise that subform seems
  what I was searching for.

   I will try what you propose and give feedback here.

  Richard

  On Sun, Jan 16, 2011 at 10:43 PM, mart msenecal...@gmail.com wrote:

  You know, I discovered a week or 2 ago a way to make a form appear to
  have sub-forms (or sub-templates). Massimo's 'Audit Trail' (i think I
  saw it on web2pyslices) serves this purpose extremely well. To that,
  it becomes very easy to write scripts to generate all sorts of
  combinations of tables that exist to those that can be generated
  dynamically. Anyways, from the Audit trail idea, I made a requests
  app, that serves many different categories and types of requests,
  where forms can be created/generated on the fly.

  If I were doing something like you described, I would probably try
  something like this

  test_1=db.Table(None,'test_1',
      Field('results','??')
     Field('whomadethetest','string'),
     Field('date','date'))

  test_2=db.Table(None,'test_2',
      Field('results','??')
     Field('whomadethetest','string'),
     Field('date','date'))

  then you could do this (or have scripts generate it):

  db.define_table('result',
     Field('length','integer'),
     Field('width','integer'),
      Field('result','integer'),
     test_1)

  or

  db.define_table('result',
     Field('length','integer'),
     Field('width','integer'),
      Field('result','integer'),
     test_1,
     test2)

  or just the test results:

  db.define_table('result',test_1,test2)

  etc...

  Hope it helps,
  Mart :)

  On Jan 16, 4:38 pm, Richard Vézina ml.richard.vez...@gmail.com
  wrote:
   Hello,

   Let me expose my problem. I have a test (experience test that I made in
  lab)
   that I have to redo many time. At time point 1 there is only one result,
  but
   at the other time point the is one more result to store each time. So at
   time point 2 there is two results, at time point 3 there is 3 results
  and so
   on.

   Since the number of time point is not fixed I can create a given number
  of
   columns to handle this probleme in a not normalized way. Say fill with
  null
   the empty columns when the results are not available for a particular
  record
   (or a given time point).

   To normalize the schema I can do :

   db.define_table('result',
       Field('length','integer'),
       Field('width','integer'),
       Field('result','integer'))

   db.define_table('test1',
       Field('results','list:integer result')
       Field('whomadethetest','string'),
       Field('date','date'))

   db.test1.results.requires = IS_IN_DB(db,'result.id',db.
   result._format,multiple=True)

   I could add my result one by one in the result table and then pick them
   up...

   But I would do something sexier then that.

   I would like to be able to add any number of record by adding the row of
   result table in the same form of test1 table.

   So my model should be :

   db.define_table('test1',
       Field('results','??')
       Field('whomadethetest','string'),
       Field('date','date'))

   db.define_table('result',
       Field('length','integer'),
       Field('width','integer'),
       Field('result','integer'),
       Field('test1_id','db.test1')

   I have now a 1:n relation that is stored in result table.

   I would build a widget that let insert all the fields of an other table
  row
   by row. So if I have one result generated at time point 1 there will be
  one
   row in my form. But if I am a later time point there will have 2 rows
  for
   time point 2 and 3 for time point 3, etc.

   It could has a button to 

Re: [web2py] Re: sqlform.factory, inserting variable number of records in an other table

2011-01-17 Thread Richard Vézina
There is a couple of little problem with the script : one have been
corrected by someone post... Look at Raymond on 9/2/10 12:11 AM

The other problem, actually not a problem, but it could be much more fun for
user to be able to erase only the added line they mistake on...

So having a button erase on the side of every added row.

It pretty much like Gmail contact interface...

The last thing I would like is to be able to add more then only one
subfield. For example, if I have

Client
Name

Address
Street
City

I would have form like this

Name :
Street | City
emptyboxstreetrow1 | emptyboxcityrow1 trashcan button
emptyboxstreetrow2 | emptyboxcityrow2 trashcan button

I guest it could be easier like this in the first place :

Name :
Street :
City :
Street :
City :
etc.


Here the SQLFORM.factory doc link that should be the way to generate the
basic form that can then be modify by Charlie's script


http://www.web2py.com/book/default/chapter/07#SQLFORM.factory

Richard

On Mon, Jan 17, 2011 at 1:56 PM, mart msenecal...@gmail.com wrote:

 yes, I see what you mean... that is interesting... Now, you have me
 wanting to look into that too ;) Could be very useful as a plugin (or
 ready made snippet of code), you are right with that.

 Mart :)

 On Jan 17, 1:08 pm, Richard Vézina ml.richard.vez...@gmail.com
 wrote:
  Not exactly what I seaching for...
 
  As far as I understand... It only let you simplified code by isolated
  repetitive piece of model code. Since it's only create one table I can't
  have a normalized schema.
 
  I would do something like this :
 
  http://charlie.griefer.com/blog/index.cfm/2009/9/17/jQuery--Dynamical...
  see
  demo link in page
 
  This snippet seems much more interresting since you can even pick the
 type
  of input field you want to create :
 http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-...
  second
  example
 
  This can let me insert the other form field (or subform) in my first form
  then I could use jQuery to add more row in my second table or subform...
 But
  I have 2 submit buttons and I will have to set the ID of the first form
 as a
  foreigh key for the second form or table manually :
 http://www.mail-archive.com/web2py@googlegroups.com/msg31293.html
 
  Richard
 
  On Mon, Jan 17, 2011 at 8:46 AM, Richard Vézina 
 ml.richard.vez...@gmail.com
 
 
 
 
 
 
 
   wrote:
   Thanks Mart... I read back my mail and my english was terrible. ;-)
 
   I thought about it after sent the mail and I realise that subform seems
   what I was searching for.
 
I will try what you propose and give feedback here.
 
   Richard
 
   On Sun, Jan 16, 2011 at 10:43 PM, mart msenecal...@gmail.com wrote:
 
   You know, I discovered a week or 2 ago a way to make a form appear to
   have sub-forms (or sub-templates). Massimo's 'Audit Trail' (i think I
   saw it on web2pyslices) serves this purpose extremely well. To that,
   it becomes very easy to write scripts to generate all sorts of
   combinations of tables that exist to those that can be generated
   dynamically. Anyways, from the Audit trail idea, I made a requests
   app, that serves many different categories and types of requests,
   where forms can be created/generated on the fly.
 
   If I were doing something like you described, I would probably try
   something like this
 
   test_1=db.Table(None,'test_1',
   Field('results','??')
  Field('whomadethetest','string'),
  Field('date','date'))
 
   test_2=db.Table(None,'test_2',
   Field('results','??')
  Field('whomadethetest','string'),
  Field('date','date'))
 
   then you could do this (or have scripts generate it):
 
   db.define_table('result',
  Field('length','integer'),
  Field('width','integer'),
   Field('result','integer'),
  test_1)
 
   or
 
   db.define_table('result',
  Field('length','integer'),
  Field('width','integer'),
   Field('result','integer'),
  test_1,
  test2)
 
   or just the test results:
 
   db.define_table('result',test_1,test2)
 
   etc...
 
   Hope it helps,
   Mart :)
 
   On Jan 16, 4:38 pm, Richard Vézina ml.richard.vez...@gmail.com
   wrote:
Hello,
 
Let me expose my problem. I have a test (experience test that I made
 in
   lab)
that I have to redo many time. At time point 1 there is only one
 result,
   but
at the other time point the is one more result to store each time.
 So at
time point 2 there is two results, at time point 3 there is 3
 results
   and so
on.
 
Since the number of time point is not fixed I can create a given
 number
   of
columns to handle this probleme in a not normalized way. Say fill
 with
   null
the empty columns when the results are not available for a
 particular
   record
(or a given time point).
 
To normalize the schema I can do :
 
db.define_table('result',
Field('length','integer'),
Field('width','integer'),

[web2py] Re: sqlform.factory, inserting variable number of records in an other table

2011-01-16 Thread mart
You know, I discovered a week or 2 ago a way to make a form appear to
have sub-forms (or sub-templates). Massimo's 'Audit Trail' (i think I
saw it on web2pyslices) serves this purpose extremely well. To that,
it becomes very easy to write scripts to generate all sorts of
combinations of tables that exist to those that can be generated
dynamically. Anyways, from the Audit trail idea, I made a requests
app, that serves many different categories and types of requests,
where forms can be created/generated on the fly.

If I were doing something like you described, I would probably try
something like this

test_1=db.Table(None,'test_1',
Field('results','??')
Field('whomadethetest','string'),
Field('date','date'))

test_2=db.Table(None,'test_2',
Field('results','??')
Field('whomadethetest','string'),
Field('date','date'))

then you could do this (or have scripts generate it):

db.define_table('result',
Field('length','integer'),
Field('width','integer'),
Field('result','integer'),
test_1)

or

db.define_table('result',
Field('length','integer'),
Field('width','integer'),
Field('result','integer'),
test_1,
test2)

or just the test results:

db.define_table('result',test_1,test2)

etc...

Hope it helps,
Mart :)


On Jan 16, 4:38 pm, Richard Vézina ml.richard.vez...@gmail.com
wrote:
 Hello,

 Let me expose my problem. I have a test (experience test that I made in lab)
 that I have to redo many time. At time point 1 there is only one result, but
 at the other time point the is one more result to store each time. So at
 time point 2 there is two results, at time point 3 there is 3 results and so
 on.

 Since the number of time point is not fixed I can create a given number of
 columns to handle this probleme in a not normalized way. Say fill with null
 the empty columns when the results are not available for a particular record
 (or a given time point).

 To normalize the schema I can do :

 db.define_table('result',
     Field('length','integer'),
     Field('width','integer'),
     Field('result','integer'))

 db.define_table('test1',
     Field('results','list:integer result')
     Field('whomadethetest','string'),
     Field('date','date'))

 db.test1.results.requires = IS_IN_DB(db,'result.id',db.
 result._format,multiple=True)

 I could add my result one by one in the result table and then pick them
 up...

 But I would do something sexier then that.

 I would like to be able to add any number of record by adding the row of
 result table in the same form of test1 table.

 So my model should be :

 db.define_table('test1',
     Field('results','??')
     Field('whomadethetest','string'),
     Field('date','date'))

 db.define_table('result',
     Field('length','integer'),
     Field('width','integer'),
     Field('result','integer'),
     Field('test1_id','db.test1')

 I have now a 1:n relation that is stored in result table.

 I would build a widget that let insert all the fields of an other table row
 by row. So if I have one result generated at time point 1 there will be one
 row in my form. But if I am a later time point there will have 2 rows for
 time point 2 and 3 for time point 3, etc.

 It could has a button to add more empty row that could be filled out.

 I read an search a lot. I found web2py_component that could be of some
 utility, but I am not sure since it seams to work with form in a global
 manner and not support field. SQLFORM.factory look the way to go before
 build the whole thing from scratch with form...

 If any of you have a android phone, I would make a form that looks and works
 like the contact app. You can add any number of phone number for the same
 contact by pressing + button to add an other empty box (field).

 Do I must made a custom widget (widget seams to be reserved to a single form
 processing), build custom form with helpers, or could SQLFORM.factory is
 enough???

 Thanks

 Richard