I have this code in plugin I want to use, and it gives an error when lazy 
tables = True (on trunk).
I've found a fix, but it feels wrong.
Question is really: how to force table definition for some tables when 
using lazy_tables?

Problem code:

 def define_tables(self, migrate=True, fake_migrate=False):
         
        upload_name = self.settings.table_upload_name    #this is 
'plugin_ckeditor_upload'
        
        self.settings.table_upload = self.db.define_table(upload_name,
            ... #skip some rows
            Field('upload', 'upload'),
            *self.settings.extra_fields.get(upload_name, []),
            migrate = migrate,
            fake_migrate = fake_migrate,
            format = '%(title)s'
        )


then comes the line with the error:
        self.settings.table_upload.upload.requires = [
            IS_NOT_EMPTY(),
            IS_LENGTH(maxsize=self.settings.file_length_max, minsize=self.
settings.file_length_min),
        ]

causing when lazy_tables=True

<type 'exceptions.AttributeError'> 'NoneType' object has no attribute 
'upload'

ok, so to trigger the definition of the table I tried:
a_table = self.db['plugin_ckeditor_upload']


but while this solves 
a_table.upload.requires = ... 

self.settings.table_upload is still None (which surprised me)

This works but it seems bad:
self.settings.table_upload = self.db['plugin_ckeditor_upload']

Now I have hard-coded the table name.




-- 
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/groups/opt_out.

Reply via email to