Changeset 011b62a47184e1bb7fa6ac18537b4d44f7aee723


Ignore:
Timestamp:
30.07.2013 15:41:38 (8 years ago)
Author:
Stanislaw Klekot <dozzie@…>
Branches:
b66903eafbcb1d49112014abc82c8bf683413db0
Children:
7cc4befbdc1bdcef6dfa6160033966dc9fc1c62d
Parents:
b0f5fda553d200c90df5f2e38dfce0fff17c4396
git-author:
Stanislaw Klekot <dozzie@…> (30.07.2013 15:41:38)
git-committer:
Stanislaw Klekot <dozzie@…> (30.07.2013 15:41:38)
Message:

Moved plugins to a separate directory.

Files:
2 edited
3 moved

Legend:

Unmodified
Added
Removed
  • dashwiki/plugins/__init__.py

    rb0f5fd r011b62  
    11#!/usr/bin/python 
    22 
    3 import os 
    43from dashwiki.plugins.ProtocolPlugin import ProtocolPlugin 
    54 
     
    1110_protocols = {} 
    1211def refresh_plugins(): 
    13   plugindir = __file__[0:__file__.rfind('/')] 
     12  def load_from_directory(directory): # {{{ 
     13    import os 
     14    for f in os.listdir(directory): 
     15      if not f.endswith('.py') or f.startswith('_') or f.startswith('.'): 
     16        continue 
    1417 
    15   for f in os.listdir(plugindir): 
    16     if not f.endswith('.py') or f.startswith('_') or f.startswith('.'): 
    17       continue 
     18      tmp = {} 
     19      execfile("%s/%s" % (directory, f), tmp, tmp) 
    1820 
    19     tmp = {} 
    20     execfile("%s/%s" % (plugindir, f), {}, tmp) 
     21      for symbol in tmp: 
     22        # FIXME: isinstance() didn't want to work if plugins were in the same 
     23        # file 
     24        #if isinstance(tmp[symbol], ProtocolPlugin): 
     25        if hasattr(tmp[symbol], 'protocols'): 
     26          for proto in tmp[symbol].protocols(): 
     27            _protocols[proto] = tmp[symbol] 
     28  # }}} 
    2129 
    22     for symbol in tmp: 
    23       # FIXME: isinstance() didn't want to work if plugins were in the same 
    24       # file 
    25       #if isinstance(tmp[symbol], ProtocolPlugin): 
    26       if hasattr(tmp[symbol], 'protocols'): 
    27         for proto in tmp[symbol].protocols(): 
    28           _protocols[proto] = tmp[symbol] 
     30  from django.conf import settings 
     31  for d in settings.DASHWIKI_PLUGINS_DIR: 
     32    load_from_directory(d) 
    2933 
     34# load the plugins while loading the module itself 
    3035refresh_plugins() 
    3136 
  • dashwiki/settings.py

    r7e6398 r011b62  
    88# Logging configuration file (YAML or JSON, use appropriate extension) 
    99DASHWIKI_LOGGING_CONFIG = '%s/examples/logging.yaml' % (app_root_dir) 
     10 
     11# plugins (protocol support and similar) 
     12DASHWIKI_PLUGINS_DIR = ( 
     13  '%s/plugins' % (app_root_dir), 
     14) 
    1015 
    1116DEBUG = True 
Note: See TracChangeset for help on using the changeset viewer.