Changeset 200
- Timestamp:
- 08/24/08 09:05:11 (10 months ago)
- Location:
- trunk
- Files:
-
- 1 removed
- 3 modified
- 4 moved
-
shakespeare.egg-info/paste_deploy_config.ini_tmpl (modified) (2 diffs)
-
shakespeare/__init__.py (modified) (2 diffs)
-
shakespeare/cli.py (modified) (11 diffs)
-
shakespeare/index_test.py (deleted)
-
shakespeare/tests/test_cache.py (moved) (moved from trunk/shakespeare/cache_test.py)
-
shakespeare/tests/test_format.py (moved) (moved from trunk/shakespeare/format_test.py)
-
shakespeare/tests/test_gutenberg.py (moved) (moved from trunk/shakespeare/gutenberg_test.py)
-
shakespeare/tests/test_textutils.py (moved) (moved from trunk/shakespeare/textutils_test.py)
Legend:
- Unmodified
- Added
- Removed
-
trunk/shakespeare.egg-info/paste_deploy_config.ini_tmpl
r169 r200 47 47 set debug = false 48 48 49 # using sqlite in memory leads to thread issues when using db ... 50 # sqlobject.dburi = sqlite:///:memory: 51 sqlobject.dburi = postgres://<username>:<password>@localhost/<your-dbname> 49 # We use sqlalchemy to connect and work with databases. 50 # This default config using sqlite. 51 sqlalchemy.url = sqlite:///%(here)s/shkspr.db 52 # This is for postgres (obviously change the values to those for your system) 53 # sqlalchemy.url = postgres://<username>:<password>@localhost/<your-dbname> 52 54 53 55 # Logging configuration … … 74 76 format = %(asctime)s %(levelname)-5.5s [%(name)s] %(message)s 75 77 76 77 [misc]78 # directory where we can store all local copies of texts79 cachedir = ./cache80 81 [db]82 # sqlobject database uri. see sqlobject documentation for details83 # uri = postgres://user:pass@host/dbname84 uri = sqlite:/:memory:85 86 [web]87 # directory where the templates used by web front end are kept88 template_dir = ./src/shakespeare/template89 90 [annotater]91 # url at which marginalia files (css/js etc) should be mounted92 marginalia_prefix = /marginalia -
trunk/shakespeare/__init__.py
r185 r200 81 81 Run:: 82 82 83 $ shakespeare-admin db create84 83 $ shakespeare-admin db init 85 84 … … 121 120 __application_name__ = 'shakespeare' 122 121 123 def conf():122 def register_config(config_path): 124 123 import os 125 defaultPath = os.path.abspath('./development.ini') 126 envVarName = __application_name__.upper() + 'CONF' 127 confPath = os.environ.get(envVarName, defaultPath) 128 if not os.path.exists(confPath): 129 raise ValueError('No Configuration file exists at: %s' % confPath) 130 131 # register the config 124 # TODO: remove? 2008-08-24 not mentioned in docs any more 125 # envVarName = __application_name__.upper() + 'CONF' 126 # config_path = os.environ.get(envVarName, '') 127 config_path = os.path.abspath(config_path) 132 128 import paste.deploy 129 pasteconf = paste.deploy.appconfig('config:' + config_path) 133 130 import shakespeare.config.environment 134 pasteconf = paste.deploy.appconfig('config:' + confPath)135 136 131 shakespeare.config.environment.load_environment(pasteconf.global_conf, 137 132 pasteconf.local_conf) 133 134 135 # TODO: rename to get_config() 136 def conf(): 138 137 from pylons import config 139 138 conf = config 140 141 # import ConfigParser142 # conf = ConfigParser.SafeConfigParser()143 # conf.read(confPath)144 145 139 return conf 146 140 -
trunk/shakespeare/cli.py
r194 r200 10 10 """ 11 11 12 def __init__(self, verbose=False):12 def __init__(self, config=None, verbose=False): 13 13 # cmd.Cmd is not a new style class 14 14 cmd.Cmd.__init__(self) 15 self.config = config 15 16 self.verbose = verbose 16 17 … … 19 20 print msg 20 21 21 prompt = 'The Bard > ' 22 23 def run_interactive(self, line=None): 24 """Run an interactive session. 25 """ 26 print 'Welcome to shakespeare-admin interactive mode\n' 27 self.do_about() 28 print 'Type: "?" or "help" for help on commands.\n' 29 while 1: 30 try: 31 self.cmdloop() 32 break 33 except KeyboardInterrupt: 34 raise 22 def _register_config(self): 23 import sys 24 if not self.config: 25 msg = 'No configuration file has been specified. See -h help for details' 26 print msg 27 sys.exit(1) 28 import shakespeare 29 shakespeare.register_config(self.config) 35 30 36 31 def do_help(self, line=None): … … 59 54 60 55 def do_db(self, line=None): 61 actions = [ 'create', 'clean', ' rebuild', 'init' ]56 actions = [ 'create', 'clean', 'init' ] 62 57 if line is None or line not in actions: 63 58 self.help_db() 64 59 return 1 60 self._register_config() 65 61 import shakespeare.model 62 import shakespeare 66 63 if line == 'init': 67 64 import pkg_resources … … 69 66 meta = pkg_resources.resource_stream(pkg, 'texts/metadata.txt') 70 67 shakespeare.model.Material.load_from_metadata(meta) 71 else: 68 elif line == 'clean': 69 config = shakespeare.conf() 70 shakespeare.model.metadata.drop_all(bind=config['pylons.g'].sa_engine) 71 elif line == 'create': 72 72 print 'To create db use paster: paster setup-app {config-file}' 73 else: 74 print self.help_db() 73 75 74 76 def help_db(self, line=None): … … 79 81 80 82 def do_gutenberg(self, line=None): 83 self._register_config() 81 84 import shakespeare.gutenberg 82 85 helper = shakespeare.gutenberg.Helper(verbose=True) … … 109 112 110 113 def help_moby(self, line=None): 114 self._register_config() 111 115 usage = \ 112 116 ''' … … 115 119 116 120 def _init_index(self): 121 self._register_config() 117 122 import shakespeare.index 118 123 self._index = shakespeare.index.all … … 185 190 186 191 def do_search(self, line): 192 self._register_config() 187 193 import shakespeare.search 188 194 index = shakespeare.search.SearchIndex.default_index() … … 232 238 233 239 def do_stats(self, line): 240 self._register_config() 234 241 action, extra = self._parse_line(line) 235 242 … … 277 284 '''%prog [options] <command> 278 285 279 Run about or help for details.''' 286 For list of the commands available run: 287 288 $ shakespeare-admin help 289 290 For more general information run the about or info commands.''' 280 291 parser = optparse.OptionParser(usage) 281 292 parser.add_option('-v', '--verbose', dest='verbose', help='Be verbose', 282 293 action='store_true', default=False) 294 parser.add_option('-c', '--config', dest='config', 295 help='Path to config file', default=None) 283 296 options, args = parser.parse_args() 284 297 … … 287 300 return 1 288 301 else: 289 cmd = ShakespeareAdmin(verbose=options.verbose )302 cmd = ShakespeareAdmin(verbose=options.verbose, config=options.config) 290 303 args = ' '.join(args) 291 304 args = args.replace('-','_')
