Re: [web2py] Re: Self-joins not working.

2012-12-02 Thread Luc Chase

It works fine if I remove 'format=' 

db.t_project.f_parent_project.requires = IS_EMPTY_OR(IS_IN_DB(db,'
t_project.id',db.t_project._format))


--
Luc.


On Saturday, 1 December 2012 07:57:16 UTC, Luc Chase wrote:

 
 db.define_table('t_project',
 Field('f_name', type='string',
   label=T('Name')),
 Field('f_parent_project', type='reference t_project',
   label=T('Parent Project')),
 Field('f_description', type='string',
   label=T('Description')),
 Field('f_start_on', type='date',
   label=T('Start On')),
 Field('f_colour', type='string',
   label=T('Colour')),
 Field('f_company_code', type='text',
   label=T('Company Code')),
 Field('f_status', type='boolean',
   label=T('Status')),
 auth.signature,
 format='%(f_name)s',
 migrate=settings.migrate)

 db.t_project.f_parent_project.requires = IS_EMPTY_OR(IS_IN_DB(db,'
 t_project.id',format=db.t_project._format))

 db.define_table('t_project_archive',db.t_project,Field('current_record','reference
  
 t_project',readable=False,writable=False))




 On Friday, 30 November 2012 13:50:34 UTC, Anthony wrote:

 The format argument goes in the define_table() call -- is that where you 
 have it?

 Anthony

 On Friday, November 30, 2012 1:58:09 AM UTC-5, Luc Chase wrote:

 Thanks for the suggestion.  I had tried something similar but got an 
 error and even with this I have an error referencing to the unexpected use 
 of 'format'.

 type 'exceptions.TypeError' __init__() got an unexpected keyword 
 argument 'format'VERSIONweb2py™(2, 2, 1, datetime.datetime(2012, 10, 
 21, 16, 57, 4), 'stable')PythonPython 2.7: C:\Program 
 Files\Python\web2py_win\web2py\web2py.exeTRACEBACK

 1.
 2.
 3.
 4.
 5.

 Traceback (most recent call last):
   File gluon/restricted.py, line 212, in restricted
   File C:/Program 
 Files/Python/web2py_win/web2py/applications/Timesheet/models/db_wizard.py 
 http://127.0.0.1:8000/admin/default/edit/Timesheet/models/db_wizard.py, 
 line 40, in module
 TypeError: __init__() got an unexpected keyword argument 'format'

 ERROR SNAPSHOT [image: help]

 type 'exceptions.TypeError'(__init__() got an unexpected keyword 
 argument 'format')

 On Thursday, 29 November 2012 02:08:58 UTC, Massimo Di Pierro wrote:

 The problem is that it cannot assign the default validator unless the 
 table is defined. You can do

 db.define_table('t_project',
 Field('f_name', type='string',
   label=T('Name')),
 Field('f_parent_project', type='reference t_project',
   label=T('Parent Project')),
 
 format='%(f_name)s',
 migrate=settings.migrate)

 db.t_project.f_name.requires = IS_EMPTY_OR(IS_IN_DB(db,'t_project.id
 ',format=db.t_project._format))

 The last line will restore the dropdown.


 On Wednesday, 28 November 2012 14:39:14 UTC-6, Jim S wrote:

 I'm seeing this as well.

 -Jim


 On Tuesday, November 27, 2012 12:09:18 PM UTC-6, Luc Chase wrote:

 If the reference is to a different table, the CRUD form renders the 
 field as a list box allowing the user to select the record from the 
 foreign 
 table.  But as a self-join the CRUD form renders the field as a simple 
 text 
 box and it seems to create a default value of 0 when saved. Then, I 
 think 
 that causes the record to generate an error when viewed ( but not when 
 edited).


 I can post the entire models file if that would help.
  


-- 





Re: [web2py] Re: Self-joins not working.

2012-12-01 Thread Luc Chase
Would the test include a test of the Wizard's ability to implement this? 
 The error first surfaced there.


--
Luc.

On Friday, 30 November 2012 15:15:39 UTC, Richard wrote:

 Ask again when you are ready I have little app dedicated to check for this 
 issue.

 Richard

 On Fri, Nov 30, 2012 at 10:10 AM, Massimo Di Pierro 
 massimo@gmail.comjavascript:
  wrote:

 Correction. Not fixed.


 On Friday, November 30, 2012 9:10:30 AM UTC-6, Massimo Di Pierro wrote:

 Can you check trunk? I just submitted a patch that should have fixed 
 this problem. The price: slower table initilization but perhaps negligible.

 On Friday, November 30, 2012 8:51:06 AM UTC-6, Richard wrote:

 I open an issue in the pass about that.

 http://code.google.com/p/**web2py/issues/detail?id=382http://code.google.com/p/web2py/issues/detail?id=382

 Richard

 On Fri, Nov 30, 2012 at 8:50 AM, Anthony abas...@gmail.com wrote:

 The format argument goes in the define_table() call -- is that where 
 you have it?

 Anthony

 On Friday, November 30, 2012 1:58:09 AM UTC-5, Luc Chase wrote:

 Thanks for the suggestion.  I had tried something similar but got an 
 error and even with this I have an error referencing to the unexpected 
 use 
 of 'format'.


 type 'exceptions.TypeError' __init__() got an unexpected keyword 
 argument 'format' VERSION web2py™ (2, 2, 1, datetime.datetime(2012, 
 10, 21, 16, 57, 4), 'stable') PythonPython 2.7: C:\Program 
 Files\Python\web2py_win\**web2py**\web2py.exe TRACEBACK

 1.
 2.
 3.
 4.
 5.

 Traceback (most recent call last):
   File gluon/restricted.py, line 212, in restricted


   File C:/Program 
 Files/Python/web2py_win/**web2py**/applications/Timesheet/**models**/db_wizard.py
  
 http://127.0.0.1:8000/admin/default/edit/Timesheet/models/db_wizard.py,
  line 40, in module

 TypeError: __init__() got an unexpected keyword argument 'format'

  ERROR SNAPSHOT [image: help]

 type 'exceptions.TypeError'(__**init**__() got an unexpected 
 keyword argument 'format')

 On Thursday, 29 November 2012 02:08:58 UTC, Massimo Di Pierro wrote:

 The problem is that it cannot assign the default validator unless 
 the table is defined. You can do

 db.define_table('t_project',
 Field('f_name', type='string',
   label=T('Name')),
 Field('f_parent_project', type='reference t_project',
   label=T('Parent Project')),
 
 format='%(f_name)s',
 migrate=settings.migrate)

 db.t_project.f_name.requires = IS_EMPTY_OR(IS_IN_DB(db,'t_**pro**
 ject.id http://t_project.id',format=db.t_**project._**format))

 The last line will restore the dropdown.


 On Wednesday, 28 November 2012 14:39:14 UTC-6, Jim S wrote:

 I'm seeing this as well.

 -Jim


 On Tuesday, November 27, 2012 12:09:18 PM UTC-6, Luc Chase wrote:

 If the reference is to a different table, the CRUD form renders 
 the field as a list box allowing the user to select the record from 
 the 
 foreign table.  But as a self-join the CRUD form renders the field as 
 a 
 simple text box and it seems to create a default value of 0 when 
 saved. 
 Then, I think that causes the record to generate an error when viewed 
 ( but 
 not when edited).


 I can post the entire models file if that would help.
  
  -- 
  
  
  


  -- 
  
  
  




-- 





Re: [web2py] Re: Self-joins not working.

2012-11-30 Thread Anthony
The format argument goes in the define_table() call -- is that where you 
have it?

Anthony

On Friday, November 30, 2012 1:58:09 AM UTC-5, Luc Chase wrote:

 Thanks for the suggestion.  I had tried something similar but got an error 
 and even with this I have an error referencing to the unexpected use of 
 'format'.

 type 'exceptions.TypeError' __init__() got an unexpected keyword 
 argument 'format'VERSIONweb2py™(2, 2, 1, datetime.datetime(2012, 10, 21, 
 16, 57, 4), 'stable')PythonPython 2.7: C:\Program 
 Files\Python\web2py_win\web2py\web2py.exeTRACEBACK

 1.
 2.
 3.
 4.
 5.

 Traceback (most recent call last):
   File gluon/restricted.py, line 212, in restricted
   File C:/Program 
 Files/Python/web2py_win/web2py/applications/Timesheet/models/db_wizard.py 
 http://127.0.0.1:8000/admin/default/edit/Timesheet/models/db_wizard.py, 
 line 40, in module
 TypeError: __init__() got an unexpected keyword argument 'format'

 ERROR SNAPSHOT [image: help]

 type 'exceptions.TypeError'(__init__() got an unexpected keyword 
 argument 'format')

 On Thursday, 29 November 2012 02:08:58 UTC, Massimo Di Pierro wrote:

 The problem is that it cannot assign the default validator unless the 
 table is defined. You can do

 db.define_table('t_project',
 Field('f_name', type='string',
   label=T('Name')),
 Field('f_parent_project', type='reference t_project',
   label=T('Parent Project')),
 
 format='%(f_name)s',
 migrate=settings.migrate)

 db.t_project.f_name.requires = IS_EMPTY_OR(IS_IN_DB(db,'t_project.id
 ',format=db.t_project._format))

 The last line will restore the dropdown.


 On Wednesday, 28 November 2012 14:39:14 UTC-6, Jim S wrote:

 I'm seeing this as well.

 -Jim


 On Tuesday, November 27, 2012 12:09:18 PM UTC-6, Luc Chase wrote:

 If the reference is to a different table, the CRUD form renders the 
 field as a list box allowing the user to select the record from the 
 foreign 
 table.  But as a self-join the CRUD form renders the field as a simple 
 text 
 box and it seems to create a default value of 0 when saved. Then, I think 
 that causes the record to generate an error when viewed ( but not when 
 edited).


 I can post the entire models file if that would help.
  


-- 





Re: [web2py] Re: Self-joins not working.

2012-11-30 Thread Richard Vézina
I open an issue in the pass about that.

http://code.google.com/p/web2py/issues/detail?id=382

Richard

On Fri, Nov 30, 2012 at 8:50 AM, Anthony abasta...@gmail.com wrote:

 The format argument goes in the define_table() call -- is that where you
 have it?

 Anthony

 On Friday, November 30, 2012 1:58:09 AM UTC-5, Luc Chase wrote:

 Thanks for the suggestion.  I had tried something similar but got an
 error and even with this I have an error referencing to the unexpected use
 of 'format'.


 type 'exceptions.TypeError' __init__() got an unexpected keyword
 argument 'format'VERSIONweb2py™(2, 2, 1, datetime.datetime(2012, 10, 21,
 16, 57, 4), 'stable')PythonPython 2.7: C:\Program
 Files\Python\web2py_win\**web2py\web2py.exeTRACEBACK

 1.
 2.
 3.
 4.
 5.

 Traceback (most recent call last):
   File gluon/restricted.py, line 212, in restricted
   File C:/Program 
 Files/Python/web2py_win/**web2py/applications/Timesheet/**models/db_wizard.py
  http://127.0.0.1:8000/admin/default/edit/Timesheet/models/db_wizard.py, 
 line 40, in module
 TypeError: __init__() got an unexpected keyword argument 'format'

 ERROR SNAPSHOT [image: help]

 type 'exceptions.TypeError'(__**init__() got an unexpected keyword
 argument 'format')

 On Thursday, 29 November 2012 02:08:58 UTC, Massimo Di Pierro wrote:

 The problem is that it cannot assign the default validator unless the
 table is defined. You can do

 db.define_table('t_project',
 Field('f_name', type='string',
   label=T('Name')),
 Field('f_parent_project', type='reference t_project',
   label=T('Parent Project')),
 
 format='%(f_name)s',
 migrate=settings.migrate)

 db.t_project.f_name.requires = 
 IS_EMPTY_OR(IS_IN_DB(db,'t_**project.idhttp://t_project.id
 ',format=db.t_**project._format))

 The last line will restore the dropdown.


 On Wednesday, 28 November 2012 14:39:14 UTC-6, Jim S wrote:

 I'm seeing this as well.

 -Jim


 On Tuesday, November 27, 2012 12:09:18 PM UTC-6, Luc Chase wrote:

 If the reference is to a different table, the CRUD form renders the
 field as a list box allowing the user to select the record from the 
 foreign
 table.  But as a self-join the CRUD form renders the field as a simple 
 text
 box and it seems to create a default value of 0 when saved. Then, I think
 that causes the record to generate an error when viewed ( but not when
 edited).


 I can post the entire models file if that would help.

  --





-- 





Re: [web2py] Re: Self-joins not working.

2012-11-30 Thread Massimo Di Pierro
Can you check trunk? I just submitted a patch that should have fixed this 
problem. The price: slower table initilization but perhaps negligible.

On Friday, November 30, 2012 8:51:06 AM UTC-6, Richard wrote:

 I open an issue in the pass about that.

 http://code.google.com/p/web2py/issues/detail?id=382

 Richard

 On Fri, Nov 30, 2012 at 8:50 AM, Anthony abas...@gmail.com 
 javascript:wrote:

 The format argument goes in the define_table() call -- is that where you 
 have it?

 Anthony

 On Friday, November 30, 2012 1:58:09 AM UTC-5, Luc Chase wrote:

 Thanks for the suggestion.  I had tried something similar but got an 
 error and even with this I have an error referencing to the unexpected use 
 of 'format'.


 type 'exceptions.TypeError' __init__() got an unexpected keyword 
 argument 'format' VERSION web2py™ (2, 2, 1, datetime.datetime(2012, 10, 
 21, 16, 57, 4), 'stable') PythonPython 2.7: C:\Program 
 Files\Python\web2py_win\**web2py\web2py.exe TRACEBACK

 1.
 2.
 3.
 4.
 5.

 Traceback (most recent call last):
   File gluon/restricted.py, line 212, in restricted

   File C:/Program 
 Files/Python/web2py_win/**web2py/applications/Timesheet/**models/db_wizard.py
  http://127.0.0.1:8000/admin/default/edit/Timesheet/models/db_wizard.py, 
 line 40, in module
 TypeError: __init__() got an unexpected keyword argument 'format'

  ERROR SNAPSHOT [image: help]

 type 'exceptions.TypeError'(__**init__() got an unexpected keyword 
 argument 'format')

 On Thursday, 29 November 2012 02:08:58 UTC, Massimo Di Pierro wrote:

 The problem is that it cannot assign the default validator unless the 
 table is defined. You can do

 db.define_table('t_project',
 Field('f_name', type='string',
   label=T('Name')),
 Field('f_parent_project', type='reference t_project',
   label=T('Parent Project')),
 
 format='%(f_name)s',
 migrate=settings.migrate)

 db.t_project.f_name.requires = 
 IS_EMPTY_OR(IS_IN_DB(db,'t_**project.idhttp://t_project.id
 ',format=db.t_**project._format))

 The last line will restore the dropdown.


 On Wednesday, 28 November 2012 14:39:14 UTC-6, Jim S wrote:

 I'm seeing this as well.

 -Jim


 On Tuesday, November 27, 2012 12:09:18 PM UTC-6, Luc Chase wrote:

 If the reference is to a different table, the CRUD form renders the 
 field as a list box allowing the user to select the record from the 
 foreign 
 table.  But as a self-join the CRUD form renders the field as a simple 
 text 
 box and it seems to create a default value of 0 when saved. Then, I 
 think 
 that causes the record to generate an error when viewed ( but not when 
 edited).


 I can post the entire models file if that would help.
  
  -- 
  
  
  




-- 





Re: [web2py] Re: Self-joins not working.

2012-11-30 Thread Massimo Di Pierro
Correction. Not fixed.

On Friday, November 30, 2012 9:10:30 AM UTC-6, Massimo Di Pierro wrote:

 Can you check trunk? I just submitted a patch that should have fixed this 
 problem. The price: slower table initilization but perhaps negligible.

 On Friday, November 30, 2012 8:51:06 AM UTC-6, Richard wrote:

 I open an issue in the pass about that.

 http://code.google.com/p/web2py/issues/detail?id=382

 Richard

 On Fri, Nov 30, 2012 at 8:50 AM, Anthony abas...@gmail.com wrote:

 The format argument goes in the define_table() call -- is that where you 
 have it?

 Anthony

 On Friday, November 30, 2012 1:58:09 AM UTC-5, Luc Chase wrote:

 Thanks for the suggestion.  I had tried something similar but got an 
 error and even with this I have an error referencing to the unexpected use 
 of 'format'.


 type 'exceptions.TypeError' __init__() got an unexpected keyword 
 argument 'format' VERSION web2py™ (2, 2, 1, datetime.datetime(2012, 
 10, 21, 16, 57, 4), 'stable') PythonPython 2.7: C:\Program 
 Files\Python\web2py_win\**web2py\web2py.exe TRACEBACK

 1.
 2.
 3.
 4.
 5.

 Traceback (most recent call last):
   File gluon/restricted.py, line 212, in restricted

   File C:/Program 
 Files/Python/web2py_win/**web2py/applications/Timesheet/**models/db_wizard.py
  http://127.0.0.1:8000/admin/default/edit/Timesheet/models/db_wizard.py, 
 line 40, in module
 TypeError: __init__() got an unexpected keyword argument 'format'

  ERROR SNAPSHOT [image: help]

 type 'exceptions.TypeError'(__**init__() got an unexpected keyword 
 argument 'format')

 On Thursday, 29 November 2012 02:08:58 UTC, Massimo Di Pierro wrote:

 The problem is that it cannot assign the default validator unless the 
 table is defined. You can do

 db.define_table('t_project',
 Field('f_name', type='string',
   label=T('Name')),
 Field('f_parent_project', type='reference t_project',
   label=T('Parent Project')),
 
 format='%(f_name)s',
 migrate=settings.migrate)

 db.t_project.f_name.requires = 
 IS_EMPTY_OR(IS_IN_DB(db,'t_**project.idhttp://t_project.id
 ',format=db.t_**project._format))

 The last line will restore the dropdown.


 On Wednesday, 28 November 2012 14:39:14 UTC-6, Jim S wrote:

 I'm seeing this as well.

 -Jim


 On Tuesday, November 27, 2012 12:09:18 PM UTC-6, Luc Chase wrote:

 If the reference is to a different table, the CRUD form renders the 
 field as a list box allowing the user to select the record from the 
 foreign 
 table.  But as a self-join the CRUD form renders the field as a simple 
 text 
 box and it seems to create a default value of 0 when saved. Then, I 
 think 
 that causes the record to generate an error when viewed ( but not when 
 edited).


 I can post the entire models file if that would help.
  
  -- 
  
  
  




-- 





Re: [web2py] Re: Self-joins not working.

2012-11-30 Thread Richard Vézina
Ask again when you are ready I have little app dedicated to check for this
issue.

Richard

On Fri, Nov 30, 2012 at 10:10 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 Correction. Not fixed.


 On Friday, November 30, 2012 9:10:30 AM UTC-6, Massimo Di Pierro wrote:

 Can you check trunk? I just submitted a patch that should have fixed this
 problem. The price: slower table initilization but perhaps negligible.

 On Friday, November 30, 2012 8:51:06 AM UTC-6, Richard wrote:

 I open an issue in the pass about that.

 http://code.google.com/p/**web2py/issues/detail?id=382http://code.google.com/p/web2py/issues/detail?id=382

 Richard

 On Fri, Nov 30, 2012 at 8:50 AM, Anthony abas...@gmail.com wrote:

 The format argument goes in the define_table() call -- is that where
 you have it?

 Anthony

 On Friday, November 30, 2012 1:58:09 AM UTC-5, Luc Chase wrote:

 Thanks for the suggestion.  I had tried something similar but got an
 error and even with this I have an error referencing to the unexpected use
 of 'format'.


 type 'exceptions.TypeError' __init__() got an unexpected keyword
 argument 'format' VERSION web2py™ (2, 2, 1, datetime.datetime(2012,
 10, 21, 16, 57, 4), 'stable') PythonPython 2.7: C:\Program
 Files\Python\web2py_win\**web2py**\web2py.exe TRACEBACK

 1.
 2.
 3.
 4.
 5.

 Traceback (most recent call last):
   File gluon/restricted.py, line 212, in restricted

   File C:/Program 
 Files/Python/web2py_win/**web2py**/applications/Timesheet/**models**/db_wizard.py
  
 http://127.0.0.1:8000/admin/default/edit/Timesheet/models/db_wizard.py, 
 line 40, in module
 TypeError: __init__() got an unexpected keyword argument 'format'

  ERROR SNAPSHOT [image: help]

 type 'exceptions.TypeError'(__**init**__() got an unexpected
 keyword argument 'format')

 On Thursday, 29 November 2012 02:08:58 UTC, Massimo Di Pierro wrote:

 The problem is that it cannot assign the default validator unless the
 table is defined. You can do

 db.define_table('t_project',
 Field('f_name', type='string',
   label=T('Name')),
 Field('f_parent_project', type='reference t_project',
   label=T('Parent Project')),
 
 format='%(f_name)s',
 migrate=settings.migrate)

 db.t_project.f_name.requires = IS_EMPTY_OR(IS_IN_DB(db,'t_**pro**
 ject.id http://t_project.id',format=db.t_**project._**format))

 The last line will restore the dropdown.


 On Wednesday, 28 November 2012 14:39:14 UTC-6, Jim S wrote:

 I'm seeing this as well.

 -Jim


 On Tuesday, November 27, 2012 12:09:18 PM UTC-6, Luc Chase wrote:

 If the reference is to a different table, the CRUD form renders the
 field as a list box allowing the user to select the record from the 
 foreign
 table.  But as a self-join the CRUD form renders the field as a simple 
 text
 box and it seems to create a default value of 0 when saved. Then, I 
 think
 that causes the record to generate an error when viewed ( but not when
 edited).


 I can post the entire models file if that would help.

  --





  --





-- 





Re: [web2py] Re: Self-joins not working.

2012-11-30 Thread Luc Chase

db.define_table('t_project',
Field('f_name', type='string',
  label=T('Name')),
Field('f_parent_project', type='reference t_project',
  label=T('Parent Project')),
Field('f_description', type='string',
  label=T('Description')),
Field('f_start_on', type='date',
  label=T('Start On')),
Field('f_colour', type='string',
  label=T('Colour')),
Field('f_company_code', type='text',
  label=T('Company Code')),
Field('f_status', type='boolean',
  label=T('Status')),
auth.signature,
format='%(f_name)s',
migrate=settings.migrate)

db.t_project.f_name.requires = IS_EMPTY_OR(IS_IN_DB(db,'t_project.id',format
=db.t_project._format))

db.define_table('t_project_archive',db.t_project,Field('current_record','reference
 
t_project',readable=False,writable=False))




On Friday, 30 November 2012 13:50:34 UTC, Anthony wrote:

 The format argument goes in the define_table() call -- is that where you 
 have it?

 Anthony

 On Friday, November 30, 2012 1:58:09 AM UTC-5, Luc Chase wrote:

 Thanks for the suggestion.  I had tried something similar but got an 
 error and even with this I have an error referencing to the unexpected use 
 of 'format'.

 type 'exceptions.TypeError' __init__() got an unexpected keyword 
 argument 'format'VERSIONweb2py™(2, 2, 1, datetime.datetime(2012, 10, 21, 
 16, 57, 4), 'stable')PythonPython 2.7: C:\Program 
 Files\Python\web2py_win\web2py\web2py.exeTRACEBACK

 1.
 2.
 3.
 4.
 5.

 Traceback (most recent call last):
   File gluon/restricted.py, line 212, in restricted
   File C:/Program 
 Files/Python/web2py_win/web2py/applications/Timesheet/models/db_wizard.py 
 http://127.0.0.1:8000/admin/default/edit/Timesheet/models/db_wizard.py, 
 line 40, in module
 TypeError: __init__() got an unexpected keyword argument 'format'

 ERROR SNAPSHOT [image: help]

 type 'exceptions.TypeError'(__init__() got an unexpected keyword 
 argument 'format')

 On Thursday, 29 November 2012 02:08:58 UTC, Massimo Di Pierro wrote:

 The problem is that it cannot assign the default validator unless the 
 table is defined. You can do

 db.define_table('t_project',
 Field('f_name', type='string',
   label=T('Name')),
 Field('f_parent_project', type='reference t_project',
   label=T('Parent Project')),
 
 format='%(f_name)s',
 migrate=settings.migrate)

 db.t_project.f_name.requires = IS_EMPTY_OR(IS_IN_DB(db,'t_project.id
 ',format=db.t_project._format))

 The last line will restore the dropdown.


 On Wednesday, 28 November 2012 14:39:14 UTC-6, Jim S wrote:

 I'm seeing this as well.

 -Jim


 On Tuesday, November 27, 2012 12:09:18 PM UTC-6, Luc Chase wrote:

 If the reference is to a different table, the CRUD form renders the 
 field as a list box allowing the user to select the record from the 
 foreign 
 table.  But as a self-join the CRUD form renders the field as a simple 
 text 
 box and it seems to create a default value of 0 when saved. Then, I think 
 that causes the record to generate an error when viewed ( but not when 
 edited).


 I can post the entire models file if that would help.
  


-- 





Re: [web2py] Re: Self-joins not working.

2012-11-29 Thread Luc Chase
Thanks for the suggestion.  I had tried something similar but got an error 
and even with this I have an referrering to the unexpected use of 'format'.

type 'exceptions.TypeError' __init__() got an unexpected keyword argument 
'format'VERSIONweb2py™(2, 2, 1, datetime.datetime(2012, 10, 21, 16, 57, 4), 
'stable')PythonPython 2.7: C:\Program 
Files\Python\web2py_win\web2py\web2py.exeTRACEBACK

1.
2.
3.
4.
5.

Traceback (most recent call last):
  File gluon/restricted.py, line 212, in restricted
  File C:/Program 
Files/Python/web2py_win/web2py/applications/Timesheet/models/db_wizard.py 
http://127.0.0.1:8000/admin/default/edit/Timesheet/models/db_wizard.py, line 
40, in module
TypeError: __init__() got an unexpected keyword argument 'format'

ERROR SNAPSHOT [image: help]

type 'exceptions.TypeError'(__init__() got an unexpected keyword argument 
'format')

On Thursday, 29 November 2012 02:08:58 UTC, Massimo Di Pierro wrote:

 The problem is that it cannot assign the default validator unless the 
 table is defined. You can do

 db.define_table('t_project',
 Field('f_name', type='string',
   label=T('Name')),
 Field('f_parent_project', type='reference t_project',
   label=T('Parent Project')),
 
 format='%(f_name)s',
 migrate=settings.migrate)

 db.t_project.f_name.requires = IS_EMPTY_OR(IS_IN_DB(db,'t_project.id
 ',format=db.t_project._format))

 The last line will restore the dropdown.


 On Wednesday, 28 November 2012 14:39:14 UTC-6, Jim S wrote:

 I'm seeing this as well.

 -Jim


 On Tuesday, November 27, 2012 12:09:18 PM UTC-6, Luc Chase wrote:

 If the reference is to a different table, the CRUD form renders the 
 field as a list box allowing the user to select the record from the foreign 
 table.  But as a self-join the CRUD form renders the field as a simple text 
 box and it seems to create a default value of 0 when saved. Then, I think 
 that causes the record to generate an error when viewed ( but not when 
 edited).


 I can post the entire models file if that would help.
  


-- 





Re: [web2py] Re: Self-joins not working.

2012-11-28 Thread Jim S
I'm seeing this as well.

-Jim


On Tuesday, November 27, 2012 12:09:18 PM UTC-6, Luc Chase wrote:

 If the reference is to a different table, the CRUD form renders the field 
 as a list box allowing the user to select the record from the foreign 
 table.  But as a self-join the CRUD form renders the field as a simple text 
 box and it seems to create a default value of 0 when saved. Then, I think 
 that causes the record to generate an error when viewed ( but not when 
 edited).


 I can post the entire models file if that would help.
  

-- 





Re: [web2py] Re: Self-joins not working.

2012-11-28 Thread Massimo Di Pierro
The problem is that it cannot assign the default validator unless the table 
is defined. You can do

db.define_table('t_project',
Field('f_name', type='string',
  label=T('Name')),
Field('f_parent_project', type='reference t_project',
  label=T('Parent Project')),

format='%(f_name)s',
migrate=settings.migrate)

db.t_project.f_name.requires = 
IS_EMPTY_OR(IS_IN_DB(db,'t_project.id',format=db.t_project._format))

The last line will restore the dropdown.


On Wednesday, 28 November 2012 14:39:14 UTC-6, Jim S wrote:

 I'm seeing this as well.

 -Jim


 On Tuesday, November 27, 2012 12:09:18 PM UTC-6, Luc Chase wrote:

 If the reference is to a different table, the CRUD form renders the field 
 as a list box allowing the user to select the record from the foreign 
 table.  But as a self-join the CRUD form renders the field as a simple text 
 box and it seems to create a default value of 0 when saved. Then, I think 
 that causes the record to generate an error when viewed ( but not when 
 edited).


 I can post the entire models file if that would help.
  


-- 





[web2py] Re: Self-joins not working.

2012-11-27 Thread Massimo Di Pierro
In which way this is not working correctly?

On Monday, 26 November 2012 12:45:22 UTC-6, Luc Chase wrote:

 The documentation at 

 http://web2py.com/books/default/chapter/29/06?search=reference#Self-Reference-and-aliases
 says that this should be possible. 

 However my models code in db_wizard.py which I've partially edited just 
 for this requirement does not generate the correct CRUD form ( a lookup 
 list-box).  What do I need to change to make this work correctly?

 Here is my models code...
 db.define_table('t_project',
 Field('f_name', type='string',
   label=T('Name')),
 Field('f_parent_project', type='reference t_project',
   label=T('Parent Project')),
 Field('f_description', type='string',
   label=T('Description')),
 Field('f_start_on', type='date',
   label=T('Start On')),
 Field('f_colour', type='string',
   label=T('Colour')),
 Field('f_company_code', type='text',
   label=T('Company Code')),
 Field('f_status', type='boolean',
   label=T('Status')),
 auth.signature,
 format='%(f_name)s',
 migrate=settings.migrate)


-- 





Re: [web2py] Re: Self-joins not working.

2012-11-27 Thread Luc Chase
If the reference is to a different table, the CRUD renders the field as a
list box allowing the user to select the record in the foreign table.  But
as a self-join the CRUD renders the field as a simple text box and it seems
to create a default value of 0 when saved. Then, I think that causes the
record to generate an error when viewed ( but not when edited).


On 27 November 2012 14:23, Massimo Di Pierro massimo.dipie...@gmail.comwrote:

 In which way this is not working correctly?


 On Monday, 26 November 2012 12:45:22 UTC-6, Luc Chase wrote:

 The documentation at
 http://web2py.com/books/**default/chapter/29/06?search=**
 reference#Self-Reference-and-**aliaseshttp://web2py.com/books/default/chapter/29/06?search=reference#Self-Reference-and-aliases
 says that this should be possible.

 However my models code in db_wizard.py which I've partially edited just
 for this requirement does not generate the correct CRUD form ( a lookup
 list-box).  What do I need to change to make this work correctly?

 Here is my models code...
 db.define_table('t_project',
 Field('f_name', type='string',
   label=T('Name')),
 Field('f_parent_project', type='reference t_project',
   label=T('Parent Project')),
 Field('f_description', type='string',
   label=T('Description')),
 Field('f_start_on', type='date',
   label=T('Start On')),
 Field('f_colour', type='string',
   label=T('Colour')),
 Field('f_company_code', type='text',
   label=T('Company Code')),
 Field('f_status', type='boolean',
   label=T('Status')),
 auth.signature,
 format='%(f_name)s',
 migrate=settings.migrate)

  --







-- 
Luc.
M. +44.7040-901-582

--