Objects Visibility
It is not possible to publish a module. Either an object within the module is present in the URI or the module has an index function. Otherwise the Publisher will return a "404 Not Found" to the client. If the next script is saved as my_module.py the only way to execute it is:
http://my_site.tld/dir/path/my_module/main
http://my_site.tld/dir/path/my_module.py/main
Global variables are also visible:
http://my_site.tld/dir/path/my_module.py/s
http://my_site.tld/dir/path/my_module/s
s = """\ <html><body> <h2>I can't be published as a module!</h2> </body></html> """ def main(): return s main()
Only the objects inside the module are visible. It is not possible to call the module like:
http://my_site.tld/dir/path/my_module
http://my_site.tld/dir/path/my_module.py
Hide objects from the web
As objects inside a module can be published it may be necessary to hide some of them. If an object name starts with an underscore it will be hidden from the web.
# The _s variable is not visible _s = """\ <html><body> <h2>%s</h2> </body></html> """ def f(): x = 'y' return _s % 'f() function' # The v variable is visible v = _s % 'v variable'
In the example above the _s variable is not visible, that is it can't be shown with:
http://my_site.tld/dir/path/objects.py/_s