Exemplo n.º 1
0
                        os.rename(uploaded_file_path,
                                  original_user_files_absolute_path + os.sep + uploaded_file_name)
                        os.rename(icon_path + os.sep + icon_name,
                                  uploaded_file_path)
                    except InvenioWebSubmitIconCreatorError, e:
                        pass

                user_files_path += '/' + filetype + '/' + uploaded_file_name

            else:
                user_files_path = ''
                if not msg:
                    msg = 'No valid file found'

        # Send our response
        send_response(req, msg, user_files_path, callback_function)

    def _lookup(self, component, path):
        """ This handler is invoked for the dynamic URLs (for getting
        and putting attachments) Eg:
        /submit/getattachedfile/41336978/image/myfigure.png
        /submit/attachfile/41336978/image/myfigure.png
        """
        if component == 'getattachedfile' and len(path) > 2:

            uid = path[0] # uid of the submitter
            file_type = path[1] # file, image, flash or media (as
                                # defined by CKEditor)

            if file_type in ['file', 'image', 'flash', 'media']:
                file_name = '/'.join(path[2:]) # the filename
                            original_user_files_absolute_path + os.sep +
                            uploaded_file_name)
                        os.rename(icon_path + os.sep + icon_name,
                                  uploaded_file_path)
                    except InvenioWebSubmitIconCreatorError, e:
                        pass

                user_files_path += '/' + filetype + '/' + uploaded_file_name

            else:
                user_files_path = ''
                if not msg:
                    msg = 'No valid file found'

        # Send our response
        send_response(req, msg, user_files_path, callback_function)

    def _lookup(self, component, path):
        """ This handler is invoked for the dynamic URLs (for getting
        and putting attachments) Eg:
        /submit/getattachedfile/41336978/image/myfigure.png
        /submit/attachfile/41336978/image/myfigure.png
        """
        if component == 'getattachedfile' and len(path) > 2:

            uid = path[0]  # uid of the submitter
            file_type = path[1]  # file, image, flash or media (as
            # defined by CKEditor)

            if file_type in ['file', 'image', 'flash', 'media']:
                file_name = '/'.join(path[2:])  # the filename