<s> import peewee <EOL> from pypi_server . db . packages import Package , PackageVersion , PackageFile <EOL> from pypi_server . db . users import Users <EOL> from pypi_server . handlers import route <EOL> from pypi_server . handlers . api import JSONHandler <EOL> from pypi_server . handlers . base import threaded <EOL> from pypi_server . handlers . api . login import authorization_required <EOL> @ route ( '<STR_LIT>' ) <EOL> class PackagesHandler ( JSONHandler ) : <EOL> @ authorization_required ( ) <EOL> @ threaded <EOL> def get ( self ) : <EOL> q = Package . select ( <EOL> Package , <EOL> Users . login , <EOL> ) . join ( <EOL> Users , peewee . JOIN . LEFT_OUTER <EOL> ) . order_by ( <EOL> Package . is_proxy . asc ( ) , <EOL> Package . lower_name . asc ( ) , <EOL> ) <EOL> self . response ( <EOL> list ( <EOL> map ( <EOL> lambda x : dict ( <EOL> name = x . name , <EOL> owner = { <EOL> '<STR_LIT:id>' : x . owner_id , <EOL> '<STR_LIT:name>' : x . owner . login <EOL> } , <EOL> is_proxy = x . is_proxy , <EOL> ) , <EOL> q <EOL> ) <EOL> ) <EOL> ) </s>
