Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
ZKAPAuthorizer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Administrator
ZKAPAuthorizer
Commits
db5750c4
Unverified
Commit
db5750c4
authored
5 years ago
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
Remove some duplication in token insertion implementations
parent
1a6e2aed
Branches
Branches containing commit
No related tags found
1 merge request
!128
Add an interface for inserting tokens
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/_zkapauthorizer/model.py
+15
-11
15 additions, 11 deletions
src/_zkapauthorizer/model.py
with
15 additions
and
11 deletions
src/_zkapauthorizer/model.py
+
15
−
11
View file @
db5750c4
...
@@ -308,13 +308,9 @@ class VoucherStore(object):
...
@@ -308,13 +308,9 @@ class VoucherStore(object):
in
refs
in
refs
)
)
@with_cursor
def
_insert_unblinded_tokens
(
self
,
cursor
,
unblinded_tokens
):
def
insert_unblinded_tokens
(
self
,
cursor
,
unblinded_tokens
):
"""
"""
Store some unblinded tokens, for example as part of a backup-restore
Helper function to really insert unblinded tokens into the database.
process.
:param list[unicode] unblinded_tokens: The unblinded tokens to store.
"""
"""
cursor
.
executemany
(
cursor
.
executemany
(
"""
"""
...
@@ -327,6 +323,16 @@ class VoucherStore(object):
...
@@ -327,6 +323,16 @@ class VoucherStore(object):
),
),
)
)
@with_cursor
def
insert_unblinded_tokens
(
self
,
cursor
,
unblinded_tokens
):
"""
Store some unblinded tokens, for example as part of a backup-restore
process.
:param list[unicode] unblinded_tokens: The unblinded tokens to store.
"""
self
.
_insert_unblinded_tokens
(
cursor
,
unblinded_tokens
)
@with_cursor
@with_cursor
def
insert_unblinded_tokens_for_voucher
(
self
,
cursor
,
voucher
,
public_key
,
unblinded_tokens
):
def
insert_unblinded_tokens_for_voucher
(
self
,
cursor
,
voucher
,
public_key
,
unblinded_tokens
):
"""
"""
...
@@ -362,12 +368,10 @@ class VoucherStore(object):
...
@@ -362,12 +368,10 @@ class VoucherStore(object):
)
)
if
cursor
.
rowcount
==
0
:
if
cursor
.
rowcount
==
0
:
raise
ValueError
(
"
Cannot insert tokens for unknown voucher; add voucher first
"
)
raise
ValueError
(
"
Cannot insert tokens for unknown voucher; add voucher first
"
)
cursor
.
executemany
(
self
.
_insert_unblinded_tokens
(
"""
cursor
,
INSERT INTO [unblinded-tokens] VALUES (?)
"""
,
list
(
list
(
(
t
.
unblinded_token
,)
t
.
unblinded_token
for
t
for
t
in
unblinded_tokens
in
unblinded_tokens
),
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment