- class The_Form:
- __attributes = {'username':None, 'passwd':None, 'function':'default',
- 'action':None, 'authors':None, 'pub_date':None,
- 'short_desc':None, 'long_desc':None, 'title':None, 'filename':None,
- 'filename_name':None}
- __keys = __attributes.keys()
-
- def __init__(self, vals=None, extra_attrs=None):
- '''\
- init object
- has two optional parameters both dictionaries
- vals is a set of vals to put into the object and
- extra_attrs is a list of attributes with defaults that can be
- added
- '''
-
- if extra_attrs:
- for i in extra_attrs.keys():
- self.__attributes[i] = extra_attrs[i]
- self.__keys = self.__attributes.keys()
-
- if vals:
- for i in vals.keys():
- if i in self.__keys:
- self.__attributes[i] = vals[i]
- else:
- self.__invalid_item = 1
-
- def error(self):
- if self.__invalid_item:
- return 1
- else:
- return 0
-
-
- def get_values_from_form(self, form):
- for i in self.__keys:
- if form.has_key(i):
- if i == 'filename':
- # print 'content-type: text/html'
- # print
- # print 'filename:', form[i].filename
- # print form[i]
- self.__attributes['filename_name'] = form[i].filename
-
- self.__attributes[i] = form[i].value
-
- def __setattr__(self, attr, val):
- if attr in self.__keys:
- self.__attributes[attr] = val
-
-
- def __getattr__(self, attr):
- if attr in self.__keys:
- return self.__attributes[attr]