diff options
author | erikb <erikb@574bc980-5f2d-0410-acbc-c8f9f0eb14e0> | 2007-10-31 20:26:55 (GMT) |
---|---|---|
committer | erikb <erikb@574bc980-5f2d-0410-acbc-c8f9f0eb14e0> | 2007-10-31 20:26:55 (GMT) |
commit | 9783a88ae07b9f2b6a754d1f595fbc6a149227e0 (patch) | |
tree | ca25a5d417acc980a5c5bf60f3e65447e4b58c74 /serialize.py | |
parent | d04a59cf1402e245a651c617ff740f57827aabae (diff) |
refactoring checks out in jhbuild
git-svn-id: http://mediamods.com/public-svn/camera-activity/Record.activity@791 574bc980-5f2d-0410-acbc-c8f9f0eb14e0
Diffstat (limited to 'serialize.py')
-rw-r--r-- | serialize.py | 164 |
1 files changed, 82 insertions, 82 deletions
diff --git a/serialize.py b/serialize.py index 4e87222..4cf7bc0 100644 --- a/serialize.py +++ b/serialize.py @@ -225,105 +225,105 @@ def addRecdXmlAttrs( self, el, recd, forMeshTransmit ): el.setAttribute(self.recdThumbBytes, str(recd.thumbBytes)) - def saveMediaHash( mediaTypes, mediaHash ): - impl = getDOMImplementation() - album = impl.createDocument(None, Constants.recdAlbum, None) - root = album.documentElement - - #flag everything for saving... - atLeastOne = False - for type,value in mediaTypes.items(): +def saveMediaHash( mediaTypes, mediaHashs ): + impl = getDOMImplementation() + album = impl.createDocument(None, Constants.recdAlbum, None) + root = album.documentElement + + #flag everything for saving... + atLeastOne = False + for type,value in mediaTypes.items(): + typeName = value[Constants.keyName] + hash = mediaHashs[type] + for i in range (0, len(hash)): + recd = hash[i] + recd.savedXml = False + recd.savedMedia = False + atLeastOne = True + + #and if there is anything to save, save it + if (atLeastOne): + for type,value in m.mediaTypes.items(): typeName = value[Constants.keyName] - hash = mediaHashs[type] + hash = m.mediaHashs[type] + for i in range (0, len(hash)): recd = hash[i] - recd.savedXml = False - recd.savedMedia = False - atLeastOne = True - - #and if there is anything to save, save it - if (atLeastOne): - for type,value in m.mediaTypes.items(): - typeName = value[Constants.keyName] - hash = m.mediaHashs[type] - - for i in range (0, len(hash)): - recd = hash[i] - mediaEl = album.createElement( typeName ) - root.appendChild( mediaEl ) - self._saveMedia( mediaEl, recd ) - - return album - - - def _saveMedia( el, recd ): - if ( (recd.buddy == True) and (recd.datastoreId == None) and (not recd.downloadedFromBuddy) ): - pixbuf = recd.getThumbPixbuf( ) - buddyThumb = str( utils.getStringFromPixbuf(pixbuf) ) - el.setAttribute(self.recdBuddyThumb, buddyThumb ) - recd.savedMedia = True - self._saveXml( el, recd ) - else: - recd.savedMedia = False - self._saveMediaToDatastore( el, recd ) + mediaEl = album.createElement( typeName ) + root.appendChild( mediaEl ) + self._saveMedia( mediaEl, recd ) + return album - def _saveXml( el, recd ): - addRecdXmlAttrs( el, recd, False ) - recd.savedXml = True +def _saveMedia( el, recd ): + if ( (recd.buddy == True) and (recd.datastoreId == None) and (not recd.downloadedFromBuddy) ): + pixbuf = recd.getThumbPixbuf( ) + buddyThumb = str( utils.getStringFromPixbuf(pixbuf) ) + el.setAttribute(self.recdBuddyThumb, buddyThumb ) + recd.savedMedia = True + self._saveXml( el, recd ) + else: + recd.savedMedia = False + self._saveMediaToDatastore( el, recd ) - def _saveMediaToDatastore( el, recd ): - #note that we update the recds that go through here to how they would - #look on a fresh load from file since this won't just happen on close() - if (recd.datastoreId != None): - #already saved to the datastore, don't need to re-rewrite the file since the mediums are immutable - #However, they might have changed the name of the file - if (recd.titleChange): - recd.datastoreOb = getMediaFromDatastore( recd ) - if (recd.datastoreOb.metadata['title'] != recd.title): - recd.datastoreOb.metadata['title'] = recd.title - datastore.write(recd.datastoreOb) +def _saveXml( el, recd ): + addRecdXmlAttrs( el, recd, False ) + recd.savedXml = True - #reset for the next title change if not closing... - recd.titleChange = False - #save the title to the xml - recd.savedMedia = True - self._saveXml( xmlFile, el, recd ) - else: - recd.savedMedia = True - self._saveXml( xmlFile, el, recd ) +def _saveMediaToDatastore( el, recd ): + #note that we update the recds that go through here to how they would + #look on a fresh load from file since this won't just happen on close() + if (recd.datastoreId != None): + #already saved to the datastore, don't need to re-rewrite the file since the mediums are immutable + #However, they might have changed the name of the file + if (recd.titleChange): + recd.datastoreOb = getMediaFromDatastore( recd ) + if (recd.datastoreOb.metadata['title'] != recd.title): + recd.datastoreOb.metadata['title'] = recd.title + datastore.write(recd.datastoreOb) + + #reset for the next title change if not closing... + recd.titleChange = False + #save the title to the xml + recd.savedMedia = True + + self._saveXml( xmlFile, el, recd ) else: - #this will remove the media from being accessed on the local disk since it puts it away into cold storage - #therefore this is only called when write_file is called by the activity superclass - mediaObject = datastore.create() - mediaObject.metadata['title'] = recd.title + recd.savedMedia = True + self._saveXml( xmlFile, el, recd ) - pixbuf = recd.getThumbPixbuf() - thumbData = utils.getStringFromPixbuf(pixbuf) - mediaObject.metadata['preview'] = thumbData + else: + #this will remove the media from being accessed on the local disk since it puts it away into cold storage + #therefore this is only called when write_file is called by the activity superclass + mediaObject = datastore.create() + mediaObject.metadata['title'] = recd.title - colors = str(recd.colorStroke.hex) + "," + str(recd.colorFill.hex) - mediaObject.metadata['icon-color'] = colors + pixbuf = recd.getThumbPixbuf() + thumbData = utils.getStringFromPixbuf(pixbuf) + mediaObject.metadata['preview'] = thumbData - mtype = self.m.mediaTypes[recd.type] - mmime = mtype[self.keyMime] - mediaObject.metadata['mime_type'] = mmime + colors = str(recd.colorStroke.hex) + "," + str(recd.colorFill.hex) + mediaObject.metadata['icon-color'] = colors - mediaObject.metadata['activity'] = Constants.activityId + mtype = self.m.mediaTypes[recd.type] + mmime = mtype[self.keyMime] + mediaObject.metadata['mime_type'] = mmime - mediaFile = recd.getMediaFilepath(False) - mediaObject.file_path = mediaFile - mediaObject.transfer_ownership = True + mediaObject.metadata['activity'] = Constants.activityId - datastore.write( mediaObject ) + mediaFile = recd.getMediaFilepath(False) + mediaObject.file_path = mediaFile + mediaObject.transfer_ownership = True - recd.datastoreId = mediaObject.object_id - recd.mediaFilename = None - recd.thumbFilename = None - recd.savedMedia = True + datastore.write( mediaObject ) + + recd.datastoreId = mediaObject.object_id + recd.mediaFilename = None + recd.thumbFilename = None + recd.savedMedia = True - self._saveXml( xmlFile, el, recd )
\ No newline at end of file + self._saveXml( xmlFile, el, recd )
\ No newline at end of file |