{ "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