Project

General

Profile

Feature #573

mongo support in uweb, sqltalk and model

Added by Jan Klopper over 12 years ago. Updated about 12 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Elmer de Looff
Category:
Model
Target version:
-
Start date:
2011-12-29
Due date:
% Done:

100%

Estimated time:
Spent time:

Description

We need to be able to talk to mongo databases.

I suggest we allow uweb to read the config file for settings, and setup a connection on the self.connection var, or possibly on self.connections['mongo'] and self.connections['mysql'] if two or more db types are being connected.

We should then be able to use mongo in the models which should be less of a technical challange as mysql was, as mongo returns nice dict like structures for the databases collection, the 'tables' and its records. Type translation is not needed, as the pymongo module already takes care of that. (including timezome aware or unaware datetime objects based in a connection flag)

I'd be super awesome if a model would 'know' to what kind of database its connected and automatically selects the right 'sqltalk' backend and connection to fetch/store its data. that way we could mix/match models from various databases.

Associated revisions

Revision 156:da0ec0c3dad0 (diff)
Added by Elmer de Looff over 12 years ago

Added a class for MongoDB record abstraction. Also improved upon a few minor things in the base Record. This completes part of issue #573.

History

#1 Updated by Elmer de Looff over 12 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 30

The uweb.model now has a MongoRecord class that implements the basic Create/Save/List/Load methods in a manner consistent with the relational one.

The model will need a proper BaseRecord class to take care of some lower level abstractions, because the current extension of MongoRecord is haphazard in a way that it has to disable some of the relational-loading.

#2 Updated by Elmer de Looff about 12 years ago

  • Status changed from In Progress to Resolved
  • Assignee changed from Elmer de Looff to Jan Klopper
  • % Done changed from 30 to 70

MongoDB support has been integrated in uWeb. There is now a new mixin class in the pagemaker module, called MongoMixin which provides a mongo property. When a mongo config entry is found, the given 'host' and 'port' will be used, or fall back to the MongoDB defaults. A database can be specified with the 'database' keyword.

Also added to the pagemaker module is the SmorgasbordMixin which will provide a bord property that automatically loads the correct database connection for Record classes. This will also work for direct MySQL access from the pagemaker (though this in itself is discouraged).

N.B. For Smorgasbord to work with MongoDB connections, it is important to still add MongoMixin to the PageMaker MRO.

#3 Updated by Jan Klopper about 12 years ago

  • Status changed from Resolved to Closed
  • Assignee changed from Jan Klopper to Elmer de Looff
  • % Done changed from 70 to 100

Works like a charm, cheers!

Also available in: Atom PDF