Skip to content
This repository has been archived by the owner on May 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #209 from enthought/code-tracing
Browse files Browse the repository at this point in the history
Code tracing
  • Loading branch information
sccolbert committed Nov 26, 2012
2 parents ff8d30d + 8521ede commit 4eceb09
Show file tree
Hide file tree
Showing 23 changed files with 2,526 additions and 2,456 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.swp
*.egg-info
*.so
*.pyd
*.DS_Store
*.enamlc
*.c
Expand Down
10 changes: 5 additions & 5 deletions enaml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#------------------------------------------------------------------------------
# Logging Setup
#------------------------------------------------------------------------------
# Add a NullHandler to make sure that all enaml loggers don't complain when they
# get used.
# Add a NullHandler so enaml loggers don't complain when they get used.
import logging

class NullHandler(logging.Handler):

def handle(self, record):
pass

Expand All @@ -33,14 +33,14 @@ def imports():
""" Lazily imports and returns an enaml imports context.
"""
from .core.import_hooks import imports
from enaml.core.import_hooks import imports
return imports()


#------------------------------------------------------------------------------
# Operator Context Functions
#------------------------------------------------------------------------------
#: The private storage for the optional default operator context function
#: The private storage for the optional default operator context function
#: which overrides that which is provided by default.
_default_operator_context_func = None

Expand All @@ -53,7 +53,7 @@ def set_default_operator_context_func(func):
func : callable
A callable object which takes no arguments and returns an
instance of OperatorContext.
"""
global _default_operator_context_func
_default_operator_context_func = func
Expand Down
80 changes: 80 additions & 0 deletions enaml/core/abstract_expressions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#------------------------------------------------------------------------------
# Copyright (c) 2012, Enthought, Inc.
# All rights reserved.
#------------------------------------------------------------------------------
from abc import ABCMeta, abstractmethod

from enaml.signaling import Signal


class AbstractListener(object):
""" An interface definition for creating attribute listeners.
Listeners are registered with `Declarative` instances using the
`bind_listener` method to track changes to their attributes.
"""
__metaclass__ = ABCMeta

@abstractmethod
def value_changed(self, obj, name, old, new):
""" Called when the attribute on the object has changed.
Parameters
----------
obj : Declarative
The Declarative object which owns the attribute.
name : str
The name of the attribute which changed.
old : object
The old value of the attribute.
new : object
The new value of the attribute.
"""
raise NotImplementedError


class AbstractExpression(object):
""" An abstract interface definition for creating expressions.
Expressions are registered with `Declarative` instances using the
`bind_expression` method to provide computed attribute values.
"""
__metaclass__ = ABCMeta

@abstractmethod
def eval(self, obj, name):
""" Evaluate and return the results of the expression.
Parameters
----------
obj : Declarative
The declarative object which owns the expression.
name : str
The attribute name on `obj` for which this expression is
providing the value.
"""
raise NotImplementedError


class AbstractListenableExpression(AbstractExpression):
""" An abstract interface definition for creating listenable
expressions.
Listenable expressions are registered with `Declarative` instances
using the `bind_expression` method to provide dynamically computed
attribute values at runtime.
"""
#: An Enaml Signal emitted by the expression when it becomes invalid.
#: The payload of the signal will be the name that was passed to the
#: `eval` method during the last expression evaluation.
invalidated = Signal()

Loading

0 comments on commit 4eceb09

Please sign in to comment.