here's a simple patch that does this.

execute web2py with this option:

--developingapps APP[,APP...]

anywhere in your application, you can use the boolean variable
WEB2PY_APP_IS_DEVELOPING.

---cut below this line---

Index: compileapp.py
===================================================================
--- compileapp.py       (revision 680)
+++ compileapp.py       (working copy)
@@ -86,6 +86,7 @@
     environment['SQLField']=SQLField
     environment['SQLFORM']=SQLFORM
     environment['SQLTABLE']=SQLTABLE
+    environment['WEB2PY_APP_IS_DEVELOPING']=request.application in
request.env.devingapps
     response._view_environment=copy.copy(environment)
     return environment

Index: widget.py
===================================================================
--- widget.py   (revision 680)
+++ widget.py   (working copy)
@@ -305,6 +305,9 @@
     parser.add_option('-D', '--debug',
                   dest='debuglevel', default=30, type='int',
                   help='set debug output level (0-100, 0 means all,
100 means none, default is 30)')
+    parser.add_option('', '--developingapps',
+                  dest='devingapps', metavar='APP
[,APP...]',type='string',
+                  help='set the python variable
WEB2PY_APP_IS_DEVELOPING in environments of APP[,APP...]'),
     parser.add_option('-S', '--shell',
                   dest='shell', metavar='APPNAME',
                   help='run web2py in interactive shell or IPython(if
installed) with specified appname')
@@ -356,6 +359,10 @@
         print 'default applications are now installed'
     else:
         print 'default applications appear to be installed already'
+    if options.devingapps:
+      options.devingapps = options.devingapps.split(',')
+    else:
+      options.devingapps = []
     return options, args

 def start():
@@ -422,6 +429,9 @@
         options.password=raw_input('choose a password:')
     if not options.password:
         print 'no password, no admin interface'
+    ### if --developmentapps
+    if len(options.devingapps):
+      print 'the following apps have been flagged as under
development:\n\t%s' % '\n\t'.join(options.devingapps)
     ### start server
     ip,port=options.ip,int(options.port)
     print 'please visit:'
@@ -437,6 +447,7 @@
                       request_queue_size=options.request_queue_size,
                       timeout=options.timeout,
                       shutdown_timeout=options.shutdown_timeout,
-                      path=options.folder)
+                      path=options.folder,
+                      devingapps=options.devingapps)
     try: server.start()
     except KeyboardInterrupt: server.stop()
Index: main.py
===================================================================
--- main.py     (revision 680)
+++ main.py     (working copy)
@@ -289,9 +289,10 @@
     else: file.write('password=None\n')
     file.close()

-def appfactory
(wsgiapp=wsgibase,logfilename='httpsever.log',web2py_path=web2py_path):
+def appfactory
(wsgiapp=wsgibase,logfilename='httpsever.log',web2py_path=web2py_path,devingapps=None):
     def app_with_logging(environ, responder):
         environ['web2py_path']=web2py_path
+        environ['devingapps']=devingapps
         status_headers=[]
         def responder2(s,h):
             status_headers.append(s)
@@ -318,7 +319,8 @@
                  request_queue_size=5,
                  timeout=10,
                  shutdown_timeout=5,
-                 path=web2py_path):
+                 path=web2py_path,
+                 devingapps=None):
         """
         starts the web server.
         """
@@ -328,7 +330,7 @@
         logging.info('starting web server...')
         from contrib.wsgihooks import ExecuteOnCompletion2, callback
         self.server=wsgiserver.CherryPyWSGIServer((ip, port),
-                    appfactory(ExecuteOnCompletion2
(wsgibase,callback),log_filename,web2py_path=path),
+                    appfactory(ExecuteOnCompletion2
(wsgibase,callback),log_filename,web2py_path=path,devingapps=devingapps),
                     numthreads=int(numthreads),
server_name=server_name,
                     request_queue_size=int(request_queue_size),
                     timeout=int(timeout),


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to