wsgidav.samples.mysql_dav_provider#

Description

Implementation of a WebDAV provider that provides a very basic, read-only resource layer emulation of a MySQL database.

This module is specific to the WsgiDAV application. It provides a classes MySQLBrowserProvider.

Usage:

(see docs/sample_wsgidav.yaml)
MySQLBrowserProvider(host, user, passwd, db)

host - host of database server
user - user_name to access database
passwd - passwd to access database
db - name of database on database server

The MySQLBrowserProvider provides a very basic, read-only resource layer emulation of a MySQL database. It provides the following interface:

  • the root collection shared consists of collections that correspond to table names

  • in each table collection, there is a resource called “_ENTIRE_CONTENTS”. This is a non-collection resource that returns a csv representation of the entire table

  • if the table has a single primary key, each table record will also appear as a non-collection resource in the table collection using the primary key value as its name. This resource returns a csv representation of the record and will also include the record attributes as live properties with attribute name as property name and table name suffixed with colon as the property namespace

This is a very basic interface and below is a by no means thorough summary of its limitations:

  • Really only supports having numbers or strings as primary keys. The code uses a numeric or string comparison that may not hold up if the primary key is a date or some other datatype.

  • There is no handling for cases like BLOBs as primary keys or such. Well, there is no handling for BLOBs in general.

  • When returning contents, it buffers the entire contents! A bad way to return large tables. Ideally you would have a FileMixin that reads the database even as the application reads the file object….

  • It takes too many database queries to return information. Ideally there should be some sort of caching for metadata at least, to avoid unnecessary queries to the database.

Classes

MySQLBrowserProvider(host, user, passwd, db)

MySQLBrowserResource(provider, path, ...)

Represents a single existing DAV resource instance.

Other Members

HTTP_FORBIDDEN

int([x]) -> integer int(x, base=10) -> integer

PRECONDITION_CODE_ProtectedProperty

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str