tgext.pluggable

22 views
Skip to first unread message

Luca Verardi

unread,
Sep 4, 2012, 5:40:54 AM9/4/12
to turbo...@googlegroups.com
Hello everybody,
I am using TG 2.2.0 and tgext.pluggable 0.0.8
I would like to load some plugins listed in my development.ini. I tried this:

development.ini

[app:main]
...
...
plugins= plugin1, plugin2

app_cfg.py:

from tg import config
from tgext.pluggable import plug
for plugin in config.get('plugins').split(','):
    plug(base_config, plugin)

TG2 returns this error  AttributeError: 'NoneType' object has no attribute 'split'.

Thanks for your support

Alessandro Molina

unread,
Sep 4, 2012, 8:45:40 AM9/4/12
to turbo...@googlegroups.com
inside app_cfg the development.ini has not yet been loaded, that is
the reason why you don't have the options you specified inside your
app_cfg.
As Configuration files are meant to replace the options inside the
app_cfg they are loaded after the app_cfg.

A possible solution is to load the plugins list from an .ini file
inside the app_cfg.py file and then load them.
The actual ini file can also be the development.ini itself.

PS: The current tgext.pluggable has a minor issue with TG2.2 which
might cause some controller methods to not be registered. It will be
fixed with a new pluggable release during this week. In the mean time
if you see that some methods of the controllers you are plugging are
missing you can set tg.config['renderers'] = base_config.renderers
inside the app_cfg before loading the pluggables themselves.
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/turbogears/-/onmsc6yAKgkJ.
> To post to this group, send email to turbo...@googlegroups.com.
> To unsubscribe from this group, send email to
> turbogears+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/turbogears?hl=en.

Luca Verardi

unread,
Sep 4, 2012, 9:16:41 AM9/4/12
to turbo...@googlegroups.com
I found another solution...
In the app_cfg.py i wrote:

for plugin in ['plugin_example1','plugin_example2','...']: # All my plugins
    try:
        plug(base_config, plugin) # if plug function finds a .egg or a module
    except:
        log.info("Plugin %s doesn't exist or hasn't been loaded "%plugin)
Reply all
Reply to author
Forward
0 new messages