X-Git-Url: http://git.veekun.com/zzz-floof.git/blobdiff_plain/c03a740f65ea24ba6567b0ef75f3785faae37d42..42398bc94b95b5a115396f14c3c1dde6fb6808a5:/floof/websetup.py diff --git a/floof/websetup.py b/floof/websetup.py index 7caeed0..06c0e9c 100644 --- a/floof/websetup.py +++ b/floof/websetup.py @@ -10,22 +10,40 @@ from pylons import config from elixir import * from floof import model as model +import os + def setup_app(command, conf, vars): """Place any commands to setup floof here""" load_environment(conf.global_conf, conf.local_conf) - model.metadata.create_all() - # Initialisation here ... this sort of stuff: + ### Database schema + model.metadata.create_all() + ### Sample data # Users - identity_url = IdentityURL(url=u'http://eevee.livejournal.com/') - user = User(name=u'Eevee') - user.identity_urls.append(identity_url) + from floof.model.users import IdentityURL, User + if not User.query.filter_by(name=u'eevee').count(): + identity_url = IdentityURL(url=u'http://eevee.livejournal.com/') + user = User(name=u'eevee') + user.identity_urls.append(identity_url) - - # some_entity = model.Session.query(model..).get(1) - # e.g. foo = model.Session.query(model.identity.User).get(1) - # from datetime import datetime - # some_entity.poked_on = datetime.now() - # model.Session.add(some_entity) model.Session.commit() + + ### Filesystem stuff + # Only necessary if we're using the filesystem for storage. + # And we are! + art_path = os.path.join(config['app_conf']['static_root'], 'art') + # Test that we can write to the art directory + if os.access(art_path, os.W_OK | os.X_OK): + # Create directories for various image sizes + for subdir in ['original', 'medium', 'thumbnail']: + path = os.path.join(art_path, subdir) + # If it exists, it should be writeable. If not, create it. + if os.path.exists(path): + if not os.access(path, os.W_OK | os.X_OK): + print "*** WARNING: Can't write to the art/{0} " \ + "directory!".format(subdir) + continue + os.makedirs(path) + else: + print "*** WARNING: Can't write to the art directory!"