Пример #1
0
    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)
Пример #2
0
    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)
Пример #3
0
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
Пример #4
0
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
Пример #5
0
 def __init__(self):
     AbstractController.__init__(self)
     self._form = AddSignForm()
Пример #6
0
 def __init__(self):
     AbstractController.__init__(self)
     self._form = AddSignForm()