[Checkins] SVN: z3c.recipe.dev/trunk/ - Bug: ``script`` ``defaults`` had a bug that prevented it from use

Adam Groszer agroszer at gmail.com
Mon Apr 7 09:25:13 EDT 2008


Log message for revision 85145:
  - Bug: ``script`` ``defaults`` had a bug that prevented it from use
         renamed it to ``arguments``, now it's working
  bump version

Changed:
  U   z3c.recipe.dev/trunk/CHANGES.txt
  U   z3c.recipe.dev/trunk/setup.py
  U   z3c.recipe.dev/trunk/src/z3c/recipe/dev/README.txt
  U   z3c.recipe.dev/trunk/src/z3c/recipe/dev/script.py

-=-
Modified: z3c.recipe.dev/trunk/CHANGES.txt
===================================================================
--- z3c.recipe.dev/trunk/CHANGES.txt	2008-04-07 10:12:10 UTC (rev 85144)
+++ z3c.recipe.dev/trunk/CHANGES.txt	2008-04-07 13:25:13 UTC (rev 85145)
@@ -2,6 +2,12 @@
 CHANGES
 =======
 
+0.5.3 (2008-04-07)
+------------------
+
+- Bug: ``script`` ``defaults`` had a bug that prevented it from use
+       renamed it to ``arguments``, now it's working
+
 0.5.2 (unreleased)
 ------------------
 

Modified: z3c.recipe.dev/trunk/setup.py
===================================================================
--- z3c.recipe.dev/trunk/setup.py	2008-04-07 10:12:10 UTC (rev 85144)
+++ z3c.recipe.dev/trunk/setup.py	2008-04-07 13:25:13 UTC (rev 85145)
@@ -26,7 +26,7 @@
 
 setup(
     name = 'z3c.recipe.dev',
-    version = '0.5.2dev',
+    version = '0.5.3',
     author = 'Roger Ineichen and the Zope Community',
     author_email = 'zope-dev at zope.org',
     description = 'Zope3 development server setup recipes',

Modified: z3c.recipe.dev/trunk/src/z3c/recipe/dev/README.txt
===================================================================
--- z3c.recipe.dev/trunk/src/z3c/recipe/dev/README.txt	2008-04-07 10:12:10 UTC (rev 85144)
+++ z3c.recipe.dev/trunk/src/z3c/recipe/dev/README.txt	2008-04-07 13:25:13 UTC (rev 85145)
@@ -230,7 +230,12 @@
 method
   The ``method`` which get called from the ``module``.
 
+arguments
+  Use the option ``arguments`` to pass arguments to the script.
+  All the string will be copied to the script 1:1.
+  So what you enter here is what you get.
 
+
 Test
 ****
 
@@ -247,8 +252,10 @@
 
   >>> write('hello', 'helloworld.py',
   ... """
-  ... def helloWorld():
+  ... def helloWorld(*args):
   ...     print 'Hello World'
+  ...     for a in args:
+  ...         print a
   ... """)
 
 Alos add a `__init__` to the `hello` package:
@@ -303,3 +310,64 @@
 
   >>> print system(join('bin', 'helloworld')),
   Hello World
+
+
+Test with parameters
+********************
+
+Of the same script defined above.
+
+Use the option `arguments = ` to pass arguments to the script.
+All the string will be copied to the script 1:1.
+So what you enter here is what you get.
+
+We'll create a `buildout.cfg` file that defines our script:
+
+  >>> write('buildout.cfg',
+  ... '''
+  ... [buildout]
+  ... develop = hello
+  ... parts = helloworld
+  ...
+  ... [helloworld]
+  ... recipe = z3c.recipe.dev:script
+  ... eggs = hello
+  ... module = hello.helloworld
+  ... method = helloWorld
+  ... arguments = 'foo', 'bar'
+  ...
+  ... ''' % globals())
+
+Let's run buildout again:
+
+  >>> print system(join('bin', 'buildout')),
+  Develop: '/sample-buildout/hello'
+  Uninstalling helloworld.
+  Installing helloworld.
+  Generated script '/sample-buildout/bin/helloworld'.
+
+And check the script again. Now we see the `helloWorld()` method is used:
+
+  >>> cat('bin', 'helloworld-script.py')
+  #!C:\Python24\python.exe
+  <BLANKLINE>
+  import sys
+  sys.path[0:0] = [
+    '/sample-buildout/hello',
+    ]
+  <BLANKLINE>
+  import os
+  sys.argv[0] = os.path.abspath(sys.argv[0])
+  <BLANKLINE>
+  <BLANKLINE>
+  import hello.helloworld
+  <BLANKLINE>
+  if __name__ == '__main__':
+      hello.helloworld.helloWorld('foo', 'bar')
+
+Now we can call the script:
+
+  >>> print system(join('bin', 'helloworld')),
+  Hello World
+  foo
+  bar

Modified: z3c.recipe.dev/trunk/src/z3c/recipe/dev/script.py
===================================================================
--- z3c.recipe.dev/trunk/src/z3c/recipe/dev/script.py	2008-04-07 10:12:10 UTC (rev 85144)
+++ z3c.recipe.dev/trunk/src/z3c/recipe/dev/script.py	2008-04-07 13:25:13 UTC (rev 85145)
@@ -56,9 +56,7 @@
             ws = []
 
         # setup script default vars
-        defaults = options.get('defaults', '').strip()
-        if defaults:
-            defaults = '(%s) + ' % defaults
+        arguments = options.get('arguments', '').strip()
 
         wd = options.get('working-directory', options['location'])
 
@@ -68,7 +66,7 @@
             [(options['script'], module, method)],
             ws, executable, self.buildout['buildout']['bin-directory'],
             extra_paths = extra_paths,
-            arguments = defaults,
+            arguments = arguments,
             initialization = initialization,
             )
 



More information about the Checkins mailing list