def PaginationOrderFinisher(node, appstruct): if appstruct and appstruct.get('order_by'): order_by = appstruct['order_by'] if not is_nonstr_iter(order_by): order_by = [order_by] appstruct['order_by'] = [] output_node = getattr(node, '__output_node__') for ob in order_by: ob = ob.split(' ', 1) if output_node: breadcrumbs = ob[0].split('.') if len(breadcrumbs) == 2: table_name, column_name = breadcrumbs table_name = uncamelcase(table_name) elif len(breadcrumbs) == 1: column_name = breadcrumbs[0] table_name = None else: continue column_name = uncamelcase(column_name) for schema in output_node.__class_schema_nodes__: if not table_name or schema.name == table_name: if isinstance(schema, SequenceSchema): schema = schema.__class_schema_nodes__[0] nodes = schema.__class_schema_nodes__ nodes.extend(schema.__all_schema_nodes__) for schema_node in nodes: if isinstance(schema_node, SchemaNode) and schema_node.name == column_name: break else: # Nothing found! dont add order by continue # Break this FOR to add order by break else: # Nothing found! dont add order by continue descendant = bool(len(ob) == 2 and ob[1].lower() in ('desc', 'd')) appstruct['order_by'].append(OrderBy(ob[0], descendant)) return appstruct
def decode_key(self, key): return uncamelcase(key) if self.auto_camelcase else key
def __init__(self, argument_name, descendant=False): self.argument_name = argument_name self.column_name = uncamelcase(argument_name) self.descendant = descendant