MCPcopy Create free account
hub / github.com/carlio/django-flows / PossibleFlowPosition

Class PossibleFlowPosition

flows/handler.py:548–593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

546
547
548class PossibleFlowPosition(object):
549 all_positions = {}
550
551 """
552 A PossibleFlowPosition represents a possible position in a hierachy of
553 flow components. On startup, all FlowComponents (Scaffolds and Actions)
554 are inspected to build up a list of all possible positions within all
555 avaiable flows. This class represents one such possibility.
556 """
557
558 def __init__(self, app_namespace, flow_namespace, flow_components):
559 self.app_namespace = app_namespace
560 self.flow_namespace = flow_namespace
561 self.flow_component_classes = flow_components
562
563 PossibleFlowPosition.all_positions[self.url_name] = self
564
565 def create_instance(self, state, state_store, url_args, url_kwargs):
566 return FlowPositionInstance(self.app_namespace, self.flow_namespace, self, state,
567 state_store, url_args, url_kwargs)
568
569 def _url_name_from_components(self, components, include_app_namespace=True):
570 if self.flow_namespace is None:
571 prefix = 'flow_'
572 else:
573 prefix = 'flow_%s_' % self.flow_namespace
574 if self.app_namespace and include_app_namespace:
575 prefix = '%s:%s' % (self.app_namespace, prefix)
576 return '%s%s' % (prefix, '/'.join([name_for_flow(fc) for fc in components]))
577
578 def is_entry_point(self):
579 root_tree = self.flow_component_classes[0].get_initial_action_tree()
580 my_tree = self.flow_component_classes
581 return root_tree == my_tree
582
583 @property
584 def url_name(self):
585 return self.get_url_name(include_app_namespace=True)
586
587 def get_url_name(self, include_app_namespace=True):
588 return self._url_name_from_components(self.flow_component_classes, include_app_namespace)
589
590
591 def __repr__(self):
592 classes = ' / '.join( map(str, self.flow_component_classes) )
593 return '%s (%s)' % (classes, self.url_name)
594

Callers 3

_urls_for_flowMethod · 0.85
flow_entry_linkMethod · 0.85
position_instance_forMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected