diff options
| author | Pierre-Yves Chibon <pingou@pingoured.fr> | 2012-04-24 09:52:39 +0200 |
|---|---|---|
| committer | Pierre-Yves Chibon <pingou@pingoured.fr> | 2012-04-24 09:52:39 +0200 |
| commit | 026cdfc591dfaedc7dcdeb050b9131ae425f85cd (patch) | |
| tree | b983a1e8fa900855ef5c211ae9ca9875c559d956 | |
| parent | 246ae70aef2e8a4657e333d4ce3b7cebb1fd2333 (diff) | |
| download | kittystore-026cdfc591dfaedc7dcdeb050b9131ae425f85cd.tar.gz kittystore-026cdfc591dfaedc7dcdeb050b9131ae425f85cd.tar.xz kittystore-026cdfc591dfaedc7dcdeb050b9131ae425f85cd.zip | |
Start defining the object
| -rw-r--r-- | mmstore.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/mmstore.py b/mmstore.py new file mode 100644 index 0000000..b007da5 --- /dev/null +++ b/mmstore.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- + +""" +mm_store - an object mapper and interface to the mongo database + representation of emails for mailman 3. + +Copyright (C) 2012 Pierre-Yves Chibon +Author: Pierre-Yves Chibon <pingou@pingoured.fr> + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. +See http://www.gnu.org/copyleft/gpl.html for the full text of the +license. +""" + +from ming import Session, Document, Field, schema +from ming.datastore import DataStore + +from datetime import datetime + + + + + +class MMStore(Document): + """ Object representation of the information stored for every email + in the mongo database. + + This class is the interface used to read and write to the database + any email it contains. + """ + + class __mongometa__: + """ Meta information required for the class """ + session = session + name = 'mailman_email' + + _id = Field(schema.ObjectId) + From = Field(str) + Content = Field(str) + Date = Field(datetime) + + def __init__(self, database, host='localhost', port='27017'): + self.bind = DataStore('mongodb://%s:%s/' %(host, port), + database=database) + self.session = Session(bind) + +if __name__ == '__main__': + store = MMStore('devel') + print store + |
