- Editing Data.fs from the command line
This recipe explains how to edit a Zope Data.fs file from the Python interactive shell (command line) in order to delete, rename, or add objects into Zope's database. This a *very* useful thing to be able to do when your Data.fs has been damaged. - Vorgehen bei defekter Datenbank
Every once in a while you'll corrupt your Zope Data.fs file, and Zope won't start. Since the Data.fs tacks transactions on to the end of the Data.fs file, recovering the Data.fs is most likely as easy as deleting the last transaction or three from the Data.fs. - Editing Data.fs from the command line
This recipe explains how to edit a Zope Data.fs file from the Python interactive shell (command line) in order to delete, rename, or add objects into Zope's database. This a *very* useful thing to be able to do when your Data.fs has been damaged. - Vorgehen bei defekter Datenbank
Every once in a while you'll corrupt your Zope Data.fs file, and Zope won't start. Since the Data.fs tacks transactions on to the end of the Data.fs file, recovering the Data.fs is most likely as easy as deleting the last transaction or three from the Data.fs.
Korrupte Datenbankobjekte reparieren
Verschiedene Ursachen können die ZOPE-Datenbank korrumpieren, z.B. Systemabstürze oder ein Festplattendefekt. Bemerkbar macht sich dies durch einen sog. POSKeyError, die betroffenen Objekte lassen sich dann nicht mehr bearbeiten. (Siehe auch Ausgabe auf Kommandozeile bzw. nohup.out)
SOLUTION: Führt ZOPEHOME/lib/python/ZODB/fsrecover.py nicht zum gewünschten Erfolg, so kann die Datenbank auf Kommandozeilen-Ebene editiert werden.
#Achtung kein vollständiges Skript,
#Parametrisierung erforderlich!
#Befehle auf der Shell/Kommandozeile eingeben
#Umgebungsvariable sezten
PYTHONPATH=/opt/zope/lib/python;export PYTHONPATH
#python-interpreter aufrufen
ZOPEHOME/bin/python
from Zope import app
from ZODB import POSException
from OFS import Folder |
from OFS import DTMLMethod #a(Beispiele)
root= app()
obj= root.unrestrictedTraverse('url_to_obj')
for id,val in obj.objectItems():
try: val.getId() #Einrückung beachten
except POSKeyError: break
#(id) enthält jetzt das gesuchte objekt
#Löschen des Objektes
obj.manage_delObjects(id)
get_transaction().commit()
#optional (Neu)anlegen des Objektes
obj.manage_addFolder('Foldername')
get_transaction().commit()
##################################
#Beispiel für eine Fehlermeldung
#bei korrupter Data.fs
------
2003-12-12T23:28:11 ERROR(200)
ZODB Couldn't load state for
'\x00\x00\x00\x00\x00\nY\xa7'
Traceback (innermost last):
File /opt/Zope-2.6.1-linux2-x86/lib/python
/ZODB/Connection.py,line 509, in setstate
File /opt/Zope-2.6.1-linux2-x86/lib/python
/ZODB/FileStorage.py,line 650, in load
(Object: /opt/Zope-2.6.1-linux2-x86/var/Data.fs)
File /opt/Zope-2.6.1-linux2-x86/lib/python
/ZODB/FileStorage.py,line 624, in _load
(Object: /opt/Zope-2.6.1-linux2-x86/var/Data.fs)
POSKeyError: 00000000000a59a7
------COMMENT: Für eine detaillierte Beschreibung siehe den folgenden Link 'Editing Data.fs...'. Das Vorgehen ist unter Zope 2.6.1 getestet und funktioniert problemlos.
Thanks to Dieter Maurer and heureso
Erstellt von: Dr. Volker Liebenberg , erstellt am: 27.06.2008 , zuletzt geändert: 19.07.2008