~moovida-developers/storm/elisa_twisted

« back to all changes in this revision

Viewing changes to storm/twisted/store.py

  • Committer: Florian Boucault
  • Date: 2009-05-12 23:45:30 UTC
  • Revision ID: kaleo@eva-20090512234530-6f6ih1rr43qr0z8d
'get' method now automatically resolves lazy values.
'add' method does not automatically resolve lazy values anylonger.

Show diffs side-by-side

added added

removed removed

Lines of Context:
162
162
        self.store = store
163
163
        # Maybe not ?
164
164
        self.store._deferredStore = self
165
 
        for methodName in ("get", "commit", "flush", "remove", "reload",
 
165
        for methodName in ("add", "commit", "flush", "remove", "reload",
166
166
                           "rollback"):
167
167
            method = partial(self.thread.defer_to_thread,
168
168
                             getattr(self.store, methodName))
191
191
            self.store._resolve_lazy_value(obj_info, None, AutoReload)
192
192
        self.store.unblock_implicit_flushes()
193
193
 
194
 
    def add(self, obj):
195
 
        """
196
 
        Specific add method that automatically resolve lazy values.
197
 
        """
198
 
        def _add():
199
 
            result = self.store.add(obj)
 
194
    def get(self, cls, key):
 
195
        """
 
196
        Specific get method that automatically resolve lazy values.
 
197
        """
 
198
        def _get():
 
199
            result = self.store.get(cls, key)
200
200
            if result is not None:
201
201
                obj_info = get_obj_info(result)
202
202
                self.store._resolve_lazy_value(obj_info, None, AutoReload)
203
203
            return result
204
 
        return self.thread.defer_to_thread(_add)
 
204
        return self.thread.defer_to_thread(_get)
205
205
 
206
206
 
207
207
    def execute(self, *args, **kwargs):