Just started with web2py... great framework.

I tried and failed however to find an answer to why two validators seem to 
validate differently in terms of checking the syntax of parameters.

I do the following:

tableNames = ['taxaTS', 'taxaPF']

for tableName in tableNames:
    # Create the taxa table
    db.define_table(tableName,
                    Field('name' , unique=True, length=512, 
comment='*Required'),
                    Field('root_Path','list:string', default=['root'], 
length=5200, compute=computers.calcRootPath()),
                    Field('is_Leaf','boolean',default=False),
                    Field('parent',length=512,default='root', 
comment='*Required'),
                    Field('note','text'),
                    Field('link_Paths','list:string',default=[]),
                    auth.signature)

    ## Field and Table Form Rules
    # name
    db[tableName].name.requires = IS_NOT_EMPTY()
line 40    db[tableName].name.requires = IS_NOT_IN_DB(db, '[tableName].name')   
 # Name is unique

    # parent
    db[tableName].parent.requires = IS_NOT_EMPTY()
line 44    db[tableName].parent.requires = IS_IN_DB(db, '[tableName].name')     
 # Parent name must exist in table already




When the above code executes, I get the following error:

<type 'exceptions.AttributeError'> 'DAL' object has no attribute 
'[tableName]'Version
web2py™ Version 2.14.3-stable+timestamp.2016.03.26.23.02.02
Python Python 2.7.3: C:\Python27\python.exe (prefix: C:\Python27)Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.

Traceback (most recent call last):
  File "C:\Users\User\PycharmProjects\bladeCloud\web2py\gluon\restricted.py", 
line 227, in restricted
    exec ccode in environment
  File 
"C:/Users/User/PycharmProjects/bladeCloud/web2py/applications/bc/models/db_bc_kb.py"
 <http://127.0.0.1:8000/admin/default/edit/bc/models/db_bc_kb.py>, line 44, in 
<module>
    db[tableName].parent.requires = IS_IN_DB(db, '[tableName].name')      # 
Parent name must exist in table already
  File "C:\Users\User\PycharmProjects\bladeCloud\web2py\gluon\validators.py", 
line 529, in __init__
    field = self.dbset.db[items[0]][items[1]]
  File 
"C:\Users\User\PycharmProjects\bladeCloud\web2py\gluon\packages\dal\pydal\base.py",
 line 914, in __getitem__
    return self.__getattr__(str(key))
  File 
"C:\Users\User\PycharmProjects\bladeCloud\web2py\gluon\packages\dal\pydal\base.py",
 line 921, in __getattr__
    return BasicStorage.__getattribute__(self, key)
AttributeError: 'DAL' object has no attribute '[tableName]'


It doesn't like line 44 but is ok with line 40.   

Can someone help?
Thanks...Norm    (really new at this)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to