Skip to content

Commit

Permalink
Resolves Issue #82
Browse files Browse the repository at this point in the history
  • Loading branch information
BJ Dierkes committed Dec 19, 2011
1 parent 151e50f commit 05c0659
Show file tree
Hide file tree
Showing 38 changed files with 207 additions and 177 deletions.
4 changes: 3 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ Incompatible Changes:
* :issue:`72` - The framework hooks 'cement_add_args_hook' and
'cement_validate_config' were removed in favor of the new pre/post setup
and run hooks.

* :issue`82` - Change 'meta' classes to Python-proper 'Meta', and
interfaces to use 'IMeta'. Old functionality will be completely removed
before Cement2 stable release.



Expand Down
2 changes: 1 addition & 1 deletion doc/source/api/extensions/daemon.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ For example:
# define an application base controller
class MyAppBaseController(controller.CementBaseController):
class meta:
class Meta:
interface = controller.IController
label = 'base'
description = "My Application does amazing things!"
Expand Down
8 changes: 4 additions & 4 deletions doc/source/dev/controllers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ handle command dispatch and rapid development.
# define an application base controller
class MyAppBaseController(controller.CementBaseController):
class meta:
class Meta:
interface = controller.IController
label = 'base'
description = "My Application does amazing things!"
Expand Down Expand Up @@ -144,7 +144,7 @@ and the other is not. Pay attention to how this looks at the command line:
# define an application base controller
class MyAppBaseController(controller.CementBaseController):
class meta:
class Meta:
interface = controller.IController
label = 'base'
description = "My Application does amazing things!"
Expand All @@ -171,7 +171,7 @@ and the other is not. Pay attention to how this looks at the command line:
self.log.info("Inside base.command1 function.")
class Controller2(controller.CementBaseController):
class meta:
class Meta:
interface = controller.IController
label = 'controller2'
stacked_on = 'base'
Expand All @@ -187,7 +187,7 @@ and the other is not. Pay attention to how this looks at the command line:
self.log.info('Inside controller2.command2 function.')
class Controller3(controller.CementBaseController):
class meta:
class Meta:
interface = controller.IController
label = 'controller3'
description = 'This is the description for controller3.'
Expand Down
2 changes: 1 addition & 1 deletion doc/source/dev/extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ is part of our 'myapp' application, so the extension module would be
Log = backend.minimal_logger(__name__)
class MyAppOutputHandler(object):
class meta:
class Meta:
interface = output.IOutput
label = 'myapp_output'
Expand Down
2 changes: 1 addition & 1 deletion doc/source/dev/hooks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ a custom application hook:
# define an application base controller
class MyAppBaseController(controller.CementBaseController):
class meta:
class Meta:
interface = controller.IController
label = 'base'
description = "My Application does amazing things!"
Expand Down
16 changes: 8 additions & 8 deletions doc/source/dev/interfaces_and_handlers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ The following defines a basic interface:
app = foundation.lay_cement('myapp')
class MyInterface(interface.Interface):
class imeta:
class iMeta:
label = 'myinterface'
# Must be provided by the implementation
meta = interface.Attribute('Handler meta-data')
Meta = interface.Attribute('Handler Meta-data')
my_var = interface.Attribute('A variable of epic proportions.')
def setup(config_obj):
Expand Down Expand Up @@ -80,19 +80,19 @@ functionality, and should never been used directly. This is why the class
functions do not have an argument of 'self', nor do they contain any code
other than comments.

That said, what is required is an 'imeta' class that is used to interact
That said, what is required is an 'iMeta' class that is used to interact
with the interface. At the very least, this must include a unique 'label'
to identify the interface. This can also be considered the 'handler type'.
For example, the ILog interface has a label of 'log'.

Notice that we defined 'meta' and 'my_var' as Interface Attributes. This is
Notice that we defined 'Meta' and 'my_var' as Interface Attributes. This is
a simple identifier that describes an attribute that an implementation is
expected to provide.

Validating Interfaces
---------------------

A validator call back function can be defined in the interfaces imeta class
A validator call back function can be defined in the interfaces iMeta class
like this:

