Merge branch 'kovidgoyal/master'

This commit is contained in:
Charles Haley 2013-08-23 15:33:09 +02:00
commit 2015762650
4 changed files with 2948 additions and 11 deletions

2928
src/apsw_shell.py Normal file

File diff suppressed because it is too large Load diff

View file

@ -988,9 +988,10 @@ def dump_and_restore(self, callback=None, sql=None):
uv = int(self.user_version)
if sql is None:
from apsw_shell import Shell
callback(_('Dumping database to SQL') + '...')
buf = StringIO()
shell = apsw.Shell(db=self.conn, stdout=buf)
shell = Shell(db=self.conn, stdout=buf)
shell.process_command('.dump')
sql = buf.getvalue()

View file

@ -581,3 +581,13 @@ def test_invalidate():
cache.add_format(1, 'ADD', BytesIO(b'xxxx'))
test_invalidate()
# }}}
def test_dump_and_restore(self): # {{{
' Test roundtripping the db through SQL '
cache = self.init_cache()
all_ids = cache.all_book_ids()
cache.dump_and_restore()
self.assertEqual(cache.set_field('title', {1:'nt'}), set([1]), 'database connection broken')
cache = self.init_cache()
self.assertEqual(cache.all_book_ids(), all_ids, 'dump and restore broke database')
# }}}

View file

@ -28,7 +28,7 @@
from calibre import prints, as_unicode
class DispatchController(object): # {{{
class DispatchController(object): # {{{
def __init__(self, prefix, wsgi=False, auth_controller=None):
self.dispatcher = cherrypy.dispatch.RoutesDispatcher()
@ -71,7 +71,7 @@ def __getattr__(self, attr):
# }}}
class BonJour(SimplePlugin): # {{{
class BonJour(SimplePlugin): # {{{
def __init__(self, engine, port=8080, prefix=''):
SimplePlugin.__init__(self, engine)
@ -88,7 +88,6 @@ def mdns_services(self):
{'path':self.prefix+'/opds'}),
]
def start(self):
zeroconf_ip_address = verify_ipV4_address(self.ip_address)
try:
@ -110,7 +109,6 @@ def stop(self):
cherrypy.log.error('Failed to stop BonJour:')
cherrypy.log.error(traceback.format_exc())
stop.priority = 10
cherrypy.engine.bonjour = BonJour(cherrypy.engine)
@ -161,9 +159,9 @@ def __init__(self, db, opts, embedded=False, show_tracebacks=True,
'request.show_tracebacks': show_tracebacks,
'server.socket_host' : listen_on,
'server.socket_port' : opts.port,
'server.socket_timeout' : opts.timeout, #seconds
'server.thread_pool' : opts.thread_pool, # number of threads
'server.shutdown_timeout': st, # minutes
'server.socket_timeout' : opts.timeout, # seconds
'server.thread_pool' : opts.thread_pool, # number of threads
'server.shutdown_timeout': st, # minutes
})
if embedded or wsgi:
cherrypy.config.update({'engine.SIGHUP' : None,
@ -173,9 +171,9 @@ def __init__(self, db, opts, embedded=False, show_tracebacks=True,
self.exception = None
auth_controller = None
self.users_dict = {}
#self.config['/'] = {
# self.config['/'] = {
# 'tools.sessions.on' : True,
# 'tools.sessions.timeout': 60, # Session times out after 60 minutes
# 'tools.sessions.timeout': 60, # Session times out after 60 minutes
#}
if not wsgi:
@ -187,7 +185,7 @@ def __init__(self, db, opts, embedded=False, show_tracebacks=True,
'text/xml', 'text/javascript', 'text/css'],
}
if opts.password:
if opts.username and opts.password:
self.users_dict[opts.username.strip()] = opts.password.strip()
auth_controller = AuthController('Your calibre library',
self.users_dict)