About proper use of mantissa.sharing...

"Alex Lang" <[email protected]> Sun, 30 Mar 2008 02:00:29 -0700
Newsgroups gmane.comp.python.quotient.dev
Message-ID <[email protected]>
Since I'm returning this ThemedElement (adapted from Foo) from a
renderer, I find myself sometimes doing things like this, which simply
feel wrong:

class Whatever(ThemedElement):
   def renderFoo(self, request, tag):
       # Supposing I want to put this item in the app store...
       _store =
self.original.store.parent.filesdir.child('app').child('Bar.axiom')).open()

       # and whereas userStore is inmemory()... I feel like there's
       # something very wrong with this idiom
       return ixmantissa.INavigableFragment(model.Foo(store=_store,
       					       userStore=self.original.store))
   page.renderer(renderFoo)

class FooElement(ThemedElement):
   def foo(self):
       primaryRole = sharing.getSelfRole(self.original.userStore)
       #of course, the above won't work for the unauthenticated user...

       _query = self.original.store.query(model.Bar)
       return [post.toDict() for post in
               sharing.asAccessibleTo(primaryRole, _query)]
   athena.expose(foo)

components.registerAdapter(
   FooElement,
   model.Foo,
   ixmantissa.INavigableFragment
)

Anyone have suggestions about this?
-- 
Alex