Re: Documentation gesucht

Andreas Sliwka <[email protected]>
Newsgroups gmane.comp.web.zope.german
Message-ID <[email protected]>
> Jedem neuangelegten oder modifizierten Inhaltsobjekt musst Du noch ein
> obj.reindexObject() hinterher werfen.
Das scheint nicht zu funktionieren, oder ich missverstehe da etwas.

Also, das angehängte Skript (per zopectl run auszuführen) erwartet
eine plone instanz namens test, legt in dieser einen Ordner und in
diesem 3 Dokumente an.
Sowohl für den Ordner als auch für die Plone Instanz wird
reindexObject aufgerufen, dann wird die Transaction commited und
anschließend noch
app.test.portal_catalog.manage_catalogRebuild() aufgerufen.

Ergebnis: Alle Dokument und der Ordner sind drin, auch veröffentlich,
aber der Ordner ist nicht im Navigationsmenu.

Und jetzt der Klopper: Wenn ich über das ZMI manage_catalogRebuild()
aufrufe, also den letzten Befehl aus dem Skript nochmal, dann tauch
der Ordner in der Navigation auf.

Zope ist wirklich wundersam ;)

Grüße,

Andreas Sliwka



_______________________________________________
zope mailing list
[email protected]
https://mail.dzug.org/mailman/listinfo/zope
create_test_objects.py (text/x-python, 1.8 KB)
# vim: set fileencoding=utf-8 

import AccessControl.SecurityManagement
import transaction
from DateTime import DateTime

users = app.acl_users
admin = users.getUser("admin").__of__(users)
AccessControl.SecurityManagement.newSecurityManager(None, admin)

workflow = app.test.portal_workflow

def addFolder(id, title, description, publish = False):
	try:
	  app.test.manage_delObjects(id)
	except AttributeError:
	  pass

	app.test.manage_addFolder(id)
	folder = app.test[id]
	folder.setTitle(title)
	folder.setDescription(description)
        if publish:
	    folder.setEffectiveDate(DateTime())
	    print folder.getEffectiveDate()
	    workflow.doActionFor(folder, 'publish', 'simple_publication_workflow')
        return folder
        folder.reindexObject()

def addDocumentTo(folder, id, title, description, text, publish = False):
	folder.invokeFactory(id = doc_id, type_name="Document")
	document = folder[doc_id]
	document.setTitle(title)
	document.setDescription(description)
	document.setText(text)
	document.setEffectiveDate(DateTime())
	workflow.doActionFor(document, 'publish', 'simple_publication_workflow')

folder = addFolder("handbuch", "Handbuch", "Das Handbuch für Erzieherinnerinnen", publish = True)

items = (
  ("eins", "erstes Dokument", "hier fängts an", "lsdldlsdf sdlfkjsd fsd fsdlsdf sdf fsdljfsd lore ipsum"),
  ("zwei", "zweites Dokument", "hier geht's weiter", "lsdldlsdf sdlfkjsd fsd fsdlsdf sdf fsdljfsd lore ipsum"),
  ("drei", "drittes Dokument", "hier isses noch nicht zu ende", "lsdldlsdf sdlfkjsd fsd fsdlsdf sdf fsdljfsd lore ipsum"),
)

for doc_id, title, description, text in items:
  addDocumentTo(folder, doc_id, title, description, text, publish=True)

app.test.reindexObject()
transaction.commit()
app.test.portal_catalog.manage_catalogRebuild()
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.