Commits

Ginés Martínez Sánchez committed 1db4b51 Draft

version 0.6.0, intra events working

Comments (0)

Files changed (4)

ginsfsm/__init__.py

 """
 A python library to do development based in Finite State Machines.
 """
-__version__ = '0.5.5'
+__version__ = '0.6.0'
 __title__ = 'ginsfsm'
 __author__ = 'Ginés Martínez'
 __license__ = 'MIT License'

ginsfsm/examples/inter_event/ap4_publicidad/publicidad/c_sorteo.py

 
     self.set_timeout(3)
 
-        #self.gaplic.send_event_outside(
-        #    origin_gaplic,  # gaplic_name
-        #    origin_role,  # role
-        #    origin_gobj,  # gobj_name
-        #    'EV_REGALO',  # event_name
-        #    self,  # subscriber_gobj
-        #    regalo=22,
-        #)
-
 
 def ac_sorteo(self, event):
-    self.broadcast_event('EV_REGALO')
+    self.broadcast_event('EV_REGALO', regalo="Premio gordo!!")
     self.set_timeout(3)
 
 

ginsfsm/gaplic.py

                         gaplic = get_gaplic_by_thread_ident(dst_ident)
                         if gaplic:
                             gaplic.enqueue_event(event)
-                except Exception:
+                except Exception as e:
                     if self.logger:
-                        self.logger.error("Exception gaplic.__process_qevent")
+                        self.logger.exception("ERROR _process_qevent: %s" % e)
 
         return False
 

ginsfsm/router.py

     """
     def __init__(self, intra_event, route_ref):
         self.event_name = intra_event.event_name
+        self.destination_gaplic = intra_event.destination_gaplic
+        self.destination_role = intra_event.destination_role
         self.destination_gobj = intra_event.destination_gobj
         self.origin_gaplic = intra_event.origin_gaplic
+        self.origin_role = intra_event.origin_role
         self.origin_gobj = intra_event.origin_gobj
         self.route_ref = route_ref
         self.isubscription = None  # reference to internal subscription
     if subscription:
         self._send_event_to_external_route(
             subscription.route_ref,
+            subscription.origin_gaplic,
+            subscription.origin_role,
             subscription.origin_gobj,
             subscription.event_name,
             subscription.destination_gobj,
     def _send_event_to_external_route(
             self,
             route_ref,
+            gaplic_name,
+            role,
             gobj_name,
             event_name,
             subscriber_gobj,
             message_type='__event__',
             serial=route.incr_serial(),
             event_name=event_name,
-            destination_gaplic=route.gaplic_name if route.gaplic_name else '',
-            destination_role=route.roles[0] if route.roles else '',
+            destination_gaplic=gaplic_name,
+            destination_role=role,
             destination_gobj=gobj_name,
             origin_gaplic=registry.my_gaplic_name,
-            origin_role=registry.my_roles,
+            origin_role=registry.my_roles,  # use destination_role?
             origin_gobj=subscriber_gobj,
             kw=kw)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.