cykooz.title
This package implements adapters for adapting any object to ITitle interface.
Let’s do some imports we will use later.
>>> import zope.interface >>> import zope.component >>> from zope.annotation.interfaces import IAttributeAnnotatable >>> from zope.dublincore.interfaces import IZopeDublinCore >>> from zope.container.interfaces import IContained >>> from cykooz.title.interfaces import ITitle >>> from cykooz.title import adapters
Let’s register the adapters, this is normally done in configure.zcml:
>>> zope.component.provideAdapter(adapters.ClassName2TitleAdapter) >>> zope.component.provideAdapter(adapters.Contained2TitleAdapter) >>> zope.component.provideAdapter(adapters.ZDC2TitleAdapter)
Implement test object:
>>> class SomeClass(object): ... zope.interface.implements(zope.interface.Interface) >>> some_object = SomeClass()
Get title from class name:
>>> ITitle(some_object).title u'SomeClass'
Now change the test object so that it provide IContained:
>>> zope.interface.directlyProvides(some_object, IContained) >>> some_object.__name__ = u'NameInContainer' >>> ITitle(some_object).title u'NameInContainer'
Change the test object so that is provide only IAttributeAnnotatable:
>>> zope.interface.directlyProvides(some_object, IAttributeAnnotatable) >>> IZopeDublinCore(some_object).title u''
If object do not provide IContained and field ‘title’ of IZopeDublinCore is empty then ITitle adapter return class name of object:
>>> ITitle(some_object).title u'SomeClass'
Now change the test object so that it also provide IContained:
>>> zope.interface.alsoProvides(some_object, IContained) >>> ITitle(some_object).title u'NameInContainer'
Set field ‘title’ of IZopeDublinCore:
>>> IZopeDublinCore(some_object).title = u'ZopeDublinCore Title' >>> IZopeDublinCore(some_object).title u'ZopeDublinCore Title'
Test adapter:
>>> ITitle(some_object).title u'ZopeDublinCore Title'
Changes
1.0.0 (2011-03-14)
Initial release
Metadata
Release files for cykooz.title 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cykooz.title-1.0.0.tar.gz | 4.8 kB | Without provenance | Details for cykooz.title-1.0.0.tar.gz |
Release files / cykooz.title-1.0.0.tar.gz
| Download URL | cykooz.title-1.0.0.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0293b53c5fe35753dc6a9c7152a9318a35c204e52369762845463048f6b7003d
|
|
BLAKE2b-256 checksum How to use checksums |
765b7d6ad703c342fa4289d1523fbb4d6164b39f650eac2624132787dee90656
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for cykooz.title 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.