module/wizard.sql
module/wizard.sset
module/wizard.tests
+ module/wizard.user
module/wizard.util
Indices and tables
Functions
---------
.. autofunction:: connect
-.. autofunction:: fill_url
+.. autofunction:: auth
--- /dev/null
+:mod:`wizard.user`
+==================
+
+.. automodule:: wizard.user
+
+Functions
+---------
+
+.. autofunction:: quota
Plugins marked with prototype todo messages are not complete yet.
+.. _wizard.strategy:
+
``wizard.strategy``
-------------------
Used during installation to automatically determine values for
installation parameters the user may have omitted.
+.. _wizard.sql.auth:
+
``wizard.sql.auth``
--------------------
Used to fill in a user's database authentication credentials if none are
-able to be determined from an application's configuration files.
+able to be determined from an application's configuration files. Plugin
+should be a function that takes a single required argument ``url``,
+which is a :class:`sqlalchemy.engine.url.URL` with partial
+authentication information, including a database name, and should return either
+``None`` if it was unable to fill in authentication credentials for the
+user, or the completed URL. Mutating the passed argument and then
+returning it is the expected modus operandi of a plugin. The function
+that runs this plugin is :func:`wizard.sql.auth`.
-.. todo:: Prototype
+.. _wizard.deploy.web:
``wizard.deploy.web``
---------------------
takes a single required argument ``dir``, which is the directory to
determint the web URL(s) for, and return a list or generator of
:class:`urlparse.ParseResult` objects or URL strings of possible web locations
-for an application.
+for an application. The function that runs this plugin is
+:func:`wizard.deploy.web`.
+
+.. _wizard.user.email:
``wizard.user.email``
---------------------
.. todo:: Prototype
+.. _wizard.user.operator:
+
``wizard.user.operator``
------------------------
.. todo:: Prototype
+.. _wizard.user.passwd:
+
``wizard.user.passwd``
----------------------
.. todo:: Prototype
+.. _wizard.user.quota:
+
``wizard.user.quota``
---------------------
limit reporting. Plugin should be a function that takes a single
required argument ``dir``, which is the directory to determine the quota
for, and return a tuple ``(quota usage, quota limit)`` or ``(0, None)``
-if it could not determine quota.
+if it could not determine quota. The function that runs this plugin is
+:func:`wizard.user.quota`.
entry_points = {
'wizard.user.quota': 'scripts = wizard_scripts:user_quota',
'wizard.deploy.web': 'scripts = wizard_scripts:deploy_web',
+ 'wizard.sql.auth': 'scripts = wizard_scripts:sql_auth',
}
)
ERROR: Could not parse quota. %s
""" % self.msg
+
+def sql_auth(url):
+ if url.driver == "mysql":
+ try:
+ url.host, url.username, url.password = shell.Shell().eval("/mit/scripts/sql/bin/get-password").split()
+ return url
+ except shell.CallError:
+ pass
+ return None
Attempts to determine the URL a directory would be web-accessible at.
If ``url`` is specified, automatically use it. Returns a generator whic
produces a list of candidate urls.
+
+ This function implements a plugin interface named :ref:`wizard.deploy.web`.
"""
if url:
yield url
def dsn(self):
"""The :class:`sqlalchemy.engine.url.URL` for this deployment."""
if not self._dsn:
- self._dsn = sql.fill_url(self.application.dsn(self))
+ self._dsn = sql.auth(self.application.dsn(self))
return self._dsn
@property
def url(self):
return self._url
except StopIteration:
raise UnknownWebPath
- def enableOldStyleUrls(self):
- """
- Switches to using http://user.scripts.mit.edu/~user/app URLs.
- No effect if they have an explicit .scripts/url override.
- """
- # XXX: This is pretty scripts specific
- self._url = scripts.fill_url(self.location, self.application.url(self), old_style = True)
@staticmethod
def parse(line):
"""
if not isinstance(options.dsn, sqlalchemy.engine.url.URL):
options.dsn = sqlalchemy.engine.url.make_url(options.dsn)
# do some guessing with sql
- options.dsn = sql.fill_url(options.dsn)
+ options.dsn = sql.auth(options.dsn)
# perform some sanity checks on the database
database = options.dsn.database
options.dsn.database = None
if not urls:
raise StrategyFailed
try:
- self._url = urls.next()
+ self._url = urls.next() # pylint: disable-msg=E1101
except StopIteration:
raise StrategyFailed
def execute(self, options):
import sqlalchemy
import os
+import pkg_resources
+import copy
from wizard import shell
meta.reflect()
return meta
-def fill_url(url):
+def auth(url):
"""
If the URL has a database name but no other values, it will
use the global configuration, and then try the database name.
+
+ This function implements a plugin interface named
+ :ref:`wizard.sql.auth`.
"""
if not url:
return None
if any((url.host, url.username, url.password)):
# don't try for defaults if a few of these were set
return url
- # this is hook stuff
- if url.driver == "mysql":
- try:
- url.host, url.username, url.password = shell.Shell().eval("/mit/scripts/sql/bin/get-password").split()
- return url
- except shell.CallError:
- pass
+ for entry in pkg_resources.iter_entry_points("wizard.sql.auth"):
+ func = entry.load()
+ r = func(copy.copy(url))
+ print r
+ if r is not None:
+ return r
env_dsn = os.getenv("WIZARD_DSN")
if env_dsn:
old_url = url
Returns a tuple (quota usage, quota limit). Returns ``(0, None)`` if
the quota usage is unknown. If ``dir`` is omitted, the current
working directory is assumed. Value returned is in bytes.
+
+ This function implements a plugin interface named
+ :ref:`wizard.user.quota`.
"""
if dir is None:
dir = os.getcwd()