Exemple #1
0
            # process uploaded file first; if not there, then check for inline
            # XML being pasted in
            if isinstance(licenseFile,
                          cgi.FieldStorage) and licenseFile.filename:

                logger.info('processing incoming license to add: %s' %
                            licenseFile.filename)

                # pull license into stringbuffer
                license_contents = []
                for i in range(32):
                    license_contents.append(licenseFile.file.read(8192))

                license_object = License(name=licenseFile.filename,
                                         namespace=None,
                                         owner=None)
                license_object.payload = ''.join(license_contents)

                # check for clear text; fake a new exception to notify user
                try:
                    unicode(license_object.payload, 'utf-8')
                except Exception, e:
                    template_args['controller_exception'] = ValueError(
                        'Invalid license file submitted')
                    license_object = None

            elif formset_pasted_license:
                license_object = License(name=('web_%s.lic' % time.time()),
                                         namespace=None,
                                         owner=None)