{ "info": { "author": "Eduardo Diaz", "author_email": "iamedu at gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Framework :: ZODB", "Framework :: Zope3", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License (GPL)", "Operating System :: POSIX :: Linux", "Programming Language :: Python" ], "description": "collective.zfile\n================\n\ncollective.zfile is a package for ZODB that allows you to manage files in a distributed\nway, using multiple storages.\n\nIt is still under development\n\nIt's main features are the following:\n\n * `Multiple storage management`_ The idea is to support a large amount of large files, so it is possible to manage multiple file storages.\n * `Revision control`_ Using zc.vault it supports revisions, similar to SCM system, revisions are seen as transactions, each transaction you make will end up as a revision in the file system.\n * `Lock support`_ Is is possible to lock files and folders in two ways: exclusive locks and shared locks, you can ask for any of this types of locks on any file, in a directory it can be recursive.\n * `Multiple mount points`_ You can mount a zfolder in multiple ZODB mount points, using zc.mountpoint.using zc.mountpoint.\n\nUsage:\n\nIn order to use collective.zfile there are four main objects to interact with:\n\n * ZStorageManager\n * ZBase\n * ZFile\n\n>>> from collective.zfile import ZStorageManager, ZBase\n>>> import transaction\n\nYou can create a storage this way\n\n.. _`Multiple storage management`:\n\n>>> storage = ZStorageManager()\n>>> storage.add_storage('test_storage')\n>>> app['storage'] = storage\n\n.. _`Revision control`:\n\nOnce you have at least one physical storage you can create a base, a base is similar to a complete filesystem.\n\n>>> base = ZBase(storage)\n\nIt needs a connection to database so we save it AND commit.\n\n>>> app['base'] = base\n>>> transaction.commit()\n\nWe are ready to go, we can now create a new ZRevision and use get our root folder\n\n>>> revision = base.new_revision()\n>>> root = revision.root\n\nNow we are good to go! we can keep working with this revision or just save it.\n\nLet's just save it for now\n\n>>> revision.save_revision()\n\nLet's add a subdirectory called test\n\n>>> test = root.newdir('test')\nTraceback (most recent call last):\n...\nFrozenError\n\nOops!! Error #1, we cannot modify anything after saving a revision.\n\nLets try again\n\n>>> revision = base.new_revision()\n>>> root = revision.root\n\nRemember always to get the new root object when creating a revision\n\n>>> test = root.newdir('test')\n\nNewdir gives us a reference to the new created dir, but we could also do:\n\n>>> test = root['test']\n>>> test1 = test.newdir('test1')\n\nAnd we can work with files as well\n\n\n>>> file = test1.newfile(\"test.txt\")\n>>> f = file.open(\"w\")\n>>> f.write('Hello world')\n>>> f.close()\n\nAnd we can check it is ok!\n\n>>> file.mimetype()\n'text/plain'\n>>> f = file.open('r')\n>>> f.read()\n'Hello world'\n>>> f.close()\n\nLet's try all the process at once.\n\n>>> html = test1.newfile(\"index.html\")\n>>> f = html.open(\"w\")\n>>> f.write(\"TestHello Test\")\n>>> f.close()\n\n>>> html.mimetype()\n'text/html'\n\n>>> new_file = file.renew()\n>>> f = new_file.open('a')\n>>> f.write('\\nHello newline')\n>>> f.close()\n\n>>> f = new_file.open('r')\n>>> f.read()\n'Hello world\\nHello newline'\n>>> f.close()\n\n>>> revision.save_revision()\n>>> transaction.commit()\n\n.. _`Lock support`:\n\n**TODO**: Lock doctests\n\n.. _`Multiple mount points`:\n\n**TODO**: Implement mountpoints", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://ediaz.me", "keywords": "zfile collective", "license": "GPL", "maintainer": "", "maintainer_email": "", "name": "collective.zfile", "package_url": "https://pypi.org/project/collective.zfile/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/collective.zfile/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://ediaz.me" }, "release_url": "https://pypi.org/project/collective.zfile/0.0dev/", "requires_dist": null, "requires_python": null, "summary": "Collective files", "version": "0.0dev" }, "last_serial": 206635, "releases": { "0.0dev": [] }, "urls": [] }