The above two lines work fine. The print statement will return "budwa". But when I check a listing of names to see if the ZODB has been updated, it hasn't. Can someone help?
The purpose of this script is to look for all objects of the type Faculty in ZODB and upudate the email, dept, current title, location etc with information from Active Directory.
the setLast_name() method is setting the Last_name of the Faculty Object by obtaining the information from Active Directory.
I added a setLast_nameK() method to manually update a given Faculty just to test and see if the ZODB is actually being updated. The object in the script get updated. Because, if I print it out, I see the new name. ZODB is not being updated, because later if I do a listing of Faculty, the name is still the original.
Plone and ZODB are new to me. Maybe I am doing something stupid, so please bear with me. I usually work in Java/SQL/VB environment and have been asked to do this for our CMS Plone team.
How are you running this code? If you are running it with bin/instance run, you need to commit the current transaction to persist the changes into ZODB.
from the Plone site, I am choosing add Script(python) and typing my code there. I will add import transaction and transaction.commit to see what happens.
Should I be doing this from the File System instead? Would that be better? I also wrote some code for the file system, but I am stuck on how to specify the url for the objects: My Faculty objects are in url http://mysite/yc1/portal_college/
Here is the code:
from ZEO.ClientStorage import ClientStorage
from ZODB import DB
from ZODB.PersistentMapping import PersistentMapping
from Persistence import Persistent
import transaction
storage =ClientStorage(('172.16.140.23',8100))
db = DB(storage)
connection = db.open()
print "connection open"
root = connection.root()
T=transaction.begin()
If you are on recent Plone enough and have ZEO, you can run python script from commandline with
bin/instance -Omyplonesiteid run myscript.py
This will provide plone object as variable named obj, and you can reach portal catalog etc from there. If you get this working, then you should include transaction.commit().