anyone?
this is what i did so far, in my model module store.py :

from ming import schema as s, Field
from ming.odm import FieldProperty, ForeignIdProperty, RelationProperty
from ming.odm import Mapper
from ming.odm.declarative import MappedClass
from ming import fs
from tgming import SynonymProperty, ProgrammaticRelationProperty
import os
from session import DBSession

BookFile = fs.filesystem('books',DBSession.impl,)

class Book(MappedClass):
"""
Book definition.
"""
class __mongometa__:
session = DBSession
name = 'books'
unique_indexes = [('title',),('author',),]

_id = FieldProperty(s.ObjectId)
title = FieldProperty(s.String)
author = FieldProperty(s.String)
isbn = FieldProperty(s.String)
vendor = FieldProperty(s.String)
_file = FieldProperty(s.ObjectId)

def _get_file(self):
return BookFile.m.find(dict(_id=self._file)).one()
def _set_file(self, name, data):
f = BookFile.m.put(name,data)
self._file = f

bookf = SynonymProperty(_get_file, _set_file)

As you can see, the fs.filesystem can't take an ODMSession 
(ThreadLocalODMSession in this case),
so i have to drop down to basic ming Session class by doing DBSession.impl,
what i'm worried is, Turbogears has been using ThreadLocalODMSession to 
adapt to multi-threaded environment,
but what i'm doing above is giving the GridFS Connection the non 
thread-safe Session,
is that okay?
how should i do this correctly/safely ?
Anyhelp would be appreciated,
Thanks :)

On Saturday, August 4, 2012 7:03:50 PM UTC+7, Panjie Setiawan Wicaksono 
wrote:
>
> Hi all,
> is there anywhere i can read about using GridFS with Ming in TG2 ?
> Ming supports GridFS start from 0.3 version, and i've used this in several 
> apps so far, but can't find any documentation of how to use GridFS with 
> Ming,
> Any help would be appreciated, thanks :)
>

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/turbogears/-/BYjT8GCl6eoJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.

Reply via email to