def _PreprocessRequest(self, request): if request.method == 'POST': self._form = AddSignForm(request.POST, request.FILES) if self._form.is_valid(): self.__ProcessVideo(request.FILES['videoFile']) self._AddToDictionary('form', self._form)
class AddVideoController(AbstractController): def __init__(self): AbstractController.__init__(self) self._form = AddSignForm() def _PreprocessRequest(self, request): if request.method == 'POST': self._form = AddSignForm(request.POST, request.FILES) if self._form.is_valid(): self.__ProcessVideo(request.FILES['videoFile']) self._AddToDictionary('form', self._form) def __ProcessVideo(self, uploaded_video): videoHandler = VideoUploadHandler(uploaded_video) if Video.UploadedAlready(videoHandler.hash()): raise RedirectingException( ViewVideoUrl(Video.GetByHash(videoHandler.hash()))) else: try: videoHandler.encodeVideo() except BadVideo: errors = self._form._errors.setdefault( "videoFile", ErrorList()) errors.append("That video could not be converted.") new_video = self._AttributeType()(videohash=\ videoHandler.hash()) new_video.save() raise RedirectingException(ViewVideoUrl(new_video)) def _AttributeType(self): raise NotImplementedError def _View(self): raise NotImplementedError
class AddVideoController(AbstractController): def __init__(self): AbstractController.__init__(self) self._form = AddSignForm() def _PreprocessRequest(self, request): if request.method == 'POST': self._form = AddSignForm(request.POST, request.FILES) if self._form.is_valid(): self.__ProcessVideo(request.FILES['videoFile']) self._AddToDictionary('form', self._form) def __ProcessVideo(self, uploaded_video): videoHandler = VideoUploadHandler(uploaded_video) if Video.UploadedAlready(videoHandler.hash()): raise RedirectingException( ViewVideoUrl(Video.GetByHash(videoHandler.hash()))) else: try: videoHandler.encodeVideo() except BadVideo: errors = self._form._errors.setdefault("videoFile", ErrorList()) errors.append("That video could not be converted.") new_video = self._AttributeType()(videohash=\ videoHandler.hash()) new_video.save() raise RedirectingException(ViewVideoUrl(new_video)) def _AttributeType(self): raise NotImplementedError def _View(self): raise NotImplementedError
def __init__(self): AbstractController.__init__(self) self._form = AddSignForm()