Created
November 5, 2011 18:44
-
-
Save knzm/1341868 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import transaction | |
from hgwiki import models | |
from hgwiki.security import make_digest | |
default_users = [ | |
("pyramid", "pylons") | |
] | |
def setup(env): | |
models.Base.metadata.create_all() | |
if models.DBSession.query(models.User).first() is None: | |
for user_name, password in default_users: | |
digest = make_digest(user_name, password, env['request']) | |
user = models.User(user_name=user_name, password_digest=digest) | |
models.DBSession.add(user) | |
transaction.commit() | |
if __name__ == '__main__': | |
import sys | |
from pyramid.paster import bootstrap | |
if len(sys.argv) > 1: | |
config_uri = sys.argv[1] | |
else: | |
config_uri = 'development.ini' | |
env = bootstrap(config_uri) | |
setup(env) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment