def plugme(app_config, options): if 'default_language' not in options: options['default_language'] = 'EN' if 'async_sender' not in options: options.update({'async_sender': 'tgext.asyncjob'}) app_config['_mailtemplates'] = options from mailtemplates import model milestones.config_ready.register(model.configure_models) if 'tgext.mailer' not in plugged(app_config): plug(app_config, 'tgext.mailer') if options['async_sender'] is None: pass elif options['async_sender'] == 'tgext.asyncjob': if 'tgext.asyncjob' not in plugged(app_config): plug(app_config, 'tgext.asyncjob') elif options['async_sender'] == 'tgext.celery': if 'tgext.celery' not in plugged(app_config): raise Exception( 'please plug and CONFIGURE tgext.celery by yourself') else: raise Exception('async_sender unknown') return dict(appid='mailtemplates', global_helpers=False)
def configure_app(): app_cfg = AppConfig(minimal=True) app_cfg.renderers = ['genshi'] app_cfg.default_renderer = 'genshi' app_cfg.use_dotted_templatenames = True app_cfg.package = FakeAppPackage() app_cfg.use_toscawidgets2 = True app_cfg['tw2.enabled'] = True app_cfg.sa_auth.authmetadata = TestAuthMetadata() app_cfg['beaker.session.secret'] = 'SECRET' app_cfg.auth_backend = 'sqlalchemy' app_cfg.sa_auth.cookie_secret = 'SECRET' app_cfg.package.model = FakeSQLAModel() app_cfg.use_sqlalchemy = True app_cfg['sqlalchemy.url'] = 'sqlite://' app_cfg.use_transaction_manager = True app_cfg['tm.enabled'] = True app_cfg.model = app_cfg.package.model app_cfg.DBSession = app_cfg.package.model.DBSession plug(app_cfg, 'calendarevents', event_types=[FakeEventType()], global_models=False, plug_bootstrap=False, form_instance=calendar_form) # This is to reset @cached_properties so they get reconfigured for new backend return app_cfg
def configure_app(using, create_form=True): # Simulate starting configuration process from scratch milestones._reset_all() app_cfg = AppConfig(minimal=True) app_cfg.renderers = ['kajiki'] app_cfg.default_renderer = 'kajiki' app_cfg.use_dotted_templatenames = True app_cfg.package = FakeAppPackage() app_cfg.use_toscawidgets2 = True app_cfg['tw2.enabled'] = True app_cfg.sa_auth.authmetadata = TestAuthMetadata() app_cfg['beaker.session.secret'] = app_cfg['session.secret'] = 'SECRET' app_cfg['mail.debugmailer'] = 'dummy' if using == 'sqlalchemy': app_cfg.auth_backend = 'sqlalchemy' app_cfg.package.model = FakeSQLAModel() app_cfg.use_sqlalchemy = True app_cfg['sqlalchemy.url'] = 'sqlite://' app_cfg.use_transaction_manager = True app_cfg['tm.enabled'] = True elif using == 'ming': app_cfg.auth_backend = 'ming' app_cfg.package.model = FakeMingModel() app_cfg.use_ming = True app_cfg['ming.url'] = 'mim:///testresetpassword' else: raise ValueError('Unsupported backend') # Reset the Sprox provider on every change of configuration. from resetpassword import model as resetpassword_model resetpassword_model.provider._provider = None app_cfg.model = app_cfg.package.model app_cfg.DBSession = app_cfg.package.model.DBSession # CUSTOM resetpassword options app_cfg['resetpassword.email_sender'] = '*****@*****.**' plug(app_cfg, 'tgext.mailer', plug_bootstrap=True, debugmailer='dummy') plug( app_cfg, 'resetpassword', plug_bootstrap=False, reset_password_form_instance=resetpassword_form if create_form else None, new_password_form_instance=newpassword_form if create_form else None, ) return app_cfg
def plugme(app_config, options): try: app_config['_pluggable_userprofile_config'] = options except TypeError: app_config.update_blueprint({'_pluggable_userprofile_config': options}) milestones.config_ready.register(model.configure_models) if 'resetpassword' not in plugged(config=app_config): plug(app_config, 'resetpassword') if 'tgext.mailer' not in plugged(config=app_config): plug(app_config, 'tgext.mailer') return dict(appid='userprofile', global_helpers=False)
def configure_app(using): # Simulate starting configuration process from scratch milestones._reset_all() app_cfg = AppConfig(minimal=True) app_cfg.renderers = ['kajiki'] app_cfg.default_renderer = 'kajiki' app_cfg.use_dotted_templatenames = True app_cfg.package = FakeAppPackage() app_cfg.use_toscawidgets2 = True app_cfg.sa_auth.authmetadata = TestAuthMetadata() app_cfg['beaker.session.secret'] = app_cfg['session.secret'] = 'SECRET' app_cfg.auth_backend = 'ming' app_cfg['mail.debugmailer'] = 'dummy' if using == 'sqlalchemy': app_cfg.package.model = FakeSQLAModel() app_cfg.use_sqlalchemy = True app_cfg['sqlalchemy.url'] = 'sqlite://' app_cfg.use_transaction_manager = True elif using == 'ming': app_cfg.package.model = FakeMingModel() app_cfg.use_ming = True app_cfg['ming.url'] = 'mim:///testregistration' else: raise ValueError('Unsupported backend') app_cfg.model = app_cfg.package.model app_cfg.DBSession = app_cfg.package.model.DBSession # CUSTOM registration options app_cfg['registration.email_sender'] = '*****@*****.**' from registration.lib import send_email, get_form # Guarantee that the same form is used between multiple # configurations of TGApps. Otherwise the validated # form would be different from the displayed one. plug_args = {} if '_pluggable_registration_config' in config: plug_args['form_instance'] = get_form() plug(app_cfg, 'tgext.mailer', plug_bootstrap=True, debugmailer='dummy') plug(app_cfg, 'registration', plug_bootstrap=False, **plug_args) return app_cfg
def configure_app(using): # Simulate starting configuration process from scratch milestones._reset_all() app_cfg = AppConfig(minimal=True) app_cfg.renderers = ['kajiki'] app_cfg.default_renderer = 'kajiki' app_cfg.use_dotted_templatenames = True app_cfg.package = FakeAppPackage() app_cfg.use_toscawidgets2 = True app_cfg['beaker.session.secret'] = app_cfg['session.secret'] = 'SECRET' app_cfg['mail.debugmailer'] = "dummy" if using == 'sqlalchemy': app_cfg.auth_backend = 'sqlalchemy' app_cfg.package.model = FakeSQLAModel() app_cfg.use_sqlalchemy = True app_cfg['sqlalchemy.url'] = 'sqlite://' app_cfg.use_transaction_manager = True app_cfg.SQLASession = app_cfg.package.model.DBSession elif using == 'ming': app_cfg.auth_backend = 'ming' app_cfg.package.model = FakeMingModel() app_cfg.use_ming = True app_cfg['ming.url'] = 'mim:///userprofile' app_cfg.MingSession = app_cfg.package.model.DBSession else: raise ValueError('Unsupported backend') app_cfg.model = app_cfg.package.model app_cfg.DBSession = app_cfg.package.model.DBSession app_cfg.sa_auth.authmetadata = TestAuthMetadata() # Guarantee that the same form is used between multiple # configurations of TGApps. Otherwise the validated # form would be different from the displayed one. app_cfg['userprofile.email_sender'] = '[email protected]' plug(app_cfg, 'userprofile', plug_bootstrap=True) return app_cfg
def configure_app(using): # Simulate starting configuration process from scratch milestones._reset_all() app_cfg = AppConfig(minimal=True) app_cfg.renderers = ['kajiki'] app_cfg.default_renderer = 'kajiki' app_cfg.use_dotted_templatenames = True app_cfg.package = FakeAppPackage() app_cfg.use_toscawidgets2 = True app_cfg['tw2.enabled'] = True app_cfg.sa_auth.authmetadata = TestAuthMetadata() app_cfg['beaker.session.secret'] = app_cfg['session.secret'] = 'SECRET' app_cfg.auth_backend = 'ming' app_cfg['mail.debugmailer'] = "dummy" if using == 'sqlalchemy': app_cfg.package.model = FakeSQLAModel() app_cfg.use_sqlalchemy = True app_cfg['sqlalchemy.url'] = 'sqlite://' app_cfg.use_transaction_manager = True app_cfg['tm.enabled'] = True app_cfg.SQLASession = app_cfg.package.model.DBSession elif using == 'ming': app_cfg.package.model = FakeMingModel() app_cfg.use_ming = True app_cfg['ming.url'] = 'mim:///mailtemapltes' app_cfg.MingSession = app_cfg.package.model.DBSession else: raise ValueError('Unsupported backend') app_cfg.model = app_cfg.package.model app_cfg.DBSession = app_cfg.package.model.DBSession # Guarantee that the same form is used between multiple # configurations of TGApps. Otherwise the validated # form would be different from the displayed one. plug(app_cfg, 'tgext.mailer', plug_bootstrap=True, debugmailer='dummy') plug(app_cfg, 'tgext.asyncjob', plug_bootstrap=True, app_globals=app_cfg['app_globals']) # it is important that tgext.mailer and tgext.asyncjob are plugged # before mailtemplates or not plugged at all as mailtemplates plugs them plug(app_cfg, 'mailtemplates', plug_bootstrap=True, default_language='EN') return app_cfg
# change the way users can login # 'sa_auth.authenticators': [('myauth', SomeAuthenticator()], # You can add more repoze.who metadata providers to fetch # user metadata. # Remember to set 'sa_auth.authmetadata' to None # to disable authmetadata and use only your own metadata providers # 'sa_auth.mdproviders': [('myprovider', SomeMDProvider()], }) try: # Enable DebugBar if available, install tgext.debugbar to turn it on from tgext.debugbar import enable_debugbar enable_debugbar(base_config) except ImportError: pass plug(base_config, 'tgext.mailer') plug(base_config, 'registration') plug(base_config, 'resetpassword') def enable_depot(): # DEPOT setup from depot.manager import DepotManager DepotManager.configure('contact_images', config, 'depot.contact_images.') DepotManager.alias('contact_image', 'contact_images') milestones.config_ready.register(enable_depot)
# user metadata. # Remember to set base_config.sa_auth.authmetadata to None # to disable authmetadata and use only your own metadata providers #base_config.sa_auth.mdproviders = [('myprovider', SomeMDProvider()] # override this if you would like to provide a different who plugin for # managing login and logout of your application base_config.sa_auth.form_plugin = None # You may optionally define a page where you want users to be redirected to # on login: base_config.sa_auth.post_login_url = '/post_login' # You may optionally define a page where you want users to be redirected to # on logout: base_config.sa_auth.post_logout_url = '/post_logout' try: # Enable DebugBar if available, install tgext.debugbar to turn it on from tgext.debugbar import enable_debugbar enable_debugbar(base_config) except ImportError: pass from tgext.pluggable import plug plug(base_config, 'stroller2') plug(base_config, 'tgext.ecommerce', edit_order_form='sample_ecommerce.config.ecommerce_hooks.EditOrderForm')
# You can use a different repoze.who Authenticator if you want to # change the way users can login # 'sa_auth.authenticators': [('myauth', SomeAuthenticator()], # You can add more repoze.who metadata providers to fetch # user metadata. # Remember to set 'sa_auth.authmetadata' to None # to disable authmetadata and use only your own metadata providers # 'sa_auth.mdproviders': [('myprovider', SomeMDProvider()], }) try: # Enable DebugBar if available, install tgext.debugbar to turn it on from tgext.debugbar import enable_debugbar enable_debugbar(base_config) except ImportError: pass from tgext.pluggable import plug plug( base_config, 'tgext.ecommerce', edit_order_form='sampleecommerce.config.ecommerce_hooks.EditOrderForm', global_models=True ) plug( base_config, 'stroller2', global_models=True )
# Remember to set base_config.sa_auth.authmetadata to None # to disable authmetadata and use only your own metadata providers # base_config.sa_auth.mdproviders = [('myprovider', SomeMDProvider()] # override this if you would like to provide a different who plugin for # managing login and logout of your application base_config.sa_auth.form_plugin = None # You may optionally define a page where you want users to be redirected to # on login: base_config.sa_auth.post_login_url = '/post_login' # You may optionally define a page where you want users to be redirected to # on logout: base_config.sa_auth.post_logout_url = '/post_logout' try: # Enable DebugBar if available, install tgext.debugbar to turn it on from tgext.debugbar import enable_debugbar enable_debugbar(base_config) except ImportError: pass from tgext.pluggable import plug plug(base_config, 'risk') plug(base_config, 'indicator') plug(base_config, 'project') plug(base_config, 'maintenance') plug(base_config, 'datacenter') plug(base_config, 'computer') plug(base_config, 'questionaires', appid='quest')
#add logservice import tgext.pylogservice tgext.pylogservice.plugme(base_config) #add utilservice import tgext.pyutilservice tgext.pyutilservice.plugme(base_config) #add sendmailservice #import tgext.sendmailservice #tgext.sendmailservice.plugme(base_config) #add facebook from tgext.pluggable import plug plug(base_config, 'fbauth') # extension pypollsocial plug(base_config, 'pypollsocial') # extension googleplusauth #plug(base_config, 'googleplusauth') ##plug(base_config, module_name='pypollmanage', appid='manage') #extension pypollwebservice #plug(base_config, module_name='pypollwebservice', appid='webservice') #plug(base_config, module_name='managepoll', appid='managepoll')
# override this if you would like to provide a different who plugin for # managing login and logout of your application base_config.sa_auth.form_plugin = None # You may optionally define a page where you want users to be redirected to # on login: base_config.sa_auth.post_login_url = '/post_login' # You may optionally define a page where you want users to be redirected to # on logout: base_config.sa_auth.post_logout_url = '/post_logout' # INFO - This is the way to specialize the resetpassword email properties # plug(base_config, 'resetpassword', None, mail_subject=reset_password_email_subject) plug(base_config, 'resetpassword', 'reset_password') replace_template(base_config, 'resetpassword.templates.index', 'tracim.templates.reset_password_index') replace_template(base_config, 'resetpassword.templates.change_password', 'mako:tracim.templates.reset_password_change_password') # Note: here are fake translatable strings that allow to translate messages for reset password email content duplicated_email_subject = l_('Password reset request') duplicated_email_body = l_(''' We've received a request to reset the password for this account. Please click this link to reset your password: %(password_reset_link)s If you no longer wish to make the above change, or if you did not initiate this request, please disregard and/or delete this e-mail. ''')
# delete it for already displayed messages. The template will receive: # $container_id, $cookie_name, $js_call variables. base_config['templating.genshi.name_constant_patch'] = True # Configure the authentication backend # YOU MUST CHANGE THIS VALUE IN PRODUCTION TO SECURE YOUR APP base_config.sa_auth.cookie_secret = "3283411b-1904-4554-b0e1-883863b53080" # INFO - This is the way to specialize the resetpassword email properties # plug(base_config, # 'resetpassword', # None, # mail_subject=reset_password_email_subject) plug(base_config, 'resetpassword', 'reset_password') replace_template(base_config, 'resetpassword.templates.index', 'tracim.templates.reset_password_index') replace_template(base_config, 'resetpassword.templates.change_password', 'mako:tracim.templates.reset_password_change_password') daemons = DaemonsManager() def start_daemons(manager: DaemonsManager): """Start Tracim daemons.""" from tg import config cfg = CFG.get_instance()
</div> ''' # -> string.Template instance used as the flash template when rendered from server side, will receive $container_id, $message and $status variables. # flash.js_call -> javascript code which will be run when displaying the flash from javascript. Default is webflash.render(), you can use webflash.payload() to retrieve the message and show it with your favourite library. # flash.js_template -> string.Template instance used to replace full javascript support for flash messages. When rendering flash message for javascript usage the following code will be used instead of providing the standard webflash object. If you replace js_template you must also ensure cookie parsing and delete it for already displayed messages. The template will receive: $container_id, $cookie_name, $js_call variables. base_config['templating.genshi.name_constant_patch'] = True # Configure the authentication backend # YOU MUST CHANGE THIS VALUE IN PRODUCTION TO SECURE YOUR APP base_config.sa_auth.cookie_secret = "3283411b-1904-4554-b0e1-883863b53080" # INFO - This is the way to specialize the resetpassword email properties # plug(base_config, 'resetpassword', None, mail_subject=reset_password_email_subject) plug(base_config, 'resetpassword', 'reset_password') replace_template(base_config, 'resetpassword.templates.index', 'tracim.templates.reset_password_index') replace_template(base_config, 'resetpassword.templates.change_password', 'mako:tracim.templates.reset_password_change_password') daemons = DaemonsManager() def start_daemons(manager: DaemonsManager): """ Sart Tracim daemons """ from tg import config cfg = CFG.get_instance()
from etl.config.evolutions.e01_options_dict import EvolveOptionsDict from etl.config.evolutions.tgappcategories import CategoriesPermissions from etl.config.evolutions.dashboard_creation import DashboardCreationEvolution tgext.evolve.plugme(base_config, options={ 'evolutions': [ EvolveOptionsDict, CategoriesPermissions, DashboardCreationEvolution, ], }) from tgext.pluggable import plug plug(base_config, 'tgappcategories', 'categories', global_models=True, plug_bootstrap=True) from tgext.webassets import Bundle plug( base_config, 'tgext.webassets', # debug=True, bundles={ 'js_all': Bundle( 'javascript/jquery.1.11.1.min.js', 'javascript/jquery.tablesorter.min.js', 'javascript/bootstrap.min.js', 'javascript/toastr.min.js',
return [g.group_name for g in identity['user'].groups] def get_permissions(self, identity, userid): return [] base_config.sa_auth.authmetadata = ApplicationAuthMetadata(base_config.sa_auth) # You can use a different repoze.who Authenticator if you want to # change the way users can login #base_config.sa_auth.authenticators = [('myauth', SomeAuthenticator()] # You can add more repoze.who metadata providers to fetch # user metadata. # Remember to set base_config.sa_auth.authmetadata to None # to disable authmetadata and use only your own metadata providers #base_config.sa_auth.mdproviders = [('myprovider', SomeMDProvider()] # override this if you would like to provide a different who plugin for # managing login and logout of your application base_config.sa_auth.form_plugin = None # You may optionally define a page where you want users to be redirected to # on login: base_config.sa_auth.post_login_url = '/post_login' # You may optionally define a page where you want users to be redirected to # on logout: base_config.sa_auth.post_logout_url = '/post_logout' from tgext.pluggable import plug plug(base_config, 'registration')
</div> ''' # -> string.Template instance used as the flash template when rendered from server side, will receive $container_id, $message and $status variables. # flash.js_call -> javascript code which will be run when displaying the flash from javascript. Default is webflash.render(), you can use webflash.payload() to retrieve the message and show it with your favourite library. # flash.js_template -> string.Template instance used to replace full javascript support for flash messages. When rendering flash message for javascript usage the following code will be used instead of providing the standard webflash object. If you replace js_template you must also ensure cookie parsing and delete it for already displayed messages. The template will receive: $container_id, $cookie_name, $js_call variables. base_config['templating.genshi.name_constant_patch'] = True # Configure the authentication backend # YOU MUST CHANGE THIS VALUE IN PRODUCTION TO SECURE YOUR APP base_config.sa_auth.cookie_secret = "3283411b-1904-4554-b0e1-883863b53080" # INFO - This is the way to specialize the resetpassword email properties # plug(base_config, 'resetpassword', None, mail_subject=reset_password_email_subject) plug(base_config, 'resetpassword', 'reset_password') replace_template(base_config, 'resetpassword.templates.index', 'tracim.templates.reset_password_index') replace_template(base_config, 'resetpassword.templates.change_password', 'mako:tracim.templates.reset_password_change_password') daemons = DaemonsManager() def start_daemons(manager: DaemonsManager): """ Sart Tracim daemons """ from tg import config # Don't start daemons if they are disabled
return [g.group_name for g in identity['user'].groups] def get_permissions(self, identity, userid): return [p.permission_name for p in identity['user'].permissions] base_config.sa_auth.authmetadata = ApplicationAuthMetadata(base_config.sa_auth) # You can use a different repoze.who Authenticator if you want to # change the way users can login #base_config.sa_auth.authenticators = [('myauth', SomeAuthenticator()] # You can add more repoze.who metadata providers to fetch # user metadata. # Remember to set base_config.sa_auth.authmetadata to None # to disable authmetadata and use only your own metadata providers #base_config.sa_auth.mdproviders = [('myprovider', SomeMDProvider()] # override this if you would like to provide a different who plugin for # managing login and logout of your application base_config.sa_auth.form_plugin = None # You may optionally define a page where you want users to be redirected to # on login: base_config.sa_auth.post_login_url = '/post_login' # You may optionally define a page where you want users to be redirected to # on logout: base_config.sa_auth.post_logout_url = '/post_logout' from tgext.pluggable import plug plug(base_config, 'tgextecommerce')
webassets.Bundle(webassets.Bundle('css/vendors/new-age/new-age.scss', filters='libsass', output='assets_debug/new-age.css'), filters='cssmin', output='assets/new-age.css') }) # try: # # Enable DebugBar if available, install tgext.debugbar to turn it on # from tgext.debugbar import enable_debugbar # enable_debugbar(base_config) # except ImportError: # pass from tgext.pluggable import plug plug(base_config, 'tgext.mailer') plug(base_config, 'registration', global_models=True) plug(base_config, 'tgext.evolve', global_models=True, evolutions=evolutions) from ksweb.config.registration_hooks import RegistrationHooks RegistrationHooks.register(base_config) plug(base_config, 'resetpassword', reset_password_form='ksweb.lib.forms.ResetPasswordForm', new_password_form='ksweb.lib.forms.NewPasswordForm') from tgext.pluggable import replace_template replace_template(base_config, 'resetpassword.templates.index', 'ksweb.templates.resetpassword.index') plug(base_config, 'tgextodt') plug(base_config, 'userprofile')
# You can use a different repoze.who Authenticator if you want to # change the way users can login # base_config.sa_auth.authenticators = [('myauth', SomeAuthenticator()] # You can add more repoze.who metadata providers to fetch # user metadata. # Remember to set base_config.sa_auth.authmetadata to None # to disable authmetadata and use only your own metadata providers # base_config.sa_auth.mdproviders = [('myprovider', SomeMDProvider()] # override this if you would like to provide a different who plugin for # managing login and logout of your application base_config.sa_auth.form_plugin = None # You may optionally define a page where you want users to be redirected to # on login: base_config.sa_auth.post_login_url = '/post_login' # You may optionally define a page where you want users to be redirected to # on logout: base_config.sa_auth.post_logout_url = '/post_logout' try: # Enable DebugBar if available, install tgext.debugbar to turn it on from tgext.debugbar import enable_debugbar enable_debugbar(base_config) except ImportError: pass plug(base_config, 'registration') plug(base_config, 'tgext.mailer')
# You can use a different repoze.who Authenticator if you want to # change the way users can login # base_config.sa_auth.authenticators = [('myauth', SomeAuthenticator()] # You can add more repoze.who metadata providers to fetch # user metadata. # Remember to set base_config.sa_auth.authmetadata to None # to disable authmetadata and use only your own metadata providers # base_config.sa_auth.mdproviders = [('myprovider', SomeMDProvider()] # override this if you would like to provide a different who plugin for # managing login and logout of your application base_config.sa_auth.form_plugin = None # You may optionally define a page where you want users to be redirected to # on login: base_config.sa_auth.post_login_url = '/post_login' # You may optionally define a page where you want users to be redirected to # on logout: base_config.sa_auth.post_logout_url = '/post_logout' #try: # Enable DebugBar if available, install tgext.debugbar to turn it on # from tgext.debugbar import enable_debugbar # enable_debugbar(base_config) #except ImportError: # pass plug(base_config, 'tgext.mailer')
# You can use a different repoze.who Authenticator if you want to # change the way users can login # base_config.sa_auth.authenticators = [('myauth', SomeAuthenticator()] # You can add more repoze.who metadata providers to fetch # user metadata. # Remember to set base_config.sa_auth.authmetadata to None # to disable authmetadata and use only your own metadata providers # base_config.sa_auth.mdproviders = [('myprovider', SomeMDProvider()] # override this if you would like to provide a different who plugin for # managing login and logout of your application base_config.sa_auth.form_plugin = None # You may optionally define a page where you want users to be redirected to # on login: base_config.sa_auth.post_login_url = '/post_login' # You may optionally define a page where you want users to be redirected to # on logout: base_config.sa_auth.post_logout_url = '/post_logout' try: # Enable DebugBar if available, install tgext.debugbar to turn it on from tgext.debugbar import enable_debugbar enable_debugbar(base_config) except ImportError: pass plug(base_config, 'registration')