admin
Module¶
Utility functions for the Admin application¶
-
gluon.admin.
apath
(path='', r=None)[source]¶ Builds a path inside an application folder
Parameters: - path (str) – path within the application folder
- r – the global request object
-
gluon.admin.
app_cleanup
(app, request)[source]¶ Removes session, cache and error files
Parameters: - app (str) – application name
- request – the global request object
Returns: True if everything went ok, False otherwise
-
gluon.admin.
app_compile
(app, request)[source]¶ Compiles the application
Parameters: - app (str) – application name
- request – the global request object
Returns: None if everything went ok, traceback text if errors are found
-
gluon.admin.
app_create
(app, request, force=False, key=None, info=False)[source]¶ Create a copy of welcome.w2p (scaffolding) app
Parameters: - app (str) – application name
- request – the global request object
-
gluon.admin.
app_install
(app, fobj, request, filename, overwrite=None)[source]¶ Installs an application:
- Identifies file type by filename
- Writes fobj contents to the ../deposit/ folder
- Calls w2p_unpack() to do the job.
Parameters: - app (str) – new application name
- fobj (obj) – file object containing the application to be installed
- request – the global request object
- filename (str) – original filename of the fobj, required to determine extension
- overwrite (bool) – force overwrite of existing application
Returns: name of the file where app is temporarily stored or None on failure
-
gluon.admin.
app_pack
(app, request, raise_ex=False, filenames=None)[source]¶ Builds a w2p package for the application
Parameters: - app (str) – application name
- request – the global request object
Returns: filename of the w2p file or None on error
-
gluon.admin.
app_pack_compiled
(app, request, raise_ex=False)[source]¶ Builds a w2p bytecode-compiled package for the application
Parameters: - app (str) – application name
- request – the global request object
Returns: filename of the w2p file or None on error
-
gluon.admin.
app_uninstall
(app, request)[source]¶ Uninstalls the application.
Parameters: - app (str) – application name
- request – the global request object
Returns: True on success, False on failure
-
gluon.admin.
check_new_version
(myversion, version_url)[source]¶ Compares current web2py’s version with the latest stable web2py version.
Parameters: - myversion – the current version as stored in file web2py/VERSION
- version_URL – the URL that contains the version of the latest stable release
Returns: state, version
- state : True if upgrade available, False if current version is up-to-date, -1 on error
- version : the most up-to-version available
Return type: tuple
-
gluon.admin.
plugin_install
(app, fobj, request, filename)[source]¶ Installs a plugin:
- Identifies file type by filename
- Writes fobj contents to the ../deposit/ folder
- Calls w2p_unpack_plugin() to do the job.
Parameters: - app (str) – new application name
- fobj – file object containing the application to be installed
- request – the global request object
- filename – original filename of the fobj, required to determine extension
Returns: name of the file where plugin is temporarily stored or False on failure
-
gluon.admin.
plugin_pack
(app, plugin_name, request)[source]¶ Builds a w2p package for the plugin
Parameters: - app (str) – application name
- plugin_name (str) – the name of the plugin without plugin_ prefix
- request – the current request app
Returns: filename of the w2p file or False on error
-
gluon.admin.
unzip
(filename, dir, subfolder='')[source]¶ Unzips filename into dir (.zip only, no .gz etc)
Parameters: - filename (str) – archive
- dir (str) – destination
- subfolder (str) – if != ‘’ unzips only files in subfolder
-
gluon.admin.
upgrade
(request, url='http://web2py.com')[source]¶ Upgrades web2py (src, osx, win) if a new version is posted. It detects whether src, osx or win is running and downloads the right one
Parameters: - request – the current request object (required to determine version and path)
- url – the incomplete url where to locate the latest web2py (actual url is url+’/examples/static/web2py_(src|osx|win).zip’)
- Returns
tuple: completed, traceback
- completed: True on success, False on failure (network problem or old version)
- traceback: None on success, raised exception details on failure