[debexpo-devel] [debexpo/master] Added uploader action to PackagesController.
Christoph Haas
email at christoph-haas.de
Tue Jun 17 12:41:12 CEST 2008
Jonny,
I can already hear the sounds of your chainsaw when you read all my
picking... :)
On Dienstag, 17. Juni 2008, debexpo commit messages wrote:
> Signed-off-by: Jonny Lamb <jonnylamb at jonnylamb.com>
> ---
> debexpo/controllers/packages.py | 28
> +++++++++++++++++++++++++++- debexpo/templates/packages/uploader.mako |
> 10 ++++++++++
> 2 files changed, 37 insertions(+), 1 deletions(-)
> create mode 100644 debexpo/templates/packages/uploader.mako
>
> diff --git a/debexpo/controllers/packages.py
> b/debexpo/controllers/packages.py index 9867d38..b4f6624 100644
> --- a/debexpo/controllers/packages.py
> +++ b/debexpo/controllers/packages.py
> @@ -113,6 +113,14 @@ class PackagesController(BaseController):
>
> return packages
>
> + def _get_user(self, email):
> + users = meta.session.query(User).filter_by(email=email).all()
> +
> + if len(users) != 1:
> + return None
> +
> + return users[0]
This is technically correct. There shouldn't be more than one user with a
certain email address anyway. But SQLAlchemy offers two constructs that
might make this nicer.
query(...).filter_by(...).first()
This gets one row or None. So you can safely return that. Might help
here.
query(...).filter_by(...).one()
This runs a query and expects exact one result. It runs with a
"LIMIT 2" clause and if it finds either 0 or >1 results it will
complain. This might help in other places where you expect really
just one result.
Cheers
Christoph
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://workaround.org/pipermail/debexpo-devel/attachments/20080617/6e84f715/attachment.pgp
More information about the debexpo-devel
mailing list