Skip to content

Commit

Permalink
Fix modification time disappearing from context data and handling mis…
Browse files Browse the repository at this point in the history
…sing value
  • Loading branch information
mhora committed Oct 1, 2014
1 parent 9f83d2b commit 7f4f4e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ There's a frood who really knows where his towel is.

1.0a10 (unreleased)
^^^^^^^^^^^^^^^^^^^
- Fix modification time disappearing from context data and handling missing value
[mhora]

- Show event's start date (instead of publication date) for Event-like objects in Basic, Collection and List tiles.
[hvelarde]
Expand Down
2 changes: 1 addition & 1 deletion src/collective/cover/tiles/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def modified(self):
mtime = ''
for k, v in self.context.data.items():
if INamedImage.providedBy(v):
mtime += self.context.data.get('{0}_mtime'.format(k), 0)
mtime += self.context.data.get('{0}_mtime'.format(k), '')

return mtime

Expand Down
6 changes: 5 additions & 1 deletion src/collective/cover/tiles/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,16 @@ def set(self, data):

for k, v in data.items():
if INamedImage.providedBy(v):
mtime_key = '{0}_mtime'.format(k)
if (self.key not in self.annotations or
k not in self.annotations[self.key] or
(self.key in self.annotations and
data[k] != self.annotations[self.key][k])):
# set modification time of the image
notify(Purge(self.tile))
data['{0}_mtime'.format(k)] = '%f' % time.time()
data[mtime_key] = '%f' % time.time()
else:
data[mtime_key] = self.annotations[self.key].get(mtime_key, '')

self.annotations[self.key] = PersistentDict(data)
notify(ObjectModifiedEvent(self.context))

0 comments on commit 7f4f4e3

Please sign in to comment.