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

Class FlowPositionInstance

flows/handler.py:349–545  ·  view source on GitHub ↗

A FlowPositionInstance represents a concrete instance of a PossibleFlowPosition - that is, a user is currently performing an action as part of a flow

Source from the content-addressed store, hash-verified

347
348
349class FlowPositionInstance(object):
350 """
351 A FlowPositionInstance represents a concrete instance of a PossibleFlowPosition -
352 that is, a user is currently performing an action as part of a flow
353 """
354
355 def __init__(self, app_namespace, flow_namespace, position, state, state_store, url_args, url_kwargs):
356 self._app_namespace = app_namespace
357 self._flow_namespace = flow_namespace
358 self._position = position
359 self._state = state
360 self._flow_components = []
361 self.state_store = state_store
362
363 self._url_args = url_args or []
364 self._url_kwargs = url_kwargs or {}
365
366 for flow_component_class in self._position.flow_component_classes:
367 flow_component = flow_component_class()
368 flow_component._flow_position_instance = self
369 flow_component.set_url_args(*self._url_args, **self._url_kwargs)
370 flow_component.state = state
371 flow_component.task_id = self.task_id
372 flow_component.app_namespace = self._app_namespace
373 flow_component.flow_namespace = self._flow_namespace
374
375 self._flow_components.append( flow_component )
376
377 self._history = FlowHistory(self)
378
379 self._validate()
380
381 def _validate(self):
382 pass
383 # TODO: assert that only the last element is an Action and that the
384 # rest are Scaffolds
385
386 @property
387 def task_id(self):
388 return self._state['_id']
389
390 def get_root_component(self):
391 return self._flow_components[0]
392
393 def get_action(self):
394 return self._flow_components[-1]
395
396 def get_back_url(self):
397 return self._history.get_back_url()
398
399 def get_absolute_url(self, include_flow_id=True):
400 args = []
401 kwargs = {}
402 for flow_component in self._flow_components:
403 flow_args, flow_kwargs = flow_component.get_url_args()
404 args += flow_args
405 kwargs.update(flow_kwargs)
406

Callers 1

create_instanceMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected