Logo Search packages:      
Sourcecode: zope-atcontenttypes version File versions

def zope-atcontenttypes-0.2-rc3::types::ATContentType::ATCTFileContent::post_validate (   self,
  REQUEST = None,
  errors = None 
)

Validates upload file and id

Definition at line 344 of file ATContentType.py.

00344                                                       :
        """Validates upload file and id
        """
        id     = REQUEST.form.get('id')
        parent = aq_parent(self)
        parent_ids = parent.objectIds()
        field  = self.getPrimaryField()
        f_name = field.getName()
        upload = REQUEST.form.get('%s_file' % f_name, None)
        filename = getattr(upload, 'filename', None)
        clean_filename = cleanupFilename(filename)

        if upload:
            # the file may have already been read by a
            # former method
            upload.seek(0)

        if not id and clean_filename == self.getId():
            # already renamed - ok
            return
        elif id == self.getId():
            # id available and already renamed
            return
        elif id and id not in parent_ids:
            # id available and id not used
            return
        elif clean_filename in parent_ids or id in parent_ids:
            # failure
            used_id = id and id or clean_filename
            errors[f_name] = 'You have to upload the file again'
            errors['id'] = 'Id %s is already in use' % used_id
            REQUEST.form['id'] = used_id
        else:
            # everything ok
            pass

InitializeClass(ATCTFileContent)


class ATCTFolder(ATCTMixin, BaseFolder):


Generated by  Doxygen 1.6.0   Back to index