X-Git-Url: http://git.veekun.com/zzz-floof.git/blobdiff_plain/f4a6882d2cdb1baeb2c4662b1c305b99d7596cae..dcf6146e9914ff3c166f242b72f04a8934d65148:/floof/websetup.py?ds=sidebyside diff --git a/floof/websetup.py b/floof/websetup.py index fa97149..815832d 100644 --- a/floof/websetup.py +++ b/floof/websetup.py @@ -1,25 +1,49 @@ +# -*- coding: utf-8 -*- """Setup the floof application""" -import elixir import logging from floof.config.environment import load_environment -from floof.model import meta -from floof.model.users import IdentityURL, User log = logging.getLogger(__name__) +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) - # Create the tables if they don't already exist - elixir.create_all(bind=meta.engine, checkfirst=False) - - ### Load some basic data + ### Database schema + model.metadata.create_all() + ### Sample data # Users + from floof.model.users import IdentityURL, User identity_url = IdentityURL(url=u'http://eevee.livejournal.com/') user = User(name=u'Eevee') user.identity_urls.append(identity_url) - elixir.session.commit() + 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!"