Commits

Ginés Martínez Sánchez committed f7cc3d7 Draft

name and parent attributes mus be Location-Aware Resources for Pyramid framework compatibility: changed to point to __name__ and __parent__

  • Participants
  • Parent commits 85b362d

Comments (0)

Files changed (2)

File ginsfsm/gaplic.py

             GObj.trace_mach = true
 
             [app:wsgi-application]
-            use = call:ginsfsm.examples.wsgi.simple_wsgi_server:paste_app_factory
+            use=call:ginsfsm.examples.wsgi.simple_wsgi_server:paste_app_factory
 
 
     The prototype for ``wsgi`` (paste app factory) is::

File ginsfsm/gobj.py

     :param gconfig: GCONFIG :term:`gconfig-template`.
     """
 
+    # name and parent attributes mus be Location-Aware Resources
+    # for Pyramid framework compatibility:
+    # changed to point to __name__ and __parent__.
+    @property
+    def name(self):
+        return self.__name__
+
+    @name.setter
+    def name(self, name):
+        self.__name__ = name
+
+    @property
+    def parent(self):
+        return self.__parent__
+
+    @parent.setter
+    def parent(self, parent):
+        self.__parent__ = parent
+
     def __init__(self, fsm, gconfig=None):
         SMachine.__init__(self, fsm)
+
         self.name = ''
         """ My name.
         Set by :meth:`create_gobj`
         GConfig.__init__(self, gconfig)
 
     def __str__(self):
-        return "%s:%s" % (self.__class__.__name__, self.name)
+        return "%s:%s" % (self.__class__.__name__, self.__name__)
 
     def create_gobj(self, name, gclass, parent, **kw):
         """ Factory function to create gobj's instances.
                 '''ERROR create_gobj(): No GObj class supplied.''')
         if not issubclass(gclass, GObj):
             raise GObjError(
-                '''ERROR create_gobj(): class '%s' is NOT a GObj subclass''' % (
-                    repr(gclass)))
+                '''ERROR create_gobj(): class '%s' is NOT a GObj subclass''' %
+                (repr(gclass)))
 
         if parent is not None:
             if not isinstance(parent, GObj):
                 isinstance(destination, GObj)):
             raise DestinationError(
                 '_resolv_destination() BAD TYPE destination %s in (%s:%s)' %
-                (repr(destination), self.__class__.__name__, self.name))
+                (repr(destination), self.__class__.__name__, self.__name__))
 
         if isinstance(destination, string_types):
             named_gobj = self.find_unique_gobj(destination)
                     '\nCurrent named-gobjs: %s'
                     % (repr(destination),
                        self.__class__.__name__,
-                       self.name,
+                       self.__name__,
                        ' '.join(sorted(self.get_named_gobjs())),
                        )
                     )
         if not (isinstance(event, string_types) or
                 isinstance(event, Event)):
             raise EventError('_event_factory() BAD TYPE event %s in (%s:%s)' %
-                (repr(event), self.__class__.__name__, self.name))
+                (repr(event), self.__class__.__name__, self.__name__))
 
         # if destination is not None:
         if not (isinstance(destination, string_types) or
                 isinstance(destination, GObj)):
             raise DestinationError(
                 '_event_factory() BAD TYPE destination %s in (%s:%s)' %
-                (repr(destination), self.__class__.__name__, self.name))
+                (repr(destination), self.__class__.__name__, self.__name__))
 
         if isinstance(event, Event):
             # duplicate the event
         function **returns** :exc:`EventNotAcceptedError`.
 
             .. note:: The :meth:`inject_event` method doesn't
-                **raise** :exc:`EventNotAcceptedError` because a :term:`machine`
-                should run under any circumstances. In any way an action can
-                raise exceptions.
+                **raise** :exc:`EventNotAcceptedError` because a
+                :term:`machine` should run under any circumstances.
+                In any way an action can raise exceptions.
 
-        If ``destination`` is a :term:`named-gobj`, i.e. a string, then the gobj
-        will be search with :meth:`search_gobj` method. This method must be
-        supplied and override by superior instance, like :term:`gaplic`.
+        If ``destination`` is a :term:`named-gobj`,
+        i.e. a string, then the gobj will be search
+        with :meth:`search_gobj` method.
+        This method must be supplied and override by superior instance,
+        like :term:`gaplic`.
 
         ``destination`` must be a `string` or :class:`GObj` types, otherwise a
         :exc:`GObjError` will be raised.
         if self.gaplic:
             cur_ident = threading.current_thread().ident
             cur_name = threading.current_thread().name
-            if self.gaplic.thread_ident and cur_ident != self.gaplic.thread_ident:
+            if self.gaplic.thread_ident and \
+                    cur_ident != self.gaplic.thread_ident:
                 logging.error("ERROR internal: "
                     "current thread '%s' is not the sender thread '%s'",
                     cur_name, self.gaplic.thread_name
         """
         raise QueueError(
               'enqueue_event() no support in (%s:%s)' % (
-              self.__class__.__name__, self.name))
+              self.__class__.__name__, self.__name__))
 
     def broadcast_event(self, event, **kw):
         """ Broadcast the ``event`` to all subscribers.
 
         """
         if subscriber_gobj is None:
