from generator.models import collectionFor, knownContentTypes, \ is_link, is_multi_link, is_reverse_link, is_reverse_multi_link, \ Model from generator.utils import try_attributes LINK_DIRECTION_OUT = 'out' LINK_DIRECTION_IN = 'in' def display_field (field): return '
{label}
'.format(label=str(field)) def display_empty (): return '
not set
'.format() # def display_link (direction = LINK_DIRECTION_OUT, label, url=None): # The source is already listed, so we care about the target def display_link (link): if not link: return display_empty() if link.reverse: direction = LINK_DIRECTION_IN else: direction = LINK_DIRECTION_OUT arrow = '→' if direction == LINK_DIRECTION_OUT else '←' # Label of target? # If there is a sourcepath include it as well # Mark whether it is an inline link if link.broken: return ''.format( direction=direction, arrow=arrow, label=link.target ) elif not link.resolved: return ''.format( direction=direction, arrow=arrow, label=link.target ) else: padname = link.target.source_path if padname: return '
{direction} {arrow} {label}
'.format( direction=direction, arrow=arrow, label=str(link.target), padname=padname.replace('#', '%23') ) else: return '
{direction} {arrow} {label}
'.format( direction=direction, arrow=arrow, label=str(link.target), ) def make_index (models): buff = '' return buff # for obj in models: # '{type}: {label} -- {padurl}'.format({ 'type': obj.type, 'label': getattr(obj, obj.labelField), 'padurl': padurl }) # for (prop, val) in dir(obj): # if is_link(val): # print('{targetname}: {targetcontenttype} {targetgcontentpadurl}').format({ # 'targetname': '', # 'targetcontenttype': '', # 'targetgcontentpadurl': '' # })\\\