<s> import web <EOL> from karesansui . lib . rest import Rest , auth <EOL> from karesansui . lib . checker import Checker , CHECK_EMPTY , CHECK_VALID , CHECK_LENGTH , CHECK_CHAR <EOL> from karesansui . lib . utils import is_param , json_dumps <EOL> from karesansui . db . access . tag import findbyhostall , findbyhostall <EOL> class HostTag ( Rest ) : <EOL> @ auth <EOL> def _GET ( self , * param , ** params ) : <EOL> tags = findbyhostall ( self . orm ) <EOL> if not tags : <EOL> return web . notfound ( self . _ ( "<STR_LIT>" ) ) <EOL> if self . is_part ( ) is True : <EOL> self . view . tags = tags <EOL> machine_ids = { } <EOL> for tag in tags : <EOL> tag_id = str ( tag . id ) <EOL> machine_ids [ tag_id ] = [ ] <EOL> for machine in tag . machine : <EOL> machine_ids [ tag_id ] . append ( "<STR_LIT>" % machine . id ) <EOL> machine_ids [ tag_id ] = "<STR_LIT:U+0020>" . join ( machine_ids [ tag_id ] ) <EOL> self . view . machine_ids = machine_ids <EOL> return True <EOL> elif self . is_json ( ) is True : <EOL> tags_json = [ ] <EOL> for tag in tags : <EOL> tags_json . append ( tag . get_json ( self . me . languages ) ) <EOL> self . view . tags = json_dumps ( tags_json ) <EOL> return True <EOL> else : <EOL> return web . nomethod ( ) <EOL> urls = ( <EOL> '<STR_LIT>' , HostTag , <EOL> ) </s>
