Feature proposal: includeme feature for classes (not only modules)

2011-12-23 Thread Ahmed
Hello all and merry Christmas

The documentation now says that the includeme callable for
config.include is only to be used if you  are including  modules.

But consider this case:

class MyView(object):
@classmethod
def includeme(cls, config):
config.add_view(cls, route_name='myroute')


I want to do:
config.include('mypackage.views.MyView') .. which would automatically
register the view too.

Is it worth it to add this feature or not?

Cheers,
Ahmed

-- 
You received this message because you are subscribed to the Google Groups 
pylons-devel group.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.



Re: Feature proposal: includeme feature for classes (not only modules)

2011-12-23 Thread Chris McDonough
On Fri, 2011-12-23 at 21:43 -0800, Ahmed wrote:
 Hello all and merry Christmas
 
 The documentation now says that the includeme callable for
 config.include is only to be used if you  are including  modules.
 
 But consider this case:
 
 class MyView(object):
 @classmethod
 def includeme(cls, config):
 config.add_view(cls, route_name='myroute')
 
 
 I want to do:
 config.include('mypackage.views.MyView') .. which would automatically
 register the view too.
 
 Is it worth it to add this feature or not?

No.  If you want to do this:

def incudeme(config):
cls = MyView
... do whatever you want to do with class ...

Rationale: method names are not importable in Python; the include
dotted name must be importable.

- C


 
 Cheers,
 Ahmed
 


-- 
You received this message because you are subscribed to the Google Groups 
pylons-devel group.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.