summaryrefslogtreecommitdiffstats
path: root/tabellio
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2011-08-18 07:49:35 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2011-08-18 07:49:35 (GMT)
commiteec061716004d43fb6945e299ed735aa8da188ec (patch)
tree7631b6738547075ecce441918e74f81c2087c441 /tabellio
parent2820fc3c48ad16fcfdb6f077ddb849f8b3fbec54 (diff)
downloadtabellio.pcfdb-eec061716004d43fb6945e299ed735aa8da188ec.zip
tabellio.pcfdb-eec061716004d43fb6945e299ed735aa8da188ec.tar.gz
tabellio.pcfdb-eec061716004d43fb6945e299ed735aa8da188ec.tar.bz2
Use invokeFactory to create documents & dossiers
Some things do not turn right when _constructInstance is used, for example items will become of "Unknown" type after rebuilding the catalog.
Diffstat (limited to 'tabellio')
-rw-r--r--tabellio/pcfdb/sync.py23
1 files changed, 7 insertions, 16 deletions
diff --git a/tabellio/pcfdb/sync.py b/tabellio/pcfdb/sync.py
index 9456cb1..e864195 100644
--- a/tabellio/pcfdb/sync.py
+++ b/tabellio/pcfdb/sync.py
@@ -340,8 +340,7 @@ class SyncFromPcfDbView(BrowserView):
new_one = False
if not hasattr(self.documents_folder, doc_id):
- type_info._constructInstance(self.documents_folder, doc_id)
- new_one = True
+ self.documents_folder.invokeFactory('tabellio.documents.document', doc_id)
object = getattr(self.documents_folder, doc_id)
object.title = intit
object.session = sess
@@ -356,11 +355,7 @@ class SyncFromPcfDbView(BrowserView):
else:
object.authors = []
- if new_one:
- self.intids.register(object)
- notify(ObjectAddedEvent(object))
- else:
- notify(ObjectModifiedEvent(object))
+ notify(ObjectModifiedEvent(object))
try:
self.portal_workflow.doActionFor(object, 'publish')
@@ -372,7 +367,7 @@ class SyncFromPcfDbView(BrowserView):
where_ts = ''
if timestamp:
where_ts = cursor.mogrify('AND t_dossier.ts > %s', (timestamp,))
- cursor.execute('''SELECT id, st, sess, no, intit, auteurs
+ cursor.execute('''SELECT id, st, sess, no, intit, auteurs, datedep
FROM t_dossier
WHERE intit IS NOT NULL
%s''' % where_ts)
@@ -384,18 +379,18 @@ class SyncFromPcfDbView(BrowserView):
row = cursor.fetchone()
if row is None:
break
- dos_id, state, sess, no, intit, authors = row
+ dos_id, state, sess, no, intit, authors, datedep = row
print 'dos id:', dos_id
new_one = False
if not hasattr(self.dossiers_folder, dos_id):
- type_info._constructInstance(self.dossiers_folder, dos_id)
- new_one = True
+ self.dossiers_folder.invokeFactory('tabellio.documents.dossier', dos_id)
object = getattr(self.dossiers_folder, dos_id)
object.title = intit
object.session = sess
object.no = no
+ object.date = datedep
if authors:
authors = [self.get_author_intid(x) for x in authors]
object.authors = [RelationValue(x) for x in authors if x]
@@ -439,11 +434,7 @@ class SyncFromPcfDbView(BrowserView):
docintid = None
object.add_histoline(date, desc, authors, docintid, docpages)
- if new_one:
- self.intids.register(object)
- notify(ObjectAddedEvent(object))
- else:
- notify(ObjectModifiedEvent(object))
+ notify(ObjectModifiedEvent(object))
try:
self.portal_workflow.doActionFor(object, 'publish')