/usr/share/pyshared/zope.dublincore-3.8.2.egg-info/PKG-INFO is in python-zope.dublincore 3.8.2-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | Metadata-Version: 1.0
Name: zope.dublincore
Version: 3.8.2
Summary: Zope Dublin Core implementation
Home-page: http://pypi.python.org/pypi/zope.dublincore
Author: Zope Foundation and Contributors
Author-email: zope-dev@zope.org
License: ZPL 2.1
Description: .. contents::
========
Overview
========
``zope.dublincore`` provides a Dublin Core support for Zope-based web
applications. This includes:
* an ``IZopeDublinCore`` interface definition that can be implemented
by objects directly or via an adapter to support DublinCore
metadata.
* an ``IZopeDublinCore`` adapter for annotatable objects (objects
providing ``IAnnotatable`` from ``zope.annotation``).
* a partial adapter for objects that already implement some of the
``IZopeDublinCore`` API,
* a "Metadata" browser page (which by default appears in the ZMI),
* subscribers to various object lifecycle events that automatically
set the created and modified date and some other metadata.
======================
Dublin Core Properties
======================
A dublin core property allows us to use properties from dublin core
by simply defining a property as DCProperty.
>>> from zope.dublincore import property
>>> from zope import interface
>>> from zope.annotation.interfaces import IAttributeAnnotatable
>>> class DC(object):
... interface.implements(IAttributeAnnotatable)
... title = property.DCProperty('title')
... author = property.DCProperty('creators')
... authors = property.DCListProperty('creators')
>>> obj = DC()
>>> obj.title = u'My title'
>>> obj.title
u'My title'
Let's see if the title is really stored in dublin core:
>>> from zope.dublincore.interfaces import IZopeDublinCore
>>> IZopeDublinCore(obj).title
u'My title'
Even if a dublin core property is a list property we can set and get the
property as scalar type:
>>> obj.author = u'me'
>>> obj.author
u'me'
DCListProperty acts on the list:
>>> obj.authors
(u'me',)
>>> obj.authors = [u'I', u'others']
>>> obj.authors
(u'I', u'others')
>>> obj.author
u'I'
====================================
Dublin Core metadata as content data
====================================
Sometimes we want to include data in content objects which mirrors one
or more Dublin Core fields. In these cases, we want the Dublin Core
structures to use the data in the content object rather than keeping a
separate value in the annotations typically used. What fields we want
to do this with can vary, however, and we may not want the Dublin Core
APIs to constrain our choices of field names for our content objects.
To deal with this, we can use speciallized adapter implementations
tailored to specific content objects. To make this a bit easier,
there is a factory for such adapters.
Let's take a look at the simplest case of this to start with. We have
some content object with a `title` attribute that should mirror the
Dublin Core `title` field::
>>> import zope.interface
>>> import zope.annotation.interfaces
>>> class Content(object):
...
... zope.interface.implements(
... zope.annotation.interfaces.IAttributeAnnotatable)
...
... title = u""
... description = u""
To avoid having a discrepency between the `title` attribute of our
content object and the equivalent Dublin Core field, we can provide a
specific adapter for our object::
>>> from zope.dublincore import annotatableadapter
>>> factory = annotatableadapter.partialAnnotatableAdapterFactory(
... ["title"])
This creates an adapter factory that maps the Dublin Core `title`
field to the `title` attribute on instances of our `Content` class.
Multiple mappings may be specified by naming the additional fields in
the sequence passed to `partialAnnotatableAdapterFactory()`. (We'll
see later how to use different attribute names for Dublin Core
fields.)
Let's see what happens when we use the adapter.
When using the adapter to retrieve a field set to use the content
object, the value stored on the content object is used::
>>> content = Content()
>>> adapter = factory(content)
>>> adapter.title
u''
>>> content.title = u"New Title"
>>> adapter.title
u'New Title'
If we set the relevant Dublin Core field using the adapter, the
content object is updated::
>>> adapter.title = u"Adapted Title"
>>> content.title
u'Adapted Title'
Dublin Core fields which are not specifically mapped to the content
object do not affect the content object::
>>> adapter.description = u"Some long description."
>>> content.description
u''
>>> adapter.description
u'Some long description.'
Using arbitrary field names
===========================
We've seen the simple approach, allowing a Dublin Core field to be
stored on the content object using an attribute of the same name as
the DC field. However, we may want to use a different name for some
reason. The `partialAnnotatableAdapterFactory()` supports this as
well.
If we call `partialAnnotatableAdapterFactory()` with a mapping instead
of a sequence, the mapping is used to map Dublin Core field names to
attribute names on the content object.
Let's look at an example where we want the `abstract` attribute on the
content object to be used for the `description` Dublin Core field::
>>> class Content(object):
...
... zope.interface.implements(
... zope.annotation.interfaces.IAttributeAnnotatable)
...
... abstract = u""
We can create the adapter factory by passing a mapping to
`partialAnnotatableAdapterFactory()`::
>>> factory = annotatableadapter.partialAnnotatableAdapterFactory(
... {"description": "abstract"})
We can check the effects of the adapter as before::
>>> content = Content()
>>> adapter = factory(content)
>>> adapter.description
u''
>>> content.abstract = u"What it's about."
>>> adapter.description
u"What it's about."
>>> adapter.description = u"Change of plans."
>>> content.abstract
u'Change of plans.'
Limitations
===========
The current implementation has a number of limitations to be aware of;
hopefully these can be removed in the future.
- Only simple string properties, like `title`, are supported. This is
largely because other field types have not been given sufficient
thought. Attempting to use this for other fields will cause a
`ValueError` to be raised by `partialAnnotatableAdapterFactory()`.
- The CMF-like APIs are not supported in the generated adapters. It
is not clear that these APIs are used, but content object
implementations should be aware of this limitation.
===============
Time annotators
===============
Time annotators store the creation resp. last modification time of an object.
Set up
======
>>> class Content(object):
... created = None
... modified = None
The annotations are stored on the ``IZopeDublinCore`` adapter. This dummy adapter
reads and writes from/to the context object.
>>> import zope.component
>>> import zope.dublincore.interfaces
>>> class DummyDublinCore(object):
... def __init__(self, context):
... self.__dict__['context'] = context
...
... def __getattr__(self, name):
... return getattr(self.context, name)
...
... def __setattr__(self, name, value):
... setattr(self.context, name, value)
>>> zope.component.provideAdapter(
... DummyDublinCore, (Content,), zope.dublincore.interfaces.IZopeDublinCore)
Created annotator
=================
The created annotator sets creation and modification time to current time.
>>> content = Content()
It is registered for the ``ObjectCreatedEvent``:
>>> import zope.dublincore.timeannotators
>>> import zope.lifecycleevent.interfaces
>>> zope.component.provideHandler(
... zope.dublincore.timeannotators.CreatedAnnotator,
... (zope.lifecycleevent.interfaces.IObjectCreatedEvent,))
>>> import zope.event
>>> import zope.lifecycleevent
>>> zope.event.notify(zope.lifecycleevent.ObjectCreatedEvent(content))
Both ``created`` and ``modified`` get set:
>>> content.created
datetime.datetime(<DATETIME>, tzinfo=<UTC>)
>>> content.modified
datetime.datetime(<DATETIME>, tzinfo=<UTC>)
The created annotator can also be registered for (object, event):
>>> zope.component.provideHandler(
... zope.dublincore.timeannotators.CreatedAnnotator,
... (None,
... zope.lifecycleevent.interfaces.IObjectCreatedEvent,))
>>> content = Content()
>>> ignored = zope.component.subscribers(
... (content, zope.lifecycleevent.ObjectCreatedEvent(content)), None)
Both ``created`` and ``modified`` get set this way, too:
>>> content.created
datetime.datetime(<DATETIME>, tzinfo=<UTC>)
>>> content.modified
datetime.datetime(<DATETIME>, tzinfo=<UTC>)
Modified annotator
==================
The modified annotator only sets the modification time to current time.
>>> content = Content()
It is registered for the ``ObjectModifiedEvent``:
>>> zope.component.provideHandler(
... zope.dublincore.timeannotators.ModifiedAnnotator,
... (zope.lifecycleevent.interfaces.IObjectModifiedEvent,))
>>> zope.event.notify(zope.lifecycleevent.ObjectModifiedEvent(content))
Only ``modified`` gets set:
>>> print content.created
None
>>> content.modified
datetime.datetime(<DATETIME>, tzinfo=<UTC>)
The modified annotator can also be registered for (object, event):
>>> zope.component.provideHandler(
... zope.dublincore.timeannotators.ModifiedAnnotator,
... (None,
... zope.lifecycleevent.interfaces.IObjectModifiedEvent,))
>>> content = Content()
>>> ignored = zope.component.subscribers(
... (content, zope.lifecycleevent.ObjectModifiedEvent(content)), None)
``modified`` gets set, this way, too:
>>> print content.created
None
>>> content.modified
datetime.datetime(<DATETIME>, tzinfo=<UTC>)
=======
Changes
=======
3.8.2 (2010-02-19)
==================
- Updated <DATETIME> regex normalizer to guard against test failure when
a datetime's microseconds value is zero.
3.8.1 (2010-12-14)
==================
- Added missing test dependency on zope.configuration and missing dependency
of security.zcml on zope.security's meta.zcml.
3.8.0 (2010-09-14)
==================
- Registered the annotators also for (object, event), so copy-pasting a
folder, changes the dublin core data of the contained objects, too. The
changed annotators are the following:
- ``zope.dublincore.timeannotators.ModifiedAnnotator``
- ``zope.dublincore.timeannotators.CreatedAnnotator``
- ``zope.dublincore.creatorannotator.CreatorAnnotator``
3.7.0 (2010-08-19)
==================
- Removed backward-compatibility shims for deprecated ``zope.app.dublincore.*``
permissions.
- Removed include the zcml configuration of ``zope.dublincore.browser``.
- Using python`s doctest instead of deprecated ``zope.testing.doctest``.
3.6.3 (2010-04-23)
==================
- Restored backward-compatible ``zope.app.dublincore.*`` permissions,
mapping them onto the new permissions using the ``<meta:redefinePermission>``
directive. These shims will be removed in 3.7.0.
- Added unit (not functional) test for loadability of ``configure.zcml``.
3.6.2 (2010-04-20)
==================
- Repaired regression introduced in 3.6.1: the renamed permissions were
not updated in other ZCML files.
3.6.1 (2010-04-19)
==================
- Renamed the ``zope.app.dublincore.*`` permissions to
``zope.dublincore.*``. Applications may need to fix up grants based on the
old permissions.
- Added tests for ``zope.dublincore.timeannotators``.
- Added not declared dependency on ``zope.lifecycleevent``.
3.6.0 (2009-12-02)
==================
- Removed the marker interface IZopeDublinCoreAnnotatable which doesn't seem
to be used.
- Made the registration of ZDCAnnotatableAdapter conditional, lifting the
dependency on zope.annotation and thereby the ZODB, leaving it as a test
dependency.
3.5.0 (2009-09-15)
==================
- Add missing dependencies.
- Get rid of any testing dependencies beyond zope.testing.
- Include browser ZCML configuration only if zope.browserpage is installed.
- Specify i18n domain in package's ``configure.zcml``, because we use message
IDs for permission titles.
- Remove unused imports, fix one test that was inactive because of being
overriden by another one by a mistake.
3.4.2 (2009-01-31)
==================
- Declare dependency on zope.datetime.
3.4.1 (2009-01-26)
==================
- Test dependencies are declared in a `test` extra now.
- Fix: Make CreatorAnnotator not to fail if participation principal is None
3.4.0 (2007-09-28)
==================
No further changes since 3.4.0a1.
3.4.0a1 (2007-04-22)
====================
Initial release as a separate project, corresponds to zope.dublincore
from Zope 3.4.0a1
Platform: UNKNOWN
|