Don't create so many objects until we have differential versioning support in the datastore.

This commit is contained in:
Tomeu Vizoso 2007-06-29 20:24:22 +02:00
parent d7a8c5430e
commit a609da166b

View File

@ -235,8 +235,10 @@ class Activity(Window, gtk.Container):
if handle.object_id: if handle.object_id:
self._jobject = datastore.get(handle.object_id) self._jobject = datastore.get(handle.object_id)
self._jobject.object_id = '' # TODO: Don't create so many objects until we have versioning
del self._jobject.metadata['ctime'] # support in the datastore
#self._jobject.object_id = ''
#del self._jobject.metadata['ctime']
del self._jobject.metadata['mtime'] del self._jobject.metadata['mtime']
elif create_jobject: elif create_jobject:
logging.debug('Creating a jobject.') logging.debug('Creating a jobject.')
@ -306,14 +308,14 @@ class Activity(Window, gtk.Container):
def _internal_save_error_cb(self, err): def _internal_save_error_cb(self, err):
logging.debug("Error saving activity object to datastore: %s" % err) logging.debug("Error saving activity object to datastore: %s" % err)
def save(self): def _get_preview(self):
"""Request that the activity is saved to the Journal."""
preview_pixbuf = self.get_canvas_screenshot() preview_pixbuf = self.get_canvas_screenshot()
preview_pixbuf = preview_pixbuf.scale_simple(units.grid_to_pixels(4), preview_pixbuf = preview_pixbuf.scale_simple(units.grid_to_pixels(4),
units.grid_to_pixels(3), units.grid_to_pixels(3),
gtk.gdk.INTERP_BILINEAR) gtk.gdk.INTERP_BILINEAR)
# TODO: Find a way of taking a png out of the pixbuf without saving to a temp file. # TODO: Find a way of taking a png out of the pixbuf without saving to a temp file.
# Impementing gtk.gdk.Pixbuf.save_to_buffer in pygtk would solve this.
fd, file_path = tempfile.mkstemp('.png') fd, file_path = tempfile.mkstemp('.png')
del fd del fd
preview_pixbuf.save(file_path, 'png') preview_pixbuf.save(file_path, 'png')
@ -326,7 +328,15 @@ class Activity(Window, gtk.Container):
# TODO: Take this out when the datastore accepts binary data. # TODO: Take this out when the datastore accepts binary data.
import base64 import base64
self.metadata['preview'] = base64.b64encode(preview_data) return base64.b64encode(preview_data)
def _get_buddies(self):
return ''
def save(self):
"""Request that the activity is saved to the Journal."""
self.metadata['buddies'] = self._get_buddies()
self.metadata['preview'] = self._get_preview()
try: try:
file_path = os.path.join(tempfile.gettempdir(), '%i' % time.time()) file_path = os.path.join(tempfile.gettempdir(), '%i' % time.time())
self.write_file(file_path) self.write_file(file_path)