[Checkins] SVN: zc.zodbrecipes/branches/dev/ Added handling of %import statements in configs.

Jim Fulton jim at zope.com
Tue Apr 17 14:31:43 EDT 2007


Log message for revision 74210:
  Added handling of %import statements in configs.
  

Changed:
  U   zc.zodbrecipes/branches/dev/README.txt
  U   zc.zodbrecipes/branches/dev/setup.py
  U   zc.zodbrecipes/branches/dev/zc/zodbrecipes/__init__.py
  U   zc.zodbrecipes/branches/dev/zc/zodbrecipes/zeo.txt

-=-
Modified: zc.zodbrecipes/branches/dev/README.txt
===================================================================
--- zc.zodbrecipes/branches/dev/README.txt	2007-04-17 18:13:29 UTC (rev 74209)
+++ zc.zodbrecipes/branches/dev/README.txt	2007-04-17 18:31:43 UTC (rev 74210)
@@ -7,6 +7,11 @@
 Changes
 *******
 
+0.2 (2007-04-17)
+================
+
+Added handling of %import directives.
+
 0.1 (2007-04-13)
 ================
 

Modified: zc.zodbrecipes/branches/dev/setup.py
===================================================================
--- zc.zodbrecipes/branches/dev/setup.py	2007-04-17 18:13:29 UTC (rev 74209)
+++ zc.zodbrecipes/branches/dev/setup.py	2007-04-17 18:31:43 UTC (rev 74210)
@@ -21,7 +21,7 @@
 name = "zc.zodbrecipes"
 setup(
     name = name,
-    version = "0.1",
+    version = "0.2",
     author = "Jim Fulton",
     author_email = "jim at zope.com",
     description = "ZC Buildout recipes for ZODB",

Modified: zc.zodbrecipes/branches/dev/zc/zodbrecipes/__init__.py
===================================================================
--- zc.zodbrecipes/branches/dev/zc/zodbrecipes/__init__.py	2007-04-17 18:13:29 UTC (rev 74209)
+++ zc.zodbrecipes/branches/dev/zc/zodbrecipes/__init__.py	2007-04-17 18:31:43 UTC (rev 74210)
@@ -272,6 +272,8 @@
 
 class ZConfigSection(dict):
 
+    imports = ()
+
     def __init__(self, type='', name='', data=None, sections=None):
         dict.__init__(self)
         if data:
@@ -291,6 +293,11 @@
                 result = ['%s<%s>' % (pre, self.type)]
             pre += '  '
 
+        if self.imports:
+            for pkgname in self.imports:
+                result.append('%import '+pkgname)
+            result.append('')
+
         for name, value in sorted(self.items()):
             result.append('%s%s %s' % (pre, name, value))
 
@@ -321,7 +328,7 @@
         pass
 
     def importSchemaComponent(self, pkgname):
-        pass
+        self.top.imports += (pkgname, )
 
     def includeConfiguration(self, section, newurl, defines):
         raise NotImplementedError('includes are not supported')

Modified: zc.zodbrecipes/branches/dev/zc/zodbrecipes/zeo.txt
===================================================================
--- zc.zodbrecipes/branches/dev/zc/zodbrecipes/zeo.txt	2007-04-17 18:13:29 UTC (rev 74209)
+++ zc.zodbrecipes/branches/dev/zc/zodbrecipes/zeo.txt	2007-04-17 18:31:43 UTC (rev 74210)
@@ -18,12 +18,16 @@
     ...       monitor-address 8101
     ...       transaction-timeout 300
     ...    </zeo>
-    ...    <filestorage main>
+    ...    %import foo
+    ...    <foo main>
     ...       path /databases/Data.fs
-    ...    </filestorage>
+    ...    </foo>
     ... ''')
 
-Here we specified a minimal configuration using a file-storage.  When
+Here we specified a minimal configuration using a "foo" storage.  We
+can use aby kind of storage we want.  Here we ised an import statement
+to import the schema definition that defined the foo section.  Any
+imports are simply copied to the generated configuration file.  When
 we run the buildout:
 
     >>> print system(buildout),
@@ -59,9 +63,10 @@
     ...       monitor-address 8101
     ...       transaction-timeout 300
     ...    </zeo>
-    ...    <filestorage main>
+    ...    %import foo
+    ...    <foo main>
     ...       path /databases/Data.fs
-    ...    </filestorage>
+    ...    </foo>
     ... ''')
 
     >>> print system(buildout),
@@ -78,15 +83,17 @@
 Let's look at the configuration files:
 
     >>> cat('parts', 'server', 'zeo.conf')
+    %import foo
+    <BLANKLINE>
     <zeo>
       address 8100
       monitor-address 8101
       transaction-timeout 300
     </zeo>
     <BLANKLINE>
-    <filestorage main>
+    <foo main>
       path /databases/Data.fs
-    </filestorage>
+    </foo>
     <BLANKLINE>
     <eventlog>
       <logfile>
@@ -117,9 +124,10 @@
     ...       monitor-address 8101
     ...       transaction-timeout 300
     ...    </zeo>
-    ...    <filestorage main>
+    ...    %import foo
+    ...    <foo main>
     ...       path /databases/Data.fs
-    ...    </filestorage>
+    ...    </foo>
     ...    <eventlog>
     ...      <logfile>
     ...        path /var/log/zeo.log
@@ -133,15 +141,17 @@
     buildout: Installing server
 
     >>> cat('parts', 'server', 'zeo.conf')
+    %import foo
+    <BLANKLINE>
     <zeo>
       address 8100
       monitor-address 8101
       transaction-timeout 300
     </zeo>
     <BLANKLINE>
-    <filestorage main>
+    <foo main>
       path /databases/Data.fs
-    </filestorage>
+    </foo>
     <BLANKLINE>
     <eventlog>
       <logfile>
@@ -169,9 +179,10 @@
     ...       monitor-address 8101
     ...       transaction-timeout 300
     ...    </zeo>
-    ...    <filestorage main>
+    ...    %import foo
+    ...    <foo main>
     ...       path /databases/Data.fs
-    ...    </filestorage>
+    ...    </foo>
     ... ''')
 
     >>> print system(buildout),
@@ -278,9 +289,10 @@
     ...       monitor-address 8101
     ...       transaction-timeout 300
     ...    </zeo>
-    ...    <filestorage main>
+    ...    %%import foo
+    ...    <foo main>
     ...       path /databases/Data.fs
-    ...    </filestorage>
+    ...    </foo>
     ... deployment = demo
     ...
     ... [demo]
@@ -383,9 +395,10 @@
     ...       monitor-address 8101
     ...       transaction-timeout 300
     ...    </zeo>
-    ...    <filestorage main>
+    ...    %%import foo
+    ...    <foo main>
     ...       path /databases/Data.fs
-    ...    </filestorage>
+    ...    </foo>
     ... deployment = demo
     ... pack = 1 1 * * 0 3
     ...



More information about the Checkins mailing list