{ "info": { "author": "Zope Corporation and Contributors", "author_email": "zope-dev@zope.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Zope3", "Intended Audience :: Developers", "License :: OSI Approved :: Zope Public License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP" ], "description": "The principal home folder subscriber lets you assign home folders to\nprincipals as you would do in any OS. This particular implementation of such a\nfeature is intended as a demo of the power of the way to handle principals\nand not as the holy grail. If you have concerns about the assumptions made in\nthis implementation (which are probably legitimate), just ignore this package\naltogether.\n\n\nDetailed Dcoumentation\n======================\n\n\n=====================\nPrincipal Home Folder\n=====================\n\nThe principal home folder subscriber lets you assign home folders to\nprincipals as you would do in any OS. This particular implementation of such a\nfeature is intended as a demo of the power of the way to handle principals\nand not as the holy grail. If you have concerns about the assumptions made in\nthis implementation (which are probably legitimate), just ignore this package\naltogether.\n\nManaging the Home Folders\n-------------------------\n\nLet's say we have a principal and we want to have a home folder for it. The\nfirst task is to create the home folder manager, which keeps track of the\nprincipal's home folders:\n\n >>> from zope.app.homefolder.homefolder import HomeFolderManager\n >>> manager = HomeFolderManager()\n\nNow the manager will not be able to do much, because it does not know where to\nlook for the principal home folders. Therefore we have to specify a folder\ncontainer:\n\n >>> from zope.container.btree import BTreeContainer\n >>> baseFolder = BTreeContainer()\n >>> manager.homeFolderBase = baseFolder\n\nNow we can assign a home folder to a principal:\n\n >>> manager.assignHomeFolder('stephan')\n\nSince we did not specify the name of the home folder, it is just the same\nas the principal id:\n\n >>> manager.assignments['stephan']\n 'stephan'\n\nSince the home folder did not exist and the `createHomeFolder` option was\nturned on, the directory was created for you:\n\n >>> 'stephan' in baseFolder\n True\n\nWhen creating the home folder, the principal also automatically receives the\n`zope.Manager` role:\n\n >>> from zope.securitypolicy.interfaces import IPrincipalRoleManager\n >>> roles = IPrincipalRoleManager(baseFolder['stephan'])\n >>> [(role, str(setting))\n ... for role, setting in roles.getRolesForPrincipal('stephan')]\n [(u'zope.Manager', 'PermissionSetting: Allow')]\n\nIf a folder already exists for the provided name, then the creation is simply\nskipped silently:\n\n >>> from zope.app.folder import Folder\n >>> baseFolder['sc3'] = Folder()\n >>> manager.assignHomeFolder('sc3')\n >>> manager.assignments['sc3']\n 'sc3'\n\nThis has the advantage that you can choose your own `IContainer`\nimplementation instead of relying on the vanilla folder.\n\nNow let's look at some derivations of the same task.\n\n 1. Sometimes you want to specify an alternative folder name:\n\n >>> manager.assignHomeFolder('jim', folderName='J1m')\n >>> manager.assignments['jim']\n 'J1m'\n >>> 'J1m' in baseFolder\n True\n\n 2. Even though folders are created by default, you can specifically turn\n that behavior off for a particular assignment:\n\n >>> manager.assignHomeFolder('dreamcatcher', create=False)\n >>> manager.assignments['dreamcatcher']\n 'dreamcatcher'\n >>> 'dreamcatcher' in baseFolder\n False\n\n 3. You wish not to create a folder by default:\n\n >>> manager.createHomeFolder = False\n >>> manager.assignHomeFolder('philiKON')\n >>> manager.assignments['philiKON']\n 'philiKON'\n >>> 'philiKON' in baseFolder\n False\n\n 4. You do not want to create a folder by default, you want to create the\n folder for a specific user:\n\n >>> manager.assignHomeFolder('stevea', create=True)\n >>> manager.assignments['stevea']\n 'stevea'\n >>> 'stevea' in baseFolder\n True\n\nLet's now look at removing home folder assignments. By default, removing an\nassignment will *not* delete the actual folder:\n\n >>> manager.unassignHomeFolder('stevea')\n >>> 'stevea' not in manager.assignments\n True\n >>> 'stevea' in baseFolder\n True\n\nBut if you specify the `delete` argument, then the folder will be deleted:\n\n >>> 'J1m' in baseFolder\n True\n >>> manager.unassignHomeFolder('jim', delete=True)\n >>> 'jim' not in manager.assignments\n True\n >>> 'J1m' in baseFolder\n False\n\nNext, let's have a look at retrieving the home folder for a principal. This\ncan be done as follows:\n\n >>> homeFolder = manager.getHomeFolder('stephan')\n >>> homeFolder is baseFolder['stephan']\n True\n\n\nIf you try to get a folder and it does not yet exist, `None` will be\nreturned if autoCreateAssignment is False. Remember 'dreamcatcher', which\nhas an assignment, but not a folder:\n\n >>> 'dreamcatcher' in baseFolder\n False\n >>> homeFolder = manager.getHomeFolder('dreamcatcher')\n >>> homeFolder is None\n True\n\nHowever, if autoCreateAssignment is True and you try to get a home folder\nof a principal which has no assignment, the assignment and the folder\nwill be automatically created. The folder will always be created, regardless\nof the value of createHomeFolder. The name of the folder will be identically\nto the principalId:\n\n >>> manager.autoCreateAssignment = True\n >>> homeFolder = manager.getHomeFolder('florian')\n >>> 'florian' in manager.assignments\n True\n >>> 'florian' in baseFolder\n True\n\nSometimes you want to create a homefolder which is not a zope.app.Folder.\nYou can change the object type that is being created by changing the\ncontainerObject property. It defaults to 'zope.app.folder.Folder'.\nLet's create a homefile.\n\n >>> manager.containerObject = 'zope.app.file.File'\n >>> manager.assignHomeFolder('fileuser', create=True)\n >>> homeFolder = manager.getHomeFolder('fileuser')\n >>> print homeFolder #doctest: +ELLIPSIS\n \n\nYou see that now a File object has been created. We reset containerObject\nto zope,folder.Folder to not confuse the follow tests.\n\n >>> manager.containerObject = 'zope.folder.Folder'\n\nAccessing the Home Folder\n-------------------------\n\nBut how does the home folder get assigned to a principal? There are two ways\nof accessing the homefolder. The first is via a simple adapter that provides a\n`homeFolder` attribute. The second method provides the folder via a path\nadapter called `homefolder`.\n\nLet's start by creating a principal:\n\n >>> from zope.security.interfaces import IPrincipal\n >>> from zope.interface import implements\n >>> class Principal:\n ... implements(IPrincipal)\n ... def __init__(self, id):\n ... self.id = id\n >>> principal = Principal('stephan')\n\nWe also need to register our manager as a utility:\n\n >>> from zope.app.testing import ztapi\n >>> from zope.app.homefolder.interfaces import IHomeFolderManager\n >>> ztapi.provideUtility(IHomeFolderManager, manager, 'manager')\n\n\n(1) Now we can access the home folder via the adapter:\n\n >>> from zope.app.homefolder.interfaces import IHomeFolder\n >>> adapter = IHomeFolder(principal)\n >>> adapter.homeFolder is baseFolder['stephan']\n True\n\n(2) Or alternatively via the path adapter:\n\n >>> import zope.component\n >>> from zope.traversing.interfaces import IPathAdapter\n >>> zope.component.getAdapter(principal, IPathAdapter,\n ... \"homefolder\") is baseFolder['stephan']\n True\n\nAs you can see, the path adapter just returns the homefolder. This way we can\nguarantee that the folder's full API is always available. Of course the real\nway it will be used is via a TALES expression:\n\n Setup of the Engine\n\n >>> from zope.app.pagetemplate.engine import Engine\n >>> from zope.tales.tales import Context\n >>> context = Context(Engine, {'principal': principal})\n\n Executing the TALES expression\n\n >>> bytecode = Engine.compile('principal/homefolder:keys')\n >>> list(bytecode(context))\n []\n >>> baseFolder['stephan'][u'documents'] = Folder()\n >>> list(bytecode(context))\n [u'documents']\n\n\n=======\nCHANGES\n=======\n\n3.5.0 (2009-02-01)\n------------------\n\n- Use ``zope.container`` instead of ``zope.app.container``.\n\n- Remove dependency on ``zope.app.zapi``.\n\n3.4.0 (2007-11-03)\n------------------\n\n- Initial release independent of the main Zope tree.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/zope.app.homefolder", "keywords": "zope3 homefolder principal", "license": "ZPL 2.1", "maintainer": null, "maintainer_email": null, "name": "zope.app.homefolder", "package_url": "https://pypi.org/project/zope.app.homefolder/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/zope.app.homefolder/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/zope.app.homefolder" }, "release_url": "https://pypi.org/project/zope.app.homefolder/3.5.0/", "requires_dist": null, "requires_python": null, "summary": "User Home Folders for Zope 3 Applications", "version": "3.5.0" }, "last_serial": 805191, "releases": { "3.4.0": [ { "comment_text": "", "digests": { "md5": "beaafbad55bd128a9d1cf2a9b039a00e", "sha256": "6db2e3f8a3dffab40097bb56705e8eeb76009d2725e97ba36daf8e69ce349ad4" }, "downloads": -1, "filename": "zope.app.homefolder-3.4.0.tar.gz", "has_sig": false, "md5_digest": "beaafbad55bd128a9d1cf2a9b039a00e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11961, "upload_time": "2007-11-04T21:27:21", "url": "https://files.pythonhosted.org/packages/cc/34/fbc23bf15b63effd98cdd6ad345ef69d731f1dc8644129e5007f53a9157d/zope.app.homefolder-3.4.0.tar.gz" } ], "3.5.0": [ { "comment_text": "", "digests": { "md5": "b77d9558d53fdf6ea4dea5a057749869", "sha256": "c244bd384238d7531afeb113d27dbd9f3ae48864887f5e9c77b723979c8098a5" }, "downloads": -1, "filename": "zope.app.homefolder-3.5.0.tar.gz", "has_sig": false, "md5_digest": "b77d9558d53fdf6ea4dea5a057749869", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12347, "upload_time": "2009-02-01T12:48:22", "url": "https://files.pythonhosted.org/packages/b4/4e/5e7e50e4b6cafb265b14483cdabcf45bb6bb5e77e9a3f9d5186f0ed073ac/zope.app.homefolder-3.5.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b77d9558d53fdf6ea4dea5a057749869", "sha256": "c244bd384238d7531afeb113d27dbd9f3ae48864887f5e9c77b723979c8098a5" }, "downloads": -1, "filename": "zope.app.homefolder-3.5.0.tar.gz", "has_sig": false, "md5_digest": "b77d9558d53fdf6ea4dea5a057749869", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12347, "upload_time": "2009-02-01T12:48:22", "url": "https://files.pythonhosted.org/packages/b4/4e/5e7e50e4b6cafb265b14483cdabcf45bb6bb5e77e9a3f9d5186f0ed073ac/zope.app.homefolder-3.5.0.tar.gz" } ] }