Metadata-Version: 2.1
Name: cone.fileupload
Version: 0.4
Summary: jQuery File Upload integration for cone.app
Home-page: https://github.com/bluedynamics/cone.fileuplaod
Author: BlueDynamics Alliance
Author-email: dev@bluedynamics.com
License: Simplified BSD
Description: .. image:: https://img.shields.io/pypi/v/cone.fileupload.svg
            :target: https://pypi.python.org/pypi/cone.fileupload
            :alt: Latest PyPI version
        
        .. image:: https://img.shields.io/pypi/dm/cone.fileupload.svg
            :target: https://pypi.python.org/pypi/cone.fileupload
            :alt: Number of PyPI downloads
        
        .. image:: https://travis-ci.org/bluedynamics/cone.fileupload.svg?branch=master
            :target: https://travis-ci.org/bluedynamics/cone.fileupload
        
        .. image:: https://coveralls.io/repos/github/bluedynamics/cone.fileupload/badge.svg?branch=master
            :target: https://coveralls.io/github/bluedynamics/cone.fileupload?branch=master
        
        
        cone.fileupload
        ===============
        
        This package integrates jQuery File Upload
        (https://github.com/blueimp/jQuery-File-Upload/) in cone.
        
        Currently, tag 9.9.3 is included. See
        (https://github.com/blueimp/jQuery-File-Upload/releases).
        
        
        Usage
        -----
        
        Since ``cone.app`` not knows about the underlying data, ``cone.fileupload``
        only provides an abstract server implementation.
        
        So first we need to provide a model.
        
        .. code-block:: python
        
            from pyramid.security import (
                Everyone,
                Allow,
                Deny,
                ALL_PERMISSIONS,
            )
            from cone.app.model import BaseNode
        
            # define an ACL
            ACL = [
                (Allow, 'role:manager', ['add', 'delete']),
                (Allow, Everyone, ['login']),
                (Deny, Everyone, ALL_PERMISSIONS),
            ]
        
            class Container(BaseNode):
                __acl__ = ACL
        
                def __call__(self):
                    """Persistence happens here.
                    """
        
            class File(BaseNode):
                __acl__ = ACL
                allow_non_node_childs = True # allow setting any value types
        
        Now we need to provide a concrete ``FileUploadHandle`` implementation for
        our model.
        
        .. code-block:: python
        
            from pyramid.view import view_config
            from cone.fileupload.browser.fileupload import FileUploadHandle
        
            @view_config(
                name='fileupload_handle',
                context=Container, # <- here the view gets bound to our model
                accept='application/json',
                renderer='json',
                permission='add')
            class ContainerFileUploadHandle(FileUploadHandle):
        
                def create_file(self, stream, filename, mimetype):
                    # this function gets called for persisting uploaded files
                    file = self.model[filename] = File()
                    file['body'] = stream.read()
                    return {
                        'name': filename,
                        'size': len(file['body']),
                        'url': '/{0}'.format(file.name),
                        'deleteUrl': '/{0}/filedelete_handle'.format(file.name),
                        'deleteType': 'GET',
                    }
        
                def read_existing(self):
                    # this function gets called for initial reading of existing files
                    files = list()
                    for node in self.model.values():
                        files.append({
                            'name': node.name,
                            'size': len(node['body']),
                            'url': '/{0}'.format(node.name),
                            'deleteUrl': '/{0}/filedelete_handle'.format(node.name),
                            'deleteType': 'GET',
                        })
                    return files
        
        Optionally we might want to provide a custom fileupload tile for our model.
        
        .. code-block:: python
        
            from cone.tile import tile
            from cone.fileupload.browser.fileupload import FileUploadTile
        
            @tile(
                name='fileupload',
                path='cone.fileupload:browser/fileupload.pt',
                interface=Container,
                permission='add')
            class ContainerFileUploadTile(FileUploadTile):
                accept_file_types = '/(\.|\/)(gif|jpg)$/i'
                disable_image_preview = True
                disable_video_preview = True
                disable_audio_preview = True
        
        
        Contributors
        ============
        
        - Robert Niederreiter <rnix [at] squarewave [dot] at>
        
        
        Changes
        =======
        
        0.4 (2020-05-30)
        ----------------
        
        - Initial pypi release
          [rnix]
        
        
        0.3
        ---
        
        - Python 3 compatibility.
          [rnix]
        
        - Convert doctests to unittests.
          [rnix]
        
        - Use ``cone.app.main_hook`` decorator.
          [rnix]
        
        - Move resource registration to main hook.
          [rnix]
        
        - Upgrade to ``cone.app`` 1.0b1.
          [rnix]
        
        
        0.2
        ---
        
        - Code organization.
          [rnix]
        
        
        0.1
        ---
        
        - Make it work
          [rnix]
        
        
        
        License
        =======
        
        Copyright (c) 2013-2019, BlueDynamics Alliance, Austria
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        * Redistributions of source code must retain the above copyright notice, this 
          list of conditions and the following disclaimer.
        * Redistributions in binary form must reproduce the above copyright notice, this 
          list of conditions and the following disclaimer in the documentation and/or 
          other materials provided with the distribution.
        * Neither the name of the BlueDynamics Alliance nor the names of its 
          contributors may be used to endorse or promote products derived from this 
          software without specific prior written permission.
              
        THIS SOFTWARE IS PROVIDED BY BlueDynamics Alliance ``AS IS`` AND ANY
        EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
        WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL BlueDynamics Alliance BE LIABLE FOR ANY
        DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
        (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
        LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
        ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
        SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Keywords: node pyramid cone web
Platform: UNKNOWN
Classifier: Environment :: Web Environment
Classifier: Programming Language :: Python
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Provides-Extra: test
