Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    BJ Dierkes
    @derks
    from cement.ext.ext_argparse import ArgparseController, expose … will be from cement import Controller, ex … things like that.
    I’ve made a few of the major changes already… I’m actually focussig mainly on revamping the site and documentation
    I’m hoping for later this year
    I’m rewriting SphinxDoc to Markdown… it’s mostly just tedious work right now… then I will button up the major design changes I wanted to roll out
    p3j4p5
    @p3j4p5
    Hi everyone,
    I hope this is the right place to ask.
    I've started working on a project that is using the Cement framework and I would like to ask a few things.
    We are using a plugin that takes a number of config options.
    Those options get set in the expected place in: /etc/<project_name>/<project_name>.conf
    The question is, what is the most elegant way to retrieve the config options inside a plugin?
    I know it is possible to do something like: self.app.config.get('section', 'option') in the _setup function of the plugin but is there a way retrieve that information without invoking app?
    Didn't have much luck when reading the docs, so I would appreciate if someone could point me to the right place.
    Thanks,
    Paul
    BJ Dierkes
    @derks
    what is the reason for not wanting to invoke app?
    if it is simply because it is annoying to call self.app.config.get (understandable) you could create a shortcut like using get_section_dict
    like self.config = self.app.config.get_section_dict(‘my_plugin’) … then just use self.config[‘my_key’] through out your plugin
    @p3j4p5 ^
    p3j4p5
    @p3j4p5
    Thanks,
    The main reason is that app is only available in the `_seti
    The main reason is that app is only available in the _setup method.
    BJ Dierkes
    @derks
    actually, app is passed to the _setup() method … because that is called when the plugin is instantiated during app.setup(). You should set self.app = app in _setup() .. or if you subclass from cement.core.handler.CementHandler just make sure you super() in _setup() and it does that
    afte app.setup() you can access self.app anywhere in the plugin class
    p3j4p5
    @p3j4p5
    okay, thank you @derks! I will try that
    zero-signal
    @zero-signal
    Hi! Just getting to grips with the framework although have hit a stumbling block. Using cement 2.10.2 and following the BOSS app creation documentation. Created an app although when I run it it doesnt seem to load the example.py plugin module. Have not modified the BOSS app in anyway. Any thoughts? Can post debug output if that is any use?
    Checked for tickets relating to this on both cement and BOSS issue trackers but cannot see anything obvious
    Thanks in advance
    BJ Dierkes
    @derks
    @zero-signal have you setup a config file… usually ~/.yourapp.conf ?
    and I assume you used boss to create a cement-app and also cement-plugin? You need to configure plugin_config_dir and plugin_dir in a configuration file in order to find plugins..
    zero-signal
    @zero-signal
    @derks thabks for getting back to me. I ended up symlinking myapp/config/app.conf created by the boss cement-app to the location you suggested and the same for plugins.d conf directory. All is working well and I can start developing the app now. I mistakenly assumed after running setup.py develop that it would pick up the configs. Thanks for the help!
    BJ Dierkes
    @derks
    @zero-signal good to hear. Please let me know if you run in to any other issues
    sud117
    @sud117
    hi I am using cement framework for our data processing module.But when we want to distibute our CLI app we don't wan to share our code.IS it possible at Cement framework level
    @derks can you please help me how to create app which we can share to clients without giving source code
    BJ Dierkes
    @derks
    @sud117 that is more of a Python specific question, and not framework
    you can destribute just Python bytecode (.pyc, and .pyo) but that is easily reverse-engineerable and or doesn’t completely hide your code if I recall correctly
    No connection between “concrete” and “cement” mind you. ;)
    though: pyconcrete is an experimental project, there is always a way to decrypt .pye files, but pyconcrete just make it harder.
    sud117
    @sud117

    Thank you so much.I would like to know what would be the execution time.Will it take more comparatively with .pyc

    @derks

    BJ Dierkes
    @derks
    @sud117 I unfortunately don’t have any experience trying to encrypt or hide code from end-users, and everyhting I’ve built on Cement is either in-house or Open Source
    One question… are you trying to hide specific code that isn’t necessarily required by the “public” user… like an admin/internal code? If so, I’d suggest putting everything you don’t want to share in a plugin… and just don’t destribute the plugin. That way, the end-user can use the public bits freely, and the internal/admin code is will work just the same after installing/enabling the plugin
    Sam Likins
    @samlikins
    In the BOSS based project templates there is a "projectName/config/projectname.conf" and "projectName/config/plugins.d/example.conf" file. i've attempted reading settings from both of these files, but they don't seem to be loaded. Aren these files
    Aren't these files supposed to be default values for the project and project plugins respectively?
    BJ Dierkes
    @derks
    @samlikins Yes, they are intended to be the defaults … however, ./config is not in the config_files search path (by default)
    so you’d need to copy it to ~/.yourapp.conf or /etc/yourapp/yourapp.conf, etc… then modifying the config should take affect
    Sam Likins
    @samlikins
    @derks: I just added app.config.parse_file('%s/config/facetracker.conf' % os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))) before app.run() and it worked... I'd like default values in the project that can be superseded by the values in system and user configurations.
    do you think this is this an elegant solution?
    BJ Dierkes
    @derks
    that works fine… better would be to redefine CementApp.Meta.config_files to include it
    Sam Likins
    @samlikins
    @derks: is there already a mechanism for deriving the path to the project directory? I have one, but I don't want to re-implement it if one exists in the code-base already.
    Sam Likins
    @samlikins
    @derks when I was testing the example in Extending CementApp I noticed that if I attempted to access the "api" configurations in the "load" function they weren't there yet, but they were their at "pre_run". This was confusing to me, as the config must have been read to run the "load" function (as that is contingent on "enable_plugin" being true) at that time. Is this an intentional state? please explain.
    BJ Dierkes
    @derks
    @samlikins no, there isn’t anything official yet… If you make a Github feature request I’ll work on it, as it would be useful to have.
    The load() function is called durint app.setup() … so, you shouldn’t expect things to be ready to use in load()
    Some will work, some won’t… because it depends on the load order
    You want to do a post_setup or pre_run hook
    Sam Likins
    @samlikins
    @derks Thanks, I created datafolklabs/cement#485.
    BJ Dierkes
    @derks
    very good
    Sam Likins
    @samlikins
    @derks Without looking too hard I wanted to ask you if you've already implemented somewhere (or plan to do so in the future) an dependency injector service for cement. I've located dependency_injector on pypi and it looks like a somewhat reasonable package at first glance, just didn't want to blaze down old roads. Thanks.
    BJ Dierkes
    @derks
    @samlikins to be honest, dependency injection is new to me… and is not something I’ve looked at for Cement
    Sam Likins
    @samlikins
    @derks Okay, well I'm doing the footwork to see how best to implement it into a framework extension...
    BJ Dierkes
    @derks
    \