user = StringField('User:')
password = PasswordField('Password:')
- ivals = UserInitialPost
-
class AuthWTForm(UserWTForm):
'''The wtform used to connect to any db and authenticate.'''
# just to keep my hand in.
db = StringField('Database:')
- ivals = UserInitialPost
-
class UploadFileWTForm(AuthWTForm):
'''The wtform used for uploading files.'''
trim_upload = BooleanField('Trim Leading/Trailing Spaces:')
literal_col_headings = BooleanField('Literal Uploaded Column Headings:')
- ivals = UploadFileInitialPost
-
class UploadNullFileWTForm(UploadFileWTForm):
'''The wtform used for uploading files that may contain NULL.'''
upload_null = BooleanField('Upload NULL Values:')
null_rep = StringField('NULL Representation:')
- ivals = UploadNullFileInitialPost
-
class UploadTableWTForm(UploadNullFileWTForm):
'''The wtform used for uploading arbitrary data into tables.'''
table = StringField('Table or View:')
- ivals = UploadTableInitialPost
-
@attr.s
class LoadedForm(collections.abc.MutableMapping):
_form Instantaiated html form object (WTForms)
_fc Class handling html form
'''
+ fc_default = attr.ib(default=None)
+ ip_default = attr.ib(default=None)
uh = attr.ib(default=None)
_store = attr.ib(factory=dict)
_fc = attr.ib(default=None)
_form = attr.ib(default=None)
ivals = attr.ib(default=None)
- def build(self, uh, fc=None, data={}, **kwargs):
+ def build(self, uh, fc=None, ip=None, data={}, **kwargs):
'''Form initialization
+ ip is the instantiated initial post
'''
self.uh = uh
if data == {}:
store = dict(data)
store.update(kwargs)
self._store = store
- self._fc = fc
- self.ivals = fc.ivals().build(self.uh.request.registry.settings)
+ self._fc = (self.fc_default if fc is None else fc)
+ ip_used = (self.ip_default if ip is None else ip)
+ self.ivals = ip_used.build(self.uh.request.registry.settings)
return self
def __iter__(self):
Methods:
read() Load form from pyramid request object.
'''
+ fc_default = attr.ib(default=UserWTForm)
+ ip_default = attr.ib(factory=UserInitialPost)
user = attr.ib(default=None)
password = attr.ib(default=None)
action = attr.ib(default=None)
- def build(self, uh, fc=UserWTForm, data={}, **kwargs):
- return super().build(uh, fc, data, **kwargs)
-
def session_put(self, key, value):
'''
Put data into the session.
Methods:
read() Load form from pyramid request object.
'''
+ fc_default = attr.ib(default=UploadFileWTForm)
+ ip_default = attr.ib(factory=UploadFileInitialPost)
upload_fmt = attr.ib(default=None)
trim_upload = attr.ib(default=None)
literal_col_headings = attr.ib(default=None)
filename = attr.ib(default=None)
localfh = attr.ib(default=None)
- def build(self, uh, fc=UploadFileWTForm, data={}, **kwargs):
- return super().build(uh, fc, data, **kwargs)
-
def read(self):
'''
Read form data from the client
Methods:
read() Load form from pyramid request object.
'''
- def build(self, uh, fc=UploadTableWTForm, data={}, **kwargs):
- return super().build(uh, fc, data, **kwargs)
+ fc_default = attr.ib(default=UploadTableWTForm)
+ ip_default = attr.ib(factory=UploadTableInitialPost)
def read(self):
'''