summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZiad Sawalha <github@highbridgellc.com>2011-04-21 11:26:08 -0500
committerZiad Sawalha <github@highbridgellc.com>2011-04-21 11:26:08 -0500
commitf98bf5777a1270472e7cd4f7b4badd3cf5e2f8b0 (patch)
tree6a761379dfd59eb0d557014123b216024292de30
parentf7479387cff81c91a7c5cede7c0d511d15dfc269 (diff)
SQL Alchemy additions: Token
-rw-r--r--keystone/db/sqlalchemy/api.py14
-rw-r--r--management/useradd.py6
2 files changed, 17 insertions, 3 deletions
diff --git a/keystone/db/sqlalchemy/api.py b/keystone/db/sqlalchemy/api.py
index 3ceb7f9e..75d7926c 100644
--- a/keystone/db/sqlalchemy/api.py
+++ b/keystone/db/sqlalchemy/api.py
@@ -58,3 +58,17 @@ def user_create(values):
user_ref.update(values)
user_ref.save()
return user_ref
+
+def token_create(values):
+ token_ref = models.Token()
+ token_ref.update(values)
+ token_ref.save()
+ return user_ref
+
+def token_get(id, session=None):
+ if not session:
+ session = get_session()
+ result = session.query(models.Token).filter_by(id=id).first()
+ if not result:
+ raise
+ return result \ No newline at end of file
diff --git a/management/useradd.py b/management/useradd.py
index 4d67cc38..8bab0261 100644
--- a/management/useradd.py
+++ b/management/useradd.py
@@ -14,7 +14,7 @@
# limitations under the License.
import optparse
-from keystone.db.sqlalchemy import api
+import keystone.db.sqlalchemy.api as db_api
from keystone.db.sqlalchemy import models
@@ -33,12 +33,12 @@ def main():
u.email = username
u.password = password
u.enabled = True
- api.user_create(u)
+ db_api.user_create(u)
print 'user', u.id, 'created.'
return
except Exception, e:
- raise #e, ('User %s already exists' % username)
+ print 'Error creating user', u.id, ':', str(e)
if __name__ == '__main__':
main()