.. code-block:: python
Expand All @@ -111,7 +111,7 @@ like this:
interface.validate(MyInterface, obj, members)
class MyInterface(interface.Interface):
class imeta:
class iMeta:
label = 'myinterface'
validator = my_validator
...
Expand Down Expand Up @@ -140,7 +140,7 @@ is a handler that implements the MyInterface above:
app = foundation.lay_cement('myapp')
class MyHandler(object):
class meta:
class Meta:
interface = MyInterface
label = 'my_handler'
description = 'This handler implements MyInterface'
Expand Down Expand Up @@ -219,7 +219,7 @@ configuration setting for that handler via the application defaults like so:
# Define the 'mylog' handler here
class MyLog(object):
class meta:
class Meta:
interface = log.ILog
label = 'mylog'
Expand Down
4 changes: 2 additions & 2 deletions doc/source/dev/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ handler class:
from cement2.ext.ext_logging import LoggingLogHandler
class MyLogHandler(LoggingLogHandler):
class meta:
class Meta:
interface = log.ILog
label = 'mylog'
Expand Down Expand Up @@ -342,7 +342,7 @@ handler class:
app.run()
# Call the log object like normal
app.log.info('Using %s log handler' % app.log.meta.label)
app.log.info('Using %s log handler' % app.log.Meta.label)
# close the application
app.close()
Expand Down
2 changes: 1 addition & 1 deletion doc/source/dev/output.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ something happen:
# Create a custom output handler
class MyOutput(object):
class meta:
class Meta:
interface = output.IOutput
label = 'myoutput'
Expand Down
6 changes: 3 additions & 3 deletions doc/source/dev/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ options and commands via an application controller:
from cement2.core import handler, controller
class MyPluginController(controller.CementBaseController):
class meta:
class Meta:
interface = controller.IController
label = 'myplugin'
description = 'This is my plugin controller.'
Expand Down Expand Up @@ -126,7 +126,7 @@ application shows how to configure an application to load plugins:
# define an application base controller
class HelloWorldBaseController(controller.CementBaseController):
class meta:
class Meta:
interface = controller.IController
label = 'base'
description = "HelloWorld does amazing things!"
Expand Down Expand Up @@ -189,7 +189,7 @@ for example:
from cement2.core import handler, controller
class MyPluginController(controller.CementBaseController):
class meta:
class Meta:
interface = controller.IController
label = 'myplugin'
description = 'This is my plugin controller.'
Expand Down
4 changes: 2 additions & 2 deletions doc/source/dev/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ application features.
app.setup()
# add arguments
app.args.add_argument('-f', '--foo', action='store', metavar='STR',
app.args.add_argument('-f', '--foo', action='store', Metavar='STR',
help='the notorious foo option')
# run the application
Expand Down Expand Up @@ -218,7 +218,7 @@ handle command dispatch and rapid development.
# define an application base controller
class MyAppBaseController(controller.CementBaseController):
class meta:
class Meta:
interface = controller.IController
label = 'base'
description = "My Application does amazing things!"
Expand Down
2 changes: 1 addition & 1 deletion src/cement2.ext.configobj/cement2/lib/ext_configobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ConfigObjConfigHandler(ConfigObj):
Arguments and Keyword arguments are passed directly to ConfigObj
on initialization.
"""
class meta:
class Meta:
interface = config.IConfig
label = 'configobj'

Expand Down
2 changes: 1 addition & 1 deletion src/cement2.ext.json/cement2/lib/ext_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class JsonOutputHandler(object):
going on.
"""
class meta:
class Meta:
interface = output.IOutput
label = 'json'

Expand Down
2 changes: 1 addition & 1 deletion src/cement2.ext.yaml/cement2/lib/ext_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class YamlOutputHandler(object):
going on.
"""
class meta:
class Meta:
interface = output.IOutput
label = 'yaml'

Expand Down
6 changes: 3 additions & 3 deletions src/cement2/cement2/core/arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ class IArgument(interface.Interface):
from cement2.core import interface, arg
class MyArgumentHandler(object):
class meta:
class Meta:
interface = arg.IArgument
label = 'my_argument_handler'
...
"""
class imeta:
class IMeta:
label = 'argument'
validator = argument_validator

# Must be provided by the implementation
meta = interface.Attribute('Handler meta-data')
Meta = interface.Attribute('Handler Meta-data')
parsed_args = interface.Attribute('Parsed args object')

def setup(config_obj):
Expand Down
6 changes: 3 additions & 3 deletions src/cement2/cement2/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ class IConfig(interface.Interface):
from cement2.core import config
class MyConfigHandler(object):
class meta:
class Meta:
interface = config.IConfig
label = 'my_config_handler'
...
"""
class imeta:
class IMeta:
label = 'config'
validator = config_validator

# Must be provided by the implementation
meta = interface.Attribute('Handler meta-data')
Meta = interface.Attribute('Handler Meta-data')

def setup(defaults):
"""
Expand Down
Loading

0 comments on commit 05c0659

Please sign in to comment.