def download(self, ver, context, REQUEST):
     RESPONSE = REQUEST.RESPONSE
     action = REQUEST.form.get('action', 'download')
     if action == 'view':
         view_adapter = get_view_adapter(ver)
         if view_adapter is not None:
             return view_adapter(context)
         return ver.send_data(RESPONSE, as_attachment=False,
                              REQUEST=REQUEST)
     elif action == 'download':
         return ver.send_data(RESPONSE, set_filename=False, REQUEST=REQUEST)
     else:
         raise NotFound
示例#2
0
 def download(self, ver, context, REQUEST):
     RESPONSE = REQUEST.RESPONSE
     action = REQUEST.form.get('action', 'download')
     if action == 'view':
         view_adapter = get_view_adapter(ver)
         if view_adapter is not None:
             return view_adapter(context)
         return ver.send_data(RESPONSE, as_attachment=False,
                              REQUEST=REQUEST)
     elif action == 'download':
         return ver.send_data(RESPONSE, set_filename=False, REQUEST=REQUEST)
     else:
         raise NotFound
            raise IndexError
        language = context.get_selected_language()
        if language is None:
            language = context.get_default_lang_code()

        if (not context._versions) or (not context._versions[language]):
            raise NotFound
        ver = context._versions[language][ver_number]
        if ver.removed:
            raise IndexError
    except (IndexError, ValueError, KeyError), e:
        raise NotFound
    RESPONSE = REQUEST.RESPONSE
    action = REQUEST.form.get('action', 'download')
    if action == 'view':
        view_adapter = get_view_adapter(ver)
        if view_adapter is not None:
            return view_adapter(context)
        return ver.send_data(RESPONSE, as_attachment=False, REQUEST=REQUEST)
    elif action == 'download':
        return ver.send_data(RESPONSE, set_filename=False, REQUEST=REQUEST)
    else:
        raise NotFound

class NyLocalizedBFile(NyContentData, NyAttributes, NyItem, NyCheckControl, NyValidation, NyContentType):
    """ """
    implements(INyBFile)

    meta_type = config['meta_type']
    meta_label = config['label']
            raise IndexError
        language = context.get_selected_language()
        if language is None:
            language = context.get_default_lang_code()

        if (not context._versions) or (not context._versions[language]):
            raise NotFound
        ver = context._versions[language][ver_number]
        if ver.removed:
            raise IndexError
    except (IndexError, ValueError, KeyError), e:
        raise NotFound
    RESPONSE = REQUEST.RESPONSE
    action = REQUEST.form.get('action', 'download')
    if action == 'view':
        view_adapter = get_view_adapter(ver)
        if view_adapter is not None:
            return view_adapter(context)
        return ver.send_data(RESPONSE, as_attachment=False, REQUEST=REQUEST)
    elif action == 'download':
        return ver.send_data(RESPONSE, set_filename=False, REQUEST=REQUEST)
    else:
        raise NotFound


class NyLocalizedBFile(NyContentData, NyAttributes, NyItem, NyCheckControl,
                       NyValidation, NyContentType):
    """ """
    implements(INyBFile)

    meta_type = config['meta_type']