def check_some_attributes(values): """check, fix up attributes.""" logging.debug('check_some_attributes: ' + repr(values)) # must have a creator if not values.has_key('creator'): ryw.give_bad_news( 'user_error: check_some_attributes: creator not specified', logging.critical) return False # must have kB field if not values.has_key('kB'): ryw.give_bad_news( 'fatal_error: check_some_attributes: size (kB) not found', logging.critical) return False # get object id if not values.has_key('id'): values['id'] = objectstore.generateNewObjectID() logging.debug('check_some_attributes: passed.') return True
def process_tricky_attributes(form, meta, filename): """hidden and obscure attributes.""" meta['upload_datetime'] = repr(datetime.datetime.now()) meta['upload_datetime_real'] = repr(datetime.datetime.now()) #meta['upload_datetime'] = datetime.datetime.now() logging.debug('process_tricky_attributes: ' + repr(meta['upload_datetime'])) if not process_date_time(form, meta): return False objectID = form.getfirst('object_ID', '') if not objectID: try: objectID = objectstore.generateNewObjectID() except: ryw.give_bad_news('fatal_error: unable to obtain new object ID.', logging.critical) return False meta['id'] = objectID path = form.getfirst('path', '') if not path: contentType = form.getfirst('content_type', '') if not contentType: ryw.give_bad_news('fatal_error: unable to determine content type.', logging.critical) return False now = datetime.datetime.now() monthStr = now.strftime('%y%m/') dateTimeRand = ryw.date_time_rand() filename = dateTimeRand + '_' + filename path = os.path.join('/upload', monthStr, contentType, filename) meta['path'] = os.path.normpath(path) ryw.db_print2('process_tricky_attributes: path is: ' + meta['path'], 57) return True