Ticket #13362 (confirmed Bug)
Archetypes and DateTime.strftime() are not compatible
Reported by: | csenger | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 4.x |
Component: | Archetypes | Version: | 4.2 |
Keywords: | DateTime | Cc: | dimboo, ida |
Description (last modified by ida) (diff)
Archetypes has a fallback date in Products.Archetypes.ExtensibleMetadata
FLOOR_DATE = DateTime(1000, 1) # always effective
that it uses for the effectiveDate field. Unfortunately this cannot be strftime()d cause DateTime uses pythons datetime.datetime since Version 2.11 that needs year to be >1900:
(Pdb) from Products.Archetypes.ExtensibleMetadata import FLOOR_DATE (Pdb) FLOOR_DATE.strftime('%Y-%M') *** ValueError: year=1000 is before 1900; the datetime strftime() methods require year >= 1900
If effectiveDate is not set/None, ExtensibleMetadata.effective returns FLOOR_DATE. strftime() this, e.g. through toLocalizedTime(), does not work. Plone views and templates are not affected. E.g. plone.app.search:search.pt uses ExtensibleMetadata.EffectiveDate(). This method returns the string 'None'.
Places that break are e.g.
- http://localhost:8080/Plone/portal_catalog/Indexes/effective/manage_browse
- collective.solr which indexes effective, not EffectiveDate
- collective.ebook, when hitting the pdf-gen-button
Same goes for the expiration-date, which falls back on year 2500.
Change History
comment:1 Changed 3 years ago by kleist
- Status changed from new to confirmed
- Component changed from Unknown to Archetypes
comment:3 Changed 3 years ago by ida
- Keywords DateTime added
- Cc ida added
- Description modified (diff)
comment:4 Changed 3 years ago by ida
Proposing to set the effective- and the expiration-date to the creation-date-value during creation. Makes semantically sense, imho (yes, it is published and expired in the moment of birth, if no user decides differently) and resolves the conflicts.
Approvals or objections anyone?