Commit f6396b03 authored by Jim Fulton's avatar Jim Fulton

Improved error reporting.

parent cd22345a
...@@ -12,8 +12,8 @@ __doc__='''Standard routines for handling Principia Extensions ...@@ -12,8 +12,8 @@ __doc__='''Standard routines for handling Principia Extensions
Principia extensions currently include external methods and pluggable brains. Principia extensions currently include external methods and pluggable brains.
$Id: Extensions.py,v 1.1 1998/08/03 13:43:26 jim Exp $''' $Id: Extensions.py,v 1.2 1998/09/16 16:52:42 jim Exp $'''
__version__='$Revision: 1.1 $'[11:-2] __version__='$Revision: 1.2 $'[11:-2]
from string import find from string import find
import os, zlib, rotor import os, zlib, rotor
...@@ -42,7 +42,9 @@ def getObject(module, name, reload=0, modules={}): ...@@ -42,7 +42,9 @@ def getObject(module, name, reload=0, modules={}):
d,n = path_split(module) d,n = path_split(module)
if d: raise ValueError, ( if d: raise ValueError, (
'The file name, %s, should be a simple file name' % module) 'The file name, %s, should be a simple file name' % module)
m={}
execsrc=None
d=find(n,'.') d=find(n,'.')
if d > 0: if d > 0:
d,n=n[:d],n[d+1:] d,n=n[:d],n[d+1:]
...@@ -53,14 +55,23 @@ def getObject(module, name, reload=0, modules={}): ...@@ -53,14 +55,23 @@ def getObject(module, name, reload=0, modules={}):
data=zlib.decompress( data=zlib.decompress(
rotor.newrotor(d+' shshsh').decrypt(open(n).read()) rotor.newrotor(d+' shshsh').decrypt(open(n).read())
) )
exec compile(data,module,'exec') in m execsrc=compile(data,module,'exec')
else:
exec open("%s/Extensions/%s.py" % if execsrc is None:
(SOFTWARE_HOME, module)) in m try: execsrc=open("%s/Extensions/%s.py" % (SOFTWARE_HOME, module))
else: except: raise "Module Error", (
exec open("%s/Extensions/%s.py" % (SOFTWARE_HOME, module)) in m "The specified module, <em>%s</em>, couldn't be opened."
% module)
m={}
exec execsrc in m
try: r=m[name]
except KeyError:
raise 'Invalid Object Name', (
"The specified object, <em>%s</em>, was not found in module, "
"<em>%s</em>." % (name, module))
r=m[name]
if old: if old:
for k, v in m.items(): old[k]=v for k, v in m.items(): old[k]=v
else: modules[module]=m else: modules[module]=m
...@@ -88,6 +99,9 @@ def getBrain(module, class_name, reload=0): ...@@ -88,6 +99,9 @@ def getBrain(module, class_name, reload=0):
############################################################################## ##############################################################################
# #
# $Log: Extensions.py,v $ # $Log: Extensions.py,v $
# Revision 1.2 1998/09/16 16:52:42 jim
# Improved error reporting.
#
# Revision 1.1 1998/08/03 13:43:26 jim # Revision 1.1 1998/08/03 13:43:26 jim
# new folderish control panel and product management # new folderish control panel and product management
# #
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment