nodes: 0, module; 1, function_definition; 2, function_name:list_provincies; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, try_statement; 9, function_definition; 10, if_statement; 11, for_statement; 12, return_statement; 13, identifier:gewest; 14, integer:2; 15, string; 16, block; 17, except_clause; 18, function_name:creator; 19, parameters; 20, block; 21, attribute; 22, block; 23, else_clause; 24, identifier:p; 25, identifier:provincies; 26, block; 27, identifier:provincies; 28, string_content; 29, expression_statement; 30, identifier:AttributeError; 31, block; 32, return_statement; 33, subscript; 34, identifier:is_configured; 35, expression_statement; 36, expression_statement; 37, block; 38, expression_statement; 39, escape_sequence:\; 40, assignment; 41, expression_statement; 42, list_comprehension; 43, attribute; 44, string; 45, assignment; 46, assignment; 47, expression_statement; 48, call; 49, identifier:gewest_id; 50, attribute; 51, assignment; 52, call; 53, for_in_clause; 54, if_clause; 55, identifier:self; 56, identifier:caches; 57, string_content:permanent; 58, identifier:key; 59, binary_operator:'ListProvinciesByGewestId#%s' % gewest_id; 60, identifier:provincies; 61, call; 62, assignment; 63, attribute; 64, argument_list; 65, identifier:gewest; 66, identifier:id; 67, identifier:gewest_id; 68, identifier:gewest; 69, identifier:Provincie; 70, argument_list; 71, identifier:p; 72, attribute; 73, comparison_operator:p[2] == gewest_id; 74, string; 75, identifier:gewest_id; 76, attribute; 77, argument_list; 78, identifier:provincies; 79, call; 80, identifier:p; 81, identifier:set_gateway; 82, identifier:self; 83, subscript; 84, subscript; 85, call; 86, identifier:self; 87, identifier:provincies; 88, subscript; 89, identifier:gewest_id; 90, string_content:ListProvinciesByGewestId#%s; 91, subscript; 92, identifier:get_or_create; 93, identifier:key; 94, identifier:creator; 95, identifier:creator; 96, argument_list; 97, identifier:p; 98, integer:0; 99, identifier:p; 100, integer:1; 101, identifier:Gewest; 102, argument_list; 103, identifier:p; 104, integer:2; 105, attribute; 106, string; 107, subscript; 108, identifier:self; 109, identifier:caches; 110, string_content:permanent; 111, identifier:p; 112, integer:2
code: def list_provincies(self, gewest=2):
          '''
          List all `provincies` in a `gewest`.
  
          :param gewest: The :class:`Gewest` for which the \
              `provincies` are wanted.
          :param integer sort: What field to sort on.
          :rtype: A :class:`list` of :class:`Provincie`.
          '''
          try:
              gewest_id = gewest.id
          except AttributeError:
              gewest_id = gewest
  
          def creator():
              return [Provincie(p[0], p[1], Gewest(p[2])) for p in self.provincies if p[2] == gewest_id]
  
          if self.caches['permanent'].is_configured:
              key = 'ListProvinciesByGewestId#%s' % gewest_id
              provincies = self.caches['permanent'].get_or_create(key, creator)
          else:
              provincies = creator()
          for p in provincies:
              p.set_gateway(self)
          return provincies