Fix up saving and loading service items

This commit is contained in:
Tim Bentley 2010-01-29 16:38:28 +00:00
parent 1fd98217ab
commit 3610b232bd
2 changed files with 13 additions and 4 deletions

View File

@ -159,7 +159,7 @@ def main():
help="Set the Qt4 style (passed directly to Qt4).")
# Set up logging
filename = u'openlp.log'
logfile = FileHandler(filename)
logfile = FileHandler(filename, u'w')
logfile.setFormatter(logging.Formatter(
u'%(asctime)s %(name)-15s %(levelname)-8s %(message)s'))
log.addHandler(logfile)

View File

@ -438,10 +438,10 @@ class ServiceManager(QtGui.QWidget):
for item in self.serviceItems:
service.append({u'serviceitem':item[u'service_item'].get_service_repr()})
if item[u'service_item'].uses_file():
for frame in item[u'service_item'].get_frames:
for frame in item[u'service_item'].get_frames():
path_from = unicode(os.path.join(
item[u'service_item'].service_item_path,
frame.get_frame_title()))
frame[u'title']))
zip.write(path_from)
file = open(servicefile, u'wb')
cPickle.dump(service, file)
@ -504,7 +504,8 @@ class ServiceManager(QtGui.QWidget):
serviceitem = ServiceItem()
serviceitem.RenderManager = self.parent.RenderManager
serviceitem.set_from_service(item, self.servicePath)
self.addServiceItem(serviceitem)
if self.validateItem(serviceitem):
self.addServiceItem(serviceitem)
try:
if os.path.isfile(p_file):
os.remove(p_file)
@ -521,6 +522,14 @@ class ServiceManager(QtGui.QWidget):
self.serviceName = name[len(name) - 1]
self.parent.serviceChanged(True, self.serviceName)
def validateItem(self, serviceItem):
print "---"
print serviceItem.name
print serviceItem.title
print serviceItem.service_item_path
print serviceItem.service_item_type
return True
def cleanUp(self):
"""
Empties the servicePath of temporary files