Package: ng.adapter
Short description of ng.adapter===============================This package has developed as the library of small adapters for thedifferent dark purposes.Adapter mtime-------------Adapter mtime intdends for getting object modification time. Objectmodification time determine on the IPersistent level and this is an exactlyin the most cases, but sometimes we need some of hooks to know objectmodification time and adapter mtime helps us in this.Adapter mtime adapts IPersistent interface to IMTime interface. IMTime interfacehas the following fields:mtimetime of the last modification of objectstrftime(format)return time as format string, fromat see in man strftimeAdapter path------------Adapter path intends for getting path from root object to current, Adapter can adoptany objects to IPath interface. Interface IPath provide followed fields:pathPath from root to current object maked from attribute __name__ of object in between;titledpathPath from root to current object maked from titles object in between. Titles getting fromadapter title (ITitle interface);Adapter title-------------Adapter title intends for getting object title (for any object).  Adapter can adoptany objects to ITitle interface. Interface IPath provide followed fields:titleObject titleIf current object has not title property, property title of object, adoptedti IZopeDublinCore return instead, If adopt to IZopeDublinCore is not possible,property __name__ or class name return instead.Adapter has been wrote in goot component style and it's posible to write adapterto ITitle for any specific cases.Adapter nsinterface-------------------Adapter nsinterface define nsinterface namespace to get possibility adopt currentobject to any interfacr. Some syntax sample followed::<tal:block define="path context/++nsinterface++ng.adapter.IPath/path"></tal:block>It usefaul, basicaly, in debugging purpose.A few adapters to INameChooser------------------------------If any of this adapters will be actvated to some container, object, created in thiscontainer will be accept __name__ from ITitle adapter. To activate adapter interface one of marker interfacesare to set to container.  There are three INameChooser adapter:NameChooserThis adapter turn on by ng.adapter.interfaces.INameChooserAble. Adapter set __name__ from ITitleadapter without any changes.NameChooserSafeThis adapter turn on by ng.adapter.interfaces.INameChooserSafeAble.Before set as __name__ adapter changing string accepted from ITitle todiscard a few symbols not recommended in URL: '/', '?' and other.NameChooserSafeWithoutSpacesThis adapter turn on by ng.adapter.interfaces.INameChooserSafeWithoutSpacesAble.Before set as __name__ adapter changing string accepted from ITitle todiscard a few symbols not recommended in URL: '/', '?' and other. Adapter replace white-spacesby '_'symbol also.Adapter pager-------------Adapter allow make pagers by list adopted to IPagerSource. Adapter quiclydoing all evaluatiion needed  to provede ready results as methods.Product content adapters from components with interfaces IContainer, IOrderedContainer andResultSet (returned by zope.catalog).Список методов IPager.....................setPagerParameters(revert=None, orphan=None,size=None)Set pager parameters:revertShow list reverted;orphanMaximum orphaned items;sizeOne page chunk size;have_beforeTrue, if page before current exist;beforesKey list from previos pages begins;beforeURLsURL list of previous pages;beforePrevious page;beforeURL = Field()URL of prefvious page;chunkComponent list showed in current chunk (page);afterKey of first item on next page;afterURLURL of next page;aftersKey list of first items on followed pages;afterURLsURL list of nest pages;have_afterTrue, if next page exist;lenCommon length of list;Code Sample::<tal:block tal:condition="python:len(context) > 0"><table cellspacing="0" cellpadding="3" bgcolor="#CCDDFF" width="100%"border="1" bordercolor="black" bordercolordark="#CCDDFF"><tr><td><p class="docttl">Вложенные материалы</td></tr><tal:block define="pager context/@@pager"><tal:block define="q python:pager.setPagerParameters(revert=True)"/><tr tal:condition="pager/have_before"><td align="left"><a href="" tal:attributes="href pager/beforeURL"> &lt;&lt;&lt;&lt;&lt;&lt;</a><tal:block repeat="item python:zip(range(1,10),pager.beforeURLs)">[<a href="" tal:attributes="href python:item[1]" tal:content="python:item[0]"/>]</tal:block></td></tr><div tal:repeat="item pager/chunk">tal:block tal:on-error="structure python:'<tr><td>'+item.__name__+'</td></tr>'"tal:content="structure item/@@short"/></div><tr tal:condition="pager/have_after"><td align="right"><tal:block repeat="item python:zip(range(1,10),pager.afterURLs)">[<a href="" tal:attributes="href python:item[1]" tal:content="python:item[0]"/>]</tal:block><a href="" tal:attributes="href pager/afterURL">  &gt;&gt;&gt;&gt;&gt; </a></td></tr></tal:block></table></tal:block>Adapter recordsize------------------Apapter allow get object record size of ZODB. Any object can be adopted tong.adapter.recordsize.IRecordSize interface and size can be read from sizeattribute. IRecordSize interface contents:sizeObject record size;Object size evaluated by means of transformation into filestorage-likeformat.Adapter checktocontain----------------------Adapter define name space **++checktocontain++** to allow check possibility context to contain the class from paramenter.Usualy namespace used in different adding-like menu::<menuItemmenu = "profilemenu"title = "Add Image"for = "ng.content.article.interfaces.ICommonContainer"action = "+/AddPhoto.html="filter = "context/++checktocontain++ng.app.photo.photo.Photo"permission = "zope.ManageContent"/>The parameter **filter** contain code to return True if **ng.app.photo.photo.Photo** can be contained in **context**container.Adapter requestcache--------------------The **requestcache** adapter can adopt **IHTTPRequest** request to IRequestCache interface. IRequestCache providemethod to set cache headers:cache(period=600)Set cache headers to cache during **period** second;nocache()Set cache headers to avoid cacheing;Adapter provide view **@@requestcache** with methods cache and nocache. Cache headers setted by the view canbe managed by **IRegistry** keys mentioned below:request_cache_use (True/False)Allow or deny cache management use. When parameter is False cache headers not set at all;request_cache_period (int)Set cache period;request_cache_use_as_nocache (True/False)Deny use any cache. When parameter is True cache headers set to deny cache by **nocache** method.The "toolchanger" tool set--------------------------The "**toolchanger**" tool set allow to make rare choice of viewduring site navigtion.Each site component provide a few views allowed unique interaction with thecomponent. The toolURL is adapter allow to generate URL based on choice makeduser in past. There is simple using sample::<tal:block tal:repeat="ob context/values"><a href="" tal:attributes="ob/@@toolURL" tal:content="ob/title"/></tal:block>Algorithm of view selection requires unification view names: all views providedby different components and named equally allow to execute similaroperations. Therefore choice selected by user is preferable choice in subsequentsite navigation, Name of view choosed by user are storedin URL. Code in sample above check existence of view with the same name forother object and, if it possible, URL to call it is generated. Default method usedotherwise. Using this idea allow to strong simplify site navigation.Unification of view names has to enforced during site development.* Sun Jul 12 2009 Andrey Orlov <dbdt@dreambot.ru> 0.2.1- Two new adapters to INameChoose added. NameChooseSafe translate title toname without forbidden URL symbols ("/", "?" and other),NameChooserSafeWithoutSpace - to name without forbidden symbols andspaces.* Wed Feb 11 2009 Andrey Orlov <dbdt@dreambot.ru> 0.2.0- Adapter ICheckSublocation added- Adapter IBreadCrumb added- Adapter IPager behaviour changed on setPagerParameters- Some debug information excluded* Mon Oct 20 2008 Andrey Orlov <dbdt@dreambot.ru> 0.1.10- Toolset "toolchanger" added- Adapter RequestCache added* Tue Sep 23 2008 Andrey Orlov <dbdt@dreambot.ru> 0.1.9- Namespace ++checktocontain++ added* Tue Feb 19 2008 Andrey Orlov <dbdt@dreambot.ru> 0.1.8- NullSublocations adapter added- AdaptiveURL adapter added- Fault tolerance of ianytitle enchanced and some diagnostics added* Wed Feb 13 2008 Andrey Orlov <dbdt@dreambot.ru> 0.1.7- A ranging in ianytitle reverted* Wed Feb 06 2008 Andrey Orlov <dbdt@dreambot.ru> 0.1.6- A few bugs fixed in ianytitle, ranging alghorithm enchanced;- Some logging excluded;- IRegisry lookup changed in pager;* Wed Jan 23 2008 Andrey Orlov <dbdt@dreambot.ru> 0.1.5- added function for format string into mtime adapter* Mon Jan 21 2008 Andrey Orlov <dbdt@dreambot.ru> 0.1.4- Registry fixed* Mon Jan 21 2008 Andrey Orlov <dbdt@dreambot.ru> 0,1,3- IAnyTitle adapter added* Tue Jan 15 2008 Andrey Orlov <dbdt@dreambot.ru> 0.1.2- Recordsize adapter added.* Sat Jan  5 2008 Andrey Orlov   <dbdt@dreambot.ru> 0.1.1- Some dependencies fixed* Sun Dec  2 2007 Andrey Orlov   <dbdt@dreambot.ru> 0.1.0- Followed adapters added: namechooser, nsinterface, pager, path,requestext, title* Fr Nov 16 2007 Yegor Shershnev <dbdt@dreambot.ru> 0.0.1- first official release