self.cur.execute(sql, (table, schema))
return self.cur.fetchone() is not None
- def quote_columns(self):
+ def quote_columns(self, settings):
'''Return boolean -- whether to take column names literally
'''
- settings = self.request.registry.settings
- quoter_setting = settings['pgwui'].get('literal_column_headings')
+ quoter_setting = settings.get('literal_column_headings')
if quoter_setting == 'on':
return True
elif quoter_setting == 'ask':
request.registry.settings = settings
uh = neuter_tableuploadhandler(uploadform, DummyRequest())
- return uh.quote_columns()
+ return uh.quote_columns(settings)
return run
True
'''
result = get_quote_columns(UPLOAD_FORM_W_LIT_CHECKED,
- {'pgwui': {'literal_column_headings': 'on'}})
+ {'literal_column_headings': 'on'})
assert result is True
False
'''
result = get_quote_columns(UPLOAD_FORM_W_LIT_CHECKED,
- {'pgwui': {'literal_column_headings': 'off'}})
+ {'literal_column_headings': 'off'})
assert result is False
'''When the settings literal_column_headings is not present return
False (as default)
'''
- result = get_quote_columns(UPLOAD_FORM_W_LIT_CHECKED, {'pgwui': {}})
+ result = get_quote_columns(UPLOAD_FORM_W_LIT_CHECKED, {})
assert result is False
'''When the form asks for literal column headings return True
'''
result = get_quote_columns(UPLOAD_FORM_W_LIT_CHECKED,
- {'pgwui': {'literal_column_headings': 'ask'}})
+ {'literal_column_headings': 'ask'})
assert result is True
'''When the form does not ask for literal column headings return False
'''
result = get_quote_columns({'literal_col_headings': False},
- {'pgwui': {'literal_column_headings': 'ask'}})
+ {'literal_column_headings': 'ask'})
assert result is False