[Zope-Checkins] CVS: Packages/ZConfig - Context.py:1.9 __init__.py:1.2
Fred L. Drake, Jr.
fred@zope.com
Thu, 7 Nov 2002 15:05:55 -0500
Update of /cvs-repository/Packages/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv13361
Modified Files:
Context.py __init__.py
Log Message:
Add support for loading from file objects.
=== Packages/ZConfig/Context.py 1.8 => 1.9 ===
--- Packages/ZConfig/Context.py:1.8 Thu Nov 7 13:54:39 2002
+++ Packages/ZConfig/Context.py Thu Nov 7 15:05:24 2002
@@ -54,6 +54,23 @@
self._finish()
return top
+ def loadfile(self, file, url=None):
+ if not url:
+ name = getattr(file, "name", None)
+ if name and name[0] != "<" and name[-1] != ">":
+ url = "file://" + urllib.pathname2url(os.path.abspath(name))
+ top = self.createToplevelSection(url)
+ self._all_sections.append(top)
+ self._imports = [top]
+ self._current_imports.append(top)
+ try:
+ self.parse(file, top, url)
+ finally:
+ del self._current_imports[-1]
+ self._finish()
+ return top
+
+
# interface for parser
def importConfiguration(self, section, url):
=== Packages/ZConfig/__init__.py 1.1 => 1.2 ===
--- Packages/ZConfig/__init__.py:1.1 Tue Oct 8 17:42:17 2002
+++ Packages/ZConfig/__init__.py Thu Nov 7 15:05:24 2002
@@ -19,3 +19,7 @@
def load(url):
import Context
return Context.Context().load(url)
+
+def loadfile(file, url=None):
+ import Context
+ return Context.Context().loadfile(file, url)