A few litle but useful adapters
Project description
Short description of ng.adapter
===============================
This package has developed as the library of small adapters for the
different dark purposes.
Adapter mtime
-------------
Adapter mtime intdends for getting object modification time. Object
modification time determine on the IPersistent level and this is an exactly
in the most cases, but sometimes we need some of hooks to know object
modification time and adapter mtime helps us in this.
Adapter mtime adapts IPersistent interface to IMTime interface. IMTime interface
has the following fields:
mtime
time of the last modification of object
strftime(format)
return time as format string, fromat see in man strftime
Adapter path
------------
Adapter path intdents for getting path from root object to current, Adapter can adopt
any objects to IPath interface. Interface IPath provide followed fields:
path
Path from root to current object maked from attribute __name__ of object in between;
titledpath
Path from root to current object maked from titles object in between. Titles getting from
adapter title (ITitle interface);
Adapter title
-------------
Adapter title ntdends for getting object title (for any object). Adapter can adopt
any objects to ITitle interface. Interface IPath provide followed fields:
title
Object title
If current object has not title property, property title of object, adopted
ti 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 adapter
to ITitle for any specific cases.
Adapter nsinterface
-------------------
Adapter nsinterface defince nsinterface namespace to get possibility adopt current
object 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.
Adapter namechooser
-------------------
If this adapter will be actvated to some container, object, created in this
container will be accept __name__ from ITitle adapter.
To activate adappter, set interface ng.adapter.interfaces.INameChooserAble
on container.
Adapter pager
-------------
Adapter allow make pagers by list adopted to IPagerSource. Adapter quicly
doing all evaluatiion needed to provede ready results as methods.
Product content adapters from components with interfaces IContainer, IOrderedContainer and
ResultSet (returned by zope.catalog).
Список методов IPager
.....................
setPagerParameters(revert=None, orphan=None,size=None)
Set pager parameters:
revert
Show list reverted;
orphan
Maximum orphaned items;
size
One page chunk size;
have_before
True, if page before current exist;
befores
Key list from previos pages begins;
beforeURLs
URL list of previous pages;
before
Previous page;
beforeURL = Field()
URL of prefvious page;
chunk
Component list showed in current chunk (page);
after
Key of first item on next page;
afterURL
URL of next page;
afters
Key list of first items on followed pages;
afterURLs
URL list of nest pages;
have_after
True, if next page exist;
len
Common 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"> <<<<<<</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"> >>>>> </a>
</td></tr>
</tal:block>
</table>
</tal:block>
Adapter recordsize
------------------
Apapter allow get object record size of ZODP. Any object can be adpoted to
ng.adapter.recordsize.IRecordSize interface and size can be read from size
attribute. IRecordSize interface contents:
size
Object record size;
Object size evaluated by means of transformation into filestorage-like
format.
* 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 <y.shershnev@gmail.com> 0.0.1
- first official release
===============================
This package has developed as the library of small adapters for the
different dark purposes.
Adapter mtime
-------------
Adapter mtime intdends for getting object modification time. Object
modification time determine on the IPersistent level and this is an exactly
in the most cases, but sometimes we need some of hooks to know object
modification time and adapter mtime helps us in this.
Adapter mtime adapts IPersistent interface to IMTime interface. IMTime interface
has the following fields:
mtime
time of the last modification of object
strftime(format)
return time as format string, fromat see in man strftime
Adapter path
------------
Adapter path intdents for getting path from root object to current, Adapter can adopt
any objects to IPath interface. Interface IPath provide followed fields:
path
Path from root to current object maked from attribute __name__ of object in between;
titledpath
Path from root to current object maked from titles object in between. Titles getting from
adapter title (ITitle interface);
Adapter title
-------------
Adapter title ntdends for getting object title (for any object). Adapter can adopt
any objects to ITitle interface. Interface IPath provide followed fields:
title
Object title
If current object has not title property, property title of object, adopted
ti 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 adapter
to ITitle for any specific cases.
Adapter nsinterface
-------------------
Adapter nsinterface defince nsinterface namespace to get possibility adopt current
object 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.
Adapter namechooser
-------------------
If this adapter will be actvated to some container, object, created in this
container will be accept __name__ from ITitle adapter.
To activate adappter, set interface ng.adapter.interfaces.INameChooserAble
on container.
Adapter pager
-------------
Adapter allow make pagers by list adopted to IPagerSource. Adapter quicly
doing all evaluatiion needed to provede ready results as methods.
Product content adapters from components with interfaces IContainer, IOrderedContainer and
ResultSet (returned by zope.catalog).
Список методов IPager
.....................
setPagerParameters(revert=None, orphan=None,size=None)
Set pager parameters:
revert
Show list reverted;
orphan
Maximum orphaned items;
size
One page chunk size;
have_before
True, if page before current exist;
befores
Key list from previos pages begins;
beforeURLs
URL list of previous pages;
before
Previous page;
beforeURL = Field()
URL of prefvious page;
chunk
Component list showed in current chunk (page);
after
Key of first item on next page;
afterURL
URL of next page;
afters
Key list of first items on followed pages;
afterURLs
URL list of nest pages;
have_after
True, if next page exist;
len
Common 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"> <<<<<<</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"> >>>>> </a>
</td></tr>
</tal:block>
</table>
</tal:block>
Adapter recordsize
------------------
Apapter allow get object record size of ZODP. Any object can be adpoted to
ng.adapter.recordsize.IRecordSize interface and size can be read from size
attribute. IRecordSize interface contents:
size
Object record size;
Object size evaluated by means of transformation into filestorage-like
format.
* 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 <y.shershnev@gmail.com> 0.0.1
- first official release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ng.adapter-0.1.5.tar.gz
(22.5 kB
view hashes)