Ñò , °Ic@sÏdZddklZddddddd gZdefd „ƒYZdefd „ƒYZdefd „ƒYZdefd „ƒYZ defd„ƒYZ defd„ƒYZ d efd„ƒYZ dS(sv Base adapters for the supported source types. This is, the foundations for the source adapters defined in plugins. In a ``group source adapter``, ``a section is a group`` in the source and ``its items are the users that belong to that group``. Example: If Bob and Mary belong to the "developers" group, then you can also say that items Bob and Mary belong to the "developers" section. In a ``permission source adapter``, ``a section is a permission`` in the source and ``its items are the groups that are granted that permission``. Example: If "developers" and "designers" are granted the right to update the web site ("update-site"), then you can also say that items "developers" and "designers" belong to the "update-site" section. @todo: Add support for "universal sections" (those containing item "_"). @todo: Add support for "anonymous sections" (those containing item "-"). iÿÿÿÿ(t InterfacetBaseSourceAdaptert AdapterErrort SourceErrortExistingSectionErrortNonExistingSectionErrortItemPresentErrortItemNotPresentErrorcBseZdZed„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z d „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(s± Base class for :term:`source adapters `. Please note that these abstract methods may only raise one exception: :class:`SourceError`, which is raised if there was a problem while dealing with the source. They may not raise other exceptions because they should not validate anything but the source (not even the parameters they get). .. attribute:: is_writable = True :type: bool Whether the adapter can write to the source. If the source type handled by your adapter doesn't support write access, or if your adapter itself doesn't support writting to the source (yet), then you should set this value to ``False`` in the class itself; it will get overriden if the ``writable`` parameter in :meth:`the contructor ` is set, unless you explicitly disable that parameter:: # ... class MyFakeAdapter(BaseSourceAdapter): def __init__(): super(MyFakeAdapter, self).__init__(writable=False) # ... .. note:: If it's ``False``, then you don't have to define the methods that modify the source because they won't be used: * :meth:`_include_items` * :meth:`_exclude_items` * :meth:`_create_section` * :meth:`_edit_section` * :meth:`_delete_section` .. warning:: Do not ever cache the results -- that is :class:`BaseSourceAdapter`'s job. It requests a given datum once, not multiple times, thanks to its internal cache. cCsh|_t|_||_dS(sŸ Run common setup for source adapters. :param writable: Whether the source is writable. :type writable: bool N(tloaded_sectionstFalsetall_sections_loadedt is_writable(tselftwritable((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/__init__.pyt__init__]s  cCs-|ip|iƒ|_t|_n|iS(sà Return all the sections found in the source. :return: All the sections found in the source. :rtype: dict :raise SourceError: If there was a problem with the source. (R t_get_all_sectionsRtTrue(R ((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/__init__.pytget_all_sectionsls  cCsB||ijo'|i|ƒ|i|ƒ|i|—s c3s*x#|]}|ˆjo |VqqWdS(N((RR(titems(sA/usr/lib/python2.6/site-packages/repoze/what/adapters/__init__.pys ˜s N(Rtsett exclude_itemst include_items(R RRtaddedtremoved((RRsA/usr/lib/python2.6/site-packages/repoze/what/adapters/__init__.pytset_section_itemsŒs  cCs |i|ƒS(sR Return the sections that meet a given criteria. :param hint: repoze.what's credentials dictionary or a group name. :type hint: dict or unicode :return: The sections that meet the criteria. :rtype: tuple :raise SourceError: If there was a problem with the source. (t_find_sections(R thint((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/__init__.pyt find_sectionsŸs cCs|i||fƒdS(s! Include ``item`` in ``section``. This is the individual (non-bulk) edition of :meth:`include_items`. :param section: The ``section`` to contain the ``item``. :type section: unicode :param item: The new ``item`` of the ``section``. :type item: tuple :raise NonExistingSectionError: If the ``section`` doesn't exist. :raise ItemPresentError: If the ``item`` is already included. :raise SourceError: If there was a problem with the source. N(R(R Rtitem((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/__init__.pyt include_item¬scCs|i|ƒx|D]}|i||ƒqW|iƒt|ƒ}|i||ƒ||ijo|i|c|O%s  ÿÿ