Skip to content

Instantly share code, notes, and snippets.

@knzm
Created November 5, 2011 18:44
Show Gist options
  • Save knzm/1341868 to your computer and use it in GitHub Desktop.
Save knzm/1341868 to your computer and use it in GitHub Desktop.
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