Skip to content

Commit

Permalink
explicitly close the files for pypy
Browse files Browse the repository at this point in the history
  • Loading branch information
janwijbrand committed Jan 10, 2018
1 parent f3986db commit 8a2bdd0
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/grokcore/startup/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,16 @@ API Documentation
>>> import os, tempfile
>>> temp_dir = tempfile.mkdtemp()
>>> sitezcml = os.path.join(temp_dir, 'site.zcml')
>>> _ = open(sitezcml, 'w').write('<configure />')
>>> out = open(sitezcml, 'w')
>>> _ = out.write('<configure />')
>>> out.close()

Furthermore we create a Zope configuration file, which is also quite
plain::

>>> zope_conf = os.path.join(temp_dir, 'zope.conf')
>>> _ = open(zope_conf, 'w').write('''
>>> out = open(zope_conf, 'w')
>>> _ = out.write('''
... site-definition %s
...
... <zodb>
Expand All @@ -191,7 +194,8 @@ API Documentation
... path STDOUT
... </logfile>
... </eventlog>
... ''' %sitezcml)
... ''' % sitezcml)
>>> out.close()

Now we can call ``application_factory`` to get a WSGI application::

Expand Down Expand Up @@ -295,7 +299,8 @@ API Documentation
>>> temp_dir = tempfile.mkdtemp()

>>> sitezcml = os.path.join(temp_dir, 'site.zcml')
>>> _ = open(sitezcml, 'w').write(
>>> out = open(sitezcml, 'w')
>>> _ = out.write(
... """<configure xmlns="http://namespaces.zope.org/zope">
... <include package="zope.component" file="meta.zcml"/>
... <include package="zope.component"/>
Expand All @@ -306,9 +311,11 @@ API Documentation
... <include package="zope.site"/>
... <include package="zope.app.appsetup"/>
... </configure>""")
>>> out.close()
>>>
>>> zopeconf = os.path.join(temp_dir, 'zope.conf')
>>> _ = open(zopeconf, 'w').write("""
>>> out = open(zopeconf, 'w')
>>> _ = out.write("""
... site-definition %s
... <zodb>
... <filestorage>
Expand All @@ -322,12 +329,14 @@ API Documentation
... </logfile>
... </eventlog>
... """ % (sitezcml, os.path.join(temp_dir, 'Data.fs')))
>>> out.close()
>>>
>>> import sys
>>> old_argv = sys.argv[:]
>>>
>>> script = os.path.join(temp_dir, 'script.py')
>>> _ = open(script, 'w').write(
>>> out = open(script, 'w')
>>> _ = out.write(
... """import sys
... from pprint import pprint
... pprint(debugger)
Expand All @@ -337,6 +346,8 @@ API Documentation
... pprint(__file__)
... pprint(__name__)""")
>>>
>>> out.close()
>>>
>>> sys.argv = ['interactive_debugger', script]
>>> from grokcore.startup import interactive_debug_prompt
>>> try:
Expand Down

0 comments on commit 8a2bdd0

Please sign in to comment.