don't always import sql

This commit is contained in:
Thomas NOËL 2012-08-29 11:44:24 +02:00
parent c2f220677b
commit cbcc055e86
1 changed files with 2 additions and 1 deletions

View File

@ -49,7 +49,6 @@ from wcs.workflows import Workflow, CommentableWorkflowStatusItem, \
SendmailWorkflowStatusItem, ChoiceWorkflowStatusItem, \
template_on_formdata
import fields
import sql
class FormField:
### only used to unpickle form fields from older (<200603) versions
@ -144,6 +143,7 @@ class FormDef(StorableObject):
if hasattr(sys.modules['formdef'], self.url_name.title()):
return getattr(sys.modules['formdef'], self.url_name.title())
if get_publisher().has_site_option('postgresql') and get_cfg('postgresql', {}):
import sql
table_name = 'formdata_' + self.url_name.replace('-', '_')
cls = new.classobj(self.url_name.title(), (sql.SqlFormData,),
{'_formdef': self,
@ -160,6 +160,7 @@ class FormDef(StorableObject):
if not self.url_name:
self.url_name = new_url_name
if get_publisher().has_site_option('postgresql') and get_cfg('postgresql', {}):
import sql
sql.do_formdef_tables(self)
elif new_url_name != self.url_name:
# title changed, url will be changed only if there are not yet any