{ "info": { "author": "Ross Patterson", "author_email": "me@rpatterson.net", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": ".. -*-doctest-*-\n\n=============================\ncollective.validationoverride\n=============================\n\nFor some sites, it may be useful to allow certain users, such as site\nadministrators, to edit content without satisfying field validators.\nFor example, a site with a content type for capturing member contact\ninformation would use required fields for most of the contact\ninformation fields. On rare occasions, however, the contact\ninformation object may be required for some purposes, such as general\nlisting, but the full contact information may not be available, such\nas wen a member is away.\n\nThe collective.validationoverride package provides patches the\nArchetypes field validator method such that when field validation\nfailures are logged but validation status is still successful.\nSpecifically, a permission is checked and if the current user has that\npermission in the context of the object, the validation error is\nlogged and then removed from the list of validation errors allowing\nfor a successful validation status.\n\nThe permission to check is taken from the\n'validation_override_permission' field attribute defaulting to the\n\"Override validation\" permission. As such, field validation may be\noverridden without modifying the content types by assigning the\n\"Override validation\" permission to the appropriate roles in the\ndesired contexts. By default, the \"Manager\" role has this permission.\n\nExamples\n--------\n\nBefore installing collective.validationoverride, field validation must\nbe satisfied.\n\nCapture logging output.\n\n >>> from zope.testing.loggingsupport import InstalledHandler\n >>> log_handler = InstalledHandler('collective.validationoverride')\n\nOpen a browser and log in as a user with the \"Manager\" role.\n\n >>> from Products.Five.testbrowser import Browser\n >>> from Products.PloneTestCase import ptc\n >>> owner_browser = Browser()\n >>> owner_browser.handleErrors = False\n >>> owner_browser.open(portal.absolute_url())\n >>> owner_browser.getLink('Log in').click()\n >>> owner_browser.getControl(\n ... 'Login Name').value = ptc.portal_owner\n >>> owner_browser.getControl(\n ... 'Password').value = ptc.default_password\n >>> owner_browser.getControl('Log in').click()\n\nAdd an event and try to save it without valid field values.\nThe validation fails and reports the required fields.\n\n >>> owner_browser.getLink(url='Event').click()\n >>> owner_browser.getControl('Event URL').value = 'foo'\n >>> owner_browser.getControl('Contact E-mail').value = 'bar'\n >>> owner_browser.getControl('Save').click()\n >>> print owner_browser.contents\n <...\n
Please correct the indicated errors.
...\n
Title is required, please correct.
...\n
Validation failed(isURL): 'foo' is not a valid url.
...\n
Validation failed(isEmail): 'bar' is not a valid email address.
...\n\nNo validation errors have been logged.\n\n >>> for record in log_handler.records:\n ... print record.getMessage()\n\nAfter installing collective.validationoverride, field validation\nfailures will be omitted for users with the \"Manger\" role but not for\nnormal users since the \"Override validation\" permission is only given\nto users with the \"Manager\" role.\n\nInstall the collective.validationoverride package.\n\n >>> portal.portal_quickinstaller.installProduct(\n ... 'collective.validationoverride')\n ''\n\nNow a user with the \"Manager\" role can successfully add an event with\ninvalid field values.\n\n >>> owner_browser.open(portal.absolute_url())\n >>> owner_browser.getLink(url='Event').click()\n >>> owner_browser.getControl('Event URL').value = 'foo'\n >>> owner_browser.getControl('Contact E-mail').value = 'bar'\n >>> owner_browser.getControl('Save').click()\n >>> print owner_browser.contents\n <...\n
Changes saved.
...\n bar...\n >> for record in log_handler.records:\n ... print record.getMessage()\n Overriding the validation result u'Title is required, please correct.' on :\n {'title': u'Title is required, please correct.'}\n Overriding the validation result u\"Validation failed(isURL): 'foo' is not a valid url.\" on :\n {}\n Overriding the validation result u\"Validation failed(isEmail): 'bar' is not a valid email address.\" on :\n {}...\n >>> log_handler.clear()\n\nOpen a browser and log in as a normal user.\n\n >>> browser = Browser()\n >>> browser.handleErrors = False\n >>> browser.open(portal.absolute_url())\n >>> browser.getLink('Log in').click()\n >>> browser.getControl('Login Name').value = ptc.default_user\n >>> browser.getControl(\n ... 'Password').value = ptc.default_password\n >>> browser.getControl('Log in').click()\n\nThe normal use still cannot add an event with invalid field values.\n\n >>> browser.open(self.folder.absolute_url())\n >>> browser.getLink(url='Event').click()\n >>> browser.getControl('Event URL').value = 'foo'\n >>> browser.getControl('Contact E-mail').value = 'bar'\n >>> browser.getControl('Save').click()\n >>> print browser.contents\n <...\n
Please correct the indicated errors.
...\n
Title is required, please correct.
...\n
Validation failed(isURL): 'foo' is not a valid url.
...\n
Validation failed(isEmail): 'bar' is not a valid email address.
...\n\nNo validation errors have been logged.\n\n >>> for record in log_handler.records:\n ... print record.getMessage()\n\nSet the 'validation_override_permission' field attribute to a\npermission the normal user has.\n\n >>> from Products.ATContentTypes.content import event\n >>> schema = event.ATEvent.schema\n >>> schema['title'].validation_override_permission = (\n ... \"Modify portal content\")\n >>> schema['eventUrl'].validation_override_permission = (\n ... \"Modify portal content\")\n >>> schema['contactEmail'].validation_override_permission = (\n ... \"Modify portal content\")\n\nNow the user can successfully add an event with invalid field values.\n\n >>> browser.open(self.folder.absolute_url())\n >>> browser.getLink(url='Event').click()\n >>> browser.getControl('Event URL').value = 'foo'\n >>> browser.getControl('Contact E-mail').value = 'bar'\n >>> browser.getControl('Save').click()\n >>> print browser.contents\n <...\n
Changes saved.
...\n
bar...\n >> for record in log_handler.records:\n ... print record.getMessage()\n Overriding the validation result u'Title is required, please correct.' on :\n {'title': u'Title is required, please correct.'}\n Overriding the validation result u\"Validation failed(isURL): 'foo' is not a valid url.\" on :\n {}\n Overriding the validation result u\"Validation failed(isEmail): 'bar' is not a valid email address.\" on :\n {}...\n >>> log_handler.clear()\n \nChangelog\n=========\n\n0.1 - 2009-11-12\n----------------\n\n* Initial release\n\n\nTODO\n====", "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/collective.validationoverride", "keywords": "", "license": "GPL", "maintainer": null, "maintainer_email": null, "name": "collective.validationoverride", "package_url": "https://pypi.org/project/collective.validationoverride/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/collective.validationoverride/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/collective.validationoverride" }, "release_url": "https://pypi.org/project/collective.validationoverride/0.1/", "requires_dist": null, "requires_python": null, "summary": "Allow AT field validatiuon to fail for users who have an override permission", "version": "0.1" }, "last_serial": 845335, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "28edb9891fe4e6e234aa8c8204980976", "sha256": "e9c447f0ca0c8c93fafd59e672d2af5de0159bb87f3ac528493dcb0209a330b2" }, "downloads": -1, "filename": "collective.validationoverride-0.1.tar.gz", "has_sig": false, "md5_digest": "28edb9891fe4e6e234aa8c8204980976", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6329, "upload_time": "2009-11-12T23:47:41", "url": "https://files.pythonhosted.org/packages/84/f6/b6bfe01a0523de5c0d7fd9c00beab7f8f8a70ed74a2a57af92277886626d/collective.validationoverride-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "28edb9891fe4e6e234aa8c8204980976", "sha256": "e9c447f0ca0c8c93fafd59e672d2af5de0159bb87f3ac528493dcb0209a330b2" }, "downloads": -1, "filename": "collective.validationoverride-0.1.tar.gz", "has_sig": false, "md5_digest": "28edb9891fe4e6e234aa8c8204980976", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6329, "upload_time": "2009-11-12T23:47:41", "url": "https://files.pythonhosted.org/packages/84/f6/b6bfe01a0523de5c0d7fd9c00beab7f8f8a70ed74a2a57af92277886626d/collective.validationoverride-0.1.tar.gz" } ] }