porting from Python Methods to PythonScripts in 2.3.0; LoginManager too
I just installed Zope 2.3.0 and I'm planning how to port my sites from 2.2.5. It looks like I'll have to: + Copy over the Products I installed, _except_ + Don't copy over SiteAccess and PythonMethods. + Delete the PythonMethods product from the Control_Panel/Products management folder. Will I have to manually convert each existing Python Method to a PythonScript, or are they essentially the same type? I haven't been able to test what happens yet, because all my existing Python Methods relate to LoginManager and I haven't been able to get the LoginManager product to initialize correctly in 2.3.0. I followed the first two steps above and copied over my data.fs. It comes up cleanly except for an exception while loading the LoginManager and some ZClass problems for ZClasses that depend on LoginManger. The exception is this: ------ 2001-01-29T16:57:02 ERROR(200) Zope Couldn't import Products.LoginManager Traceback (innermost last): File E:\PROGRA~1\Zope230\lib\python\OFS\Application.py, line 530, in import_products (Object: string) File E:\PROGRA~1\Zope225\lib\python\Products\LoginManager\__init__.py, line 1, in ? File E:\PROGRA~1\Zope225\lib\python\Products\LoginManager\LoginManager.py, line 121, in ? InstallError: No access file found at E:\Program Files\Zope230 - see INSTALL.txt ------ Can someone help me understand this? The two INSTALL.txt files under Zope230 offer no clues. It's odd that the exception stack shows it executing code from my older Zope225 installation. How the heck can that happen? Is that some bug in Python? There's nothing in my environment that mentions Zope225, and I dumped sys.path late in z2.py and it looks fine. I tried deleting the LoginManager product from the management interface and restarting, but the same exception occurs. I do notice that, unlike prior Zope installs, there is no 'access' file in the Zope root. Oops, I just saw another message about LoginManager not yet working in Zope 2.3. If that's so, it's a show-stopper for me. -- Fred Yankowski fred@OntoSys.com tel: +1.630.879.1312 Principal Consultant www.OntoSys.com fax: +1.630.879.1370 OntoSys, Inc 38W242 Deerpath Rd, Batavia, IL 60510, USA
After browsing the Zope-dev list (I guess that's _yet another_ list I need to follow) I found a note about creating the 'access' file manually with zpasswd.py. After doing that, LoginManager seems to come up cleanly in Zope 2.3.0. And now I can see that my Python Methods come in broken, apparently because they depend on the PythonMethods product that I didn't carry over. So I guess I'll have to have to install PythonMethods and port over those methods manually to Python Scripts. Rats. I'm just glad I didn't have too much invested into PythonMethods. -- Fred Yankowski fred@OntoSys.com tel: +1.630.879.1312 Principal Consultant www.OntoSys.com fax: +1.630.879.1370 OntoSys, Inc 38W242 Deerpath Rd, Batavia, IL 60510, USA
On Mon, Jan 29, 2001 at 11:50:17AM -0600, Fred Yankowski wrote:
over those methods manually to Python Scripts. Rats. I'm just glad I didn't have too much invested into PythonMethods.
Admittedly, I haven't been following this very closely, but wasn't Python Scripts going to simply be a new name for PythonMethods? Yours Confused David Trudgett
+ Delete the PythonMethods product from the Control_Panel/Products management folder.
Will I have to manually convert each existing Python Method to a PythonScript, or are they essentially the same type?
It's my understanding from reading release ntoes that PYthonScripts and PythonMethods will co-exist peacefully.
From: "Fred Yankowski" <fred@ontosys.com>
+ Don't copy over SiteAccess and PythonMethods. + Delete the PythonMethods product from the Control_Panel/Products management folder.
Will I have to manually convert each existing Python Method to a PythonScript, or are they essentially the same type?
They are radically different types, and can therefore live in the same Zope, side-by-side, without conflicting. There is no automatic conversion process. Simply keep PythonMethods installed, and replace individual Methods with Scripts as you feel the need. Cheers, Evan @ digicool & 4-am
The text of an external method for converting Python Methods to Python Scripts was posted to the list a while back. I forget who because I just copied and pasted at the time. Anyway, credit to whoever, and apologies for not having the name. I took that and made something that works for me as a Python Script. (Though my Methods have been rather simple...) Standard caveats, YMMV, etc, but it does a quick pass on the Methods in the folder where it is and makes Scripts from them when you hit the 'test' tab, saving the old ones as methodname.old. It's not perfect (e.g., it will import random if you use whrandom); it's just a bit easier than manually editing (copy, paste, edit) for the same functionality. It would be pretty easy to recurse all folders and change them all, but I am not that bold yet. It seems debugged enough to post. I am sure someone will let me know if otherwise. -- Jim Washington #### begin code import string ids = container.objectIds('Python Method') #what suffix do we want on the old Methods? oldscriptsuffix='.old' #replace all self. with the following: #change to context if needed newself = 'container' #for future programmatic use just to be certain no extra dots if string.find(newself,'.') >= 0: newself = string.replace(newself,'.','') for method_id in ids: method_id = string.strip(method_id) #get the Method and its title method = container[method_id] title = method.title #FTPget does not require external method! thebody = method.manage_FTPget() #get the params eop = string.find(thebody,'</params>') params = thebody[8:eop] params = string.replace(params,' ','') params = string.replace(params,'self,','') params = string.rstrip(string.replace(params,'self','')) body = thebody[eop+10:] #get the body newbodylist = [] splitbody = string.split(body,'\n') #do imports as needed #bug: random will be imported if you use whrandom for animport in ['string','whrandom','random','math']: if string.find(body,animport+'.') >= 0: newbodylist.append('import ' + animport) for k in splitbody: #this would be a good place for re; put container where self was newstring = string.replace(k,'self.',newself + '.') #bug: might miss 'self [' wish re were available newstring = string.replace(newstring,'self[', newself + '.') newbodylist.append(string.rstrip(newstring)) body = string.join(newbodylist,'\n') # uncomment to see the raw data # print 'params = "%s"' % params # print 'body is:\n"%s"' % body #rename the old and create the new. don't do more than once. if method_id [-len(oldscriptsuffix):] <> oldscriptsuffix: container.manage_renameObject(method_id,method_id+oldscriptsuffix) container.manage_addProduct['PythonScripts'].manage_addPythonScript(method_id) newscript = container[method_id] newscript.ZPythonScript_setTitle(title) newscript.ZPythonScript_edit(params, body) print 'converted: \t%s' % method_id if len(printed) < 9: print "No methods to convert" return printed #### end code Evan Simpson wrote:
From: "Fred Yankowski" <fred@ontosys.com>
+ Don't copy over SiteAccess and PythonMethods. + Delete the PythonMethods product from the Control_Panel/Products management folder.
Will I have to manually convert each existing Python Method to a PythonScript, or are they essentially the same type?
They are radically different types, and can therefore live in the same Zope, side-by-side, without conflicting. There is no automatic conversion process. Simply keep PythonMethods installed, and replace individual Methods with Scripts as you feel the need.
From: "Jim Washington" <jwashin@vt.edu>
Standard caveats, YMMV, etc, but it does a quick pass on the Methods in the folder where it is and makes Scripts from them when you hit the 'test' tab, saving the old ones as methodname.old.
Excellent! Thanks for writing and sharing this -- it looks like a fine candidate for a HOWTO. Cheers, Evan @ digicool & 4-am
participants (5)
-
David K. Trudgett -
Evan Simpson -
Fred Yankowski -
Jim Washington -
Steve Drees