Ok. used:

 

> def _do_get_provider_count_and_objs(self, **kw):
>                 kw.update({'form': 'platsreview'})

                super(MyAdminConfig.className.table_filler_type, 
> self)._do_get_provider_count_and_objs(kw) 
>
 and got error:

Invalid search query "": _do_get_provider_count_and_objs() takes exactly 1 
> argument (2 given)


 As I am only saving 6 lines of code using super and they are working, I'm 
not spending much time on this.  However, I am interested in how super can 
work as part of 'eternal learning'.


On Wednesday, November 6, 2013 12:31:50 PM UTC-6, Alessandro Molina wrote:
>
> On the global namespace only the outermost class is defined. You need to 
> write full class path in super call: Parent.Child
> Il 06/nov/2013 19:25 "Moritz Schlarb" <[email protected] <javascript:>> 
> ha scritto:
>
>> I assume that you are defining the table_filler_type class within the
>> scope of another class definition (declarative-style), which doesn't
>> work, because of reasons.
>> Happened to me, too, and made me wonder an afternoon long...
>>
>> One solution would be to define the class in the module scope and just
>> reference it, if possible, or you just use the old-school hardcode 
>> variant.
>>
>> Am 06.11.2013 17:13, schrieb Stuart Zurcher:
>> > I'm new to super(). I've tried several ways and failed.  From
>> > documentation, format for super is :
>> >
>> >     super(className, self).method(arg)
>> >
>> > so I tried:
>> >
>> >
>> >             class table_filler_type(TableFiller):
>> >                 __entity__ = Forms
>> >
>> >
>> >                 def _do_get_provider_count_and_objs(self, **kw):
>> >                     kw.update({'form':'platreview'})
>> >                     super(table_filler_type,
>> >     self)._do_get_provider_count_and_objs(kw)
>> >
>> >  which throws table_filler_type undefined error
>> >
>> >
>> >
>> > On Tuesday, November 5, 2013 2:52:15 PM UTC-6, Alessandro Molina wrote:
>> >
>> >     If you just need to add a filter it's probably better to avoid
>> >     issues in the future to just add the kw.update line and then call
>> >     super._do_get_provider_count_and_objs instead of copying the whole
>> >     implementation
>> >
>> >
>> >     On Tue, Nov 5, 2013 at 9:39 PM, Stuart Zurcher <[email protected]
>> >     <javascript:>> wrote:
>> >
>> >         Ok. Found the solution, thanks to Alessandro, and posting for
>> >         others.
>> >         I am using ming with auth quickstarted.
>> >         The following will provide a subset of users with 'plats' in
>> >         _groups of the User entity in my customAdmin.py
>> >         Key line highlighted in bold.  Adjust filter query semantics to
>> >         your ORM provider and needs.
>> >
>> >
>> >             from projectName.model.auth import User, Group, Permission
>> >
>> >             from tgext.admin.mongo import TGMongoAdminConfig
>> >             from tgext.admin.tgadminconfig import 
>> CrudRestControllerConfig
>> >             from tgext.admin.controller import AdminController
>> >
>> >             try:
>> >                 from tgext.crud.utils import SortableTableBase as 
>> TableBase
>> >             except:
>> >                 from sprox.tablebase import TableBase
>> >
>> >             try:
>> >                 from tgext.crud.utils import RequestLocalTableFiller as
>> >             TableFiller
>> >             except:
>> >                 from sprox.fillerbase import TableFiller
>> >             from tg.predicates import in_group
>> >
>> >
>> >             class MyAdminConfig(TGMongoAdminConfig):
>> >                 default_index_template = 
>> "mako:projectName.templates.admin"
>> >
>> >
>> >
>> >                 class user(CrudRestControllerConfig):
>> >                     class table_type(TableBase):
>> >                         __entity__ = User
>> >                         __limit_fields__ = ['display_name',
>> >             'email_address', 'groups']
>> >
>> >                         __url__ = '../user.json' #this just tidies up
>> >             the URL a bit
>> >
>> >                     class table_filler_type(TableFiller):
>> >                         __entity__ = User
>> >                         __limit_fields__ = ['_id', 'display_name',
>> >             'email_address', 'groups']
>> >
>> >
>> >                         def _do_get_provider_count_and_objs(self, **kw):
>> >                             limit = kw.pop('limit', None)
>> >                             offset = kw.pop('offset', None)
>> >                             order_by = kw.pop('order_by', None)
>> >                             desc = kw.pop('desc', False)
>> >                             substring_filters =
>> >             kw.pop('substring_filters', [])
>> >                             *kw.update({'_groups':{'$in': ['plats']}})*
>> >
>> >                             count, objs =
>> >             self.__provider__.query(self.__entity__, limit, offset,
>> >             self.__limit_fields__,
>> >
>> >             order_by, desc, substring_filters=substring_filters,
>> >
>> >             filters=kw)
>> >                             self.__count__ = count
>> >                             return count, objs
>> >
>> >
>> >             class MyAdminController(AdminController):
>> >                 allow_only = in_group('plats',
>> >                                      msg=('DB can only be administered
>> >             by Plat Reiview staff.'))
>> >
>> >
>> >         Saved by the group.
>> >
>> >
>> >
>> >         Thank you for the replies.  I'll revisit this later today or
>> >         tomorrow.  Have a detour project to work on.
>> >         Stuart
>> >
>> >         On Monday, November 4, 2013 8:05:50 AM UTC-6, Stuart Zurcher 
>> wrote:
>> >
>> >             I have been looking around and have not found any
>> >             documentation or examples of providing a subset of the
>> >             entity for admin.
>> >
>> >             I would like to provide all users of a group for that
>> >             group's administrator.  I can hard code the forms but was
>> >             wondering if there is a simpler way with the admin module as
>> >             I have several of these type of instances which a simple
>> >             solution would save considerable time.
>> >
>> >         --
>> >         You received this message because you are subscribed to the
>> >         Google Groups "TurboGears" group.
>> >         To unsubscribe from this group and stop receiving emails from
>> >         it, send an email to [email protected]<javascript:>.
>> >         To post to this group, send email to [email protected]
>> >         <javascript:>.
>> >         Visit this group at http://groups.google.com/group/turbogears
>> >         <http://groups.google.com/group/turbogears>.
>> >         For more options, visit 
>> https://groups.google.com/groups/opt_out
>> >         <https://groups.google.com/groups/opt_out>.
>> >
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "TurboGears" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an email to [email protected] <javascript:>.
>> > To post to this group, send email to [email protected]<javascript:>
>> .
>> > Visit this group at http://groups.google.com/group/turbogears.
>> > For more options, visit https://groups.google.com/groups/opt_out.
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "TurboGears" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/turbogears.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to