-            subscriber_gobj = self.parent
+            subscriber_gobj = self.__parent__
 
         if subscriber_gobj is not None:
             if not (isinstance(subscriber_gobj, string_types) or
                     isinstance(subscriber_gobj, GObj)):
                 raise GObjError(
-                    'subcribe_event(): BAD TYPE subscriber_gobj %s in (%s:%s)' %
-                    (repr(subscriber_gobj), self.__class__.__name__, self.name))
+                    'subcribe_event(): BAD TYPE subscriber_gobj %s in (%s:%s)'
+                    % (repr(subscriber_gobj),
+                     self.__class__.__name__,
+                     self.__name__))
 
             if isinstance(subscriber_gobj, string_types):
                 named_gobj = self.find_unique_gobj(subscriber_gobj)
                         'subscribe_event() subscriber NOT FOUND in (%s:%s)'
                         '\nCurrent named-gobjs: %s'
                         % (self.__class__.__name__,
-                           self.name,
+                           self.__name__,
                            ' '.join(sorted(self.get_named_gobjs())),
                            )
                         )
             if not isinstance(name, string_types):
                 raise EventError(
                     'subscribe_event(): event %s is not string in (%s:%s)'
-                    % (repr(name), self.__class__.__name__, self.name))
+                    % (repr(name), self.__class__.__name__, self.__name__))
 
             if name not in output_events:
                 raise EventError(
                     ' (%s:%s)' % (
                         repr(event_name),
                         self.__class__.__name__,
-                        self.name))
+                        self.__name__))
 
         existing_subs = self._find_subscription(event_name, subscriber_gobj)
         if existing_subs:
                 pass  # "Set changed size during iteration" is OK
 
     def set_owned_event_filter(self, filter):
-        """ Set a filter function to be used by :meth:`broadcast_event` function
-        to check the owner of events.
+        """ Set a filter function to be used
+        by :meth:`broadcast_event` function to check the owner of events.
         """
         self.owned_event_filter = filter
 
         if gobj.parent:
             raise ParentError(
                 '_add_child(): gobj already has parent in (%s:%s)' %
-                (self.__class__.__name__, self.name))
+                (self.__class__.__name__, self.__name__))
         self.dl_childs.add(gobj)
         gobj.parent = self
 
 
         :param settings: parameters and their values.
 
-        The settings are filtered by the named-gobj or gclass name of this gobj.
+        The settings are filtered by the named-gobj
+        or gclass name of this gobj.
         The parameter name in settings, must be a dot-named,
         with the first item being the named-gobj o gclass name.
         """
 
         :param settings: parameters and their values.
 
-        The settings are filtered by the named-gobj or gclass name of this gobj.
+        The settings are filtered by the named-gobj
+        or gclass name of this gobj.
         The parameter name in settings, must be a dot-named,
         with the first item being the named-gobj o gclass name.
         """