[debexpo-devel] [debexpo/master] Added uploader action to PackagesController.
Christoph Haas
email at christoph-haas.de
Tue Jun 17 14:43:55 CEST 2008
On Dienstag, 17. Juni 2008, Jonny Lamb wrote:
> On Tue, Jun 17, 2008 at 12:41:12PM +0200, Christoph Haas wrote:
> > 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.
>
> This was laziness over anything else -- I've used .one() in the importer
> script, at least.
Isn't .first() simpler in this case? It returns None if there are no
results or otherwise the single row. That would spare you the try/except.
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/fc2e1384/attachment-0001.pgp
More information about the debexpo-devel
mailing list