Plugin based feature adding to web-application

limodou limodou at gmail.com
Fri Mar 13 08:37:18 EDT 2009


On Fri, Mar 13, 2009 at 8:31 PM, Ravi Kumar <ra21vi at gmail.com> wrote:
> I need an architecture in a project using Django and Python + MySQL, so that
> when I put a python script in specified directory, that should be loaded and
> its methods/functions can be used.
> As far as i have thought on this, I am going to scan that particular
> directory,  list out the files, import them if they exists,
>
> NOw I need the functions list defined in that module. Is there any way to
> get it. I also need to find which class in defined in that python file.
> Please suggest me over architectures and best practices. Any suggestion
> would be really helpful.
>
> Thanks
> Rav!
>

When you import the plugin file, and you can use dir() to get all
attributes, and use callable() to test if the object can be invoked,
or use types.FunctionType to test if an object is a function, or you
can specified certain prefix just like: "do_", etc.

-- 
I like python!
UliPad <<The Python Editor>>: http://code.google.com/p/ulipad/
UliWeb <<simple web framework>>: http://uliwebproject.appspot.com
My Blog: http://hi.baidu.com/limodou



More information about the Python-list mailing list