-
-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Tutorial Walk Through #323
Comments
For what its worth: I am looking for some more real world examples of controllers, interfaces and handlers. When to use what. For example I have an App class that needs to perform special tasks to init the overall configuration. Like assemble more complex variables or objects based on the app config settings. I am also looking for how to add capabilities to have the app communicate with external interfaces. e.g. perform REST gets and posts and leverage the config settings for the interface/handler. I assume controllers are only for tasks that are exposed to the CLI. But I am not quite sure when to use Interfaces and handlers. Sorry if these are Noob questions. Still trying to figure everything out. |
@fxstein I appreciate your feedback here, and again apologize for the delay in development (my $dayjob has been busy). To touch on your questions a bit:
For this, I generally tie into from cement.core.foundation import CementApp
from cement.utils.misc import is_true
class MyApp(CementApp):
class Meta:
label = 'myapp'
def validate_config(self):
# convert 1, 0, true, false, etc to boolean
my_param = self.config.get('myapp', 'my_param')
self.config.set('myapp', 'my_param', is_true(my_param))
For this, I use a combination of from cement.core import hook
def extend_my_api_client(app):
# do something to setup an api client object
my_api_client = SomeAPIClientClass()
app.extend('my_api_client', my_api_client)
hook.register('post_argument_parsing', extend_my_api_client) You can then access
Yes, controllers are specifically for exposing operations to the end-user via CLI commands/arguments. Interfaces/Handlers are primarily for segmenting bits of code that might have alternative use cases (handlers). Take for example a database interface. You might want to define an Does that make sense? |
This can be closed, complete doc/api rewrites took place when Cement 3 was released. https://builtoncement.com |
The doc is pretty intense... need something to go in-between
Quickstart
andRead All This Shit To Understand All The Things
.The text was updated successfully, but these errors were encountered: