Exemple #1
0
class PDXF_Presenter(TaggedModelPresenter):

	cid = uc2const.PDXF

	methods = None
	cms = None


	def __init__(self, appdata, cnf={}, filepath=None):
		self.config = PDXF_Config()
		config_file = os.path.join(appdata.app_config_dir, 'pdxf_config.xml')
		self.config.load(config_file)
		self.config.update(cnf)
		self.appdata = appdata
		self.doc_id = generate_id()
		self.loader = PDXF_Loader()
		self.saver = PDXF_Saver()
		self.methods = PDXF_Methods(self)
		self.rm = ResourceManager(self)
		self.create_cache_structure()
		if filepath is None:
			self.new()
		else:
			self.load(filepath)

	def create_cache_structure(self):
		doc_cache_dir = os.path.join(self.appdata.app_config_dir, 'docs_cache')
		self.doc_dir = os.path.join(doc_cache_dir, 'doc_' + self.doc_id)
		for dir in const.DOC_STRUCTURE:
			path = os.path.join(self.doc_dir, dir)
			os.makedirs(path)
		mime = open(os.path.join(self.doc_dir, 'mimetype') , 'wb')
		mime.write(const.DOC_MIME)
		mime.close()

	def init_cms(self):
		self.cms = PDXF_ColorManager(self)

	def new(self):
		self.model = methods.create_new_doc(self.config)
		self.update()

	def merge(self):
		pass

	def update(self):
		self.init_cms()
		TaggedModelPresenter.update(self)
		if not self.model is None:
			self.methods.update()
Exemple #2
0
 def __init__(self, appdata, cnf={}, filepath=None):
     self.config = PDXF_Config()
     config_file = os.path.join(appdata.app_config_dir, 'pdxf_config.xml')
     self.config.load(config_file)
     self.config.update(cnf)
     self.appdata = appdata
     self.doc_id = generate_id()
     self.loader = PDXF_Loader()
     self.saver = PDXF_Saver()
     self.methods = PDXF_Methods(self)
     self.rm = ResourceManager(self)
     self.create_cache_structure()
     if filepath is None:
         self.new()
     else:
         self.load(filepath)
Exemple #3
0
	def __init__(self, appdata, cnf={}, filepath=None):
		self.config = PDXF_Config()
		config_file = os.path.join(appdata.app_config_dir, 'pdxf_config.xml')
		self.config.load(config_file)
		self.config.update(cnf)
		self.appdata = appdata
		self.doc_id = generate_id()
		self.loader = PDXF_Loader()
		self.saver = PDXF_Saver()
		self.methods = PDXF_Methods(self)
		self.rm = ResourceManager(self)
		self.create_cache_structure()
		if filepath is None:
			self.new()
		else:
			self.load(filepath)