Add the variable to the return value of your new function:

@expose('amandmani.templates.crud_new', inherit=True)
    def new(self,  *args, **kw):
        params = super(AmendmentController_1, self).new(*args, **kw)
        params['rtt'] = self.rtt
        return params

You get the return params from the parent class, then add your rtt value
and then finally return it for the template to render.

Disclaimer: I don't have a chance right now to test this but I think it
should work or something along the lines.

Regards,
Carlos Ruvalcaba


On Mon, Jan 6, 2014 at 4:51 AM, puska <[email protected]> wrote:

> Hi,
>
> I am trying to customize new.html sprox template in order to show custom
> text as the page title, based on
> http://turbogears.readthedocs.org/en/latest/cookbook/Crud/index.html#overriding-templates.
>  To achieve that I customized new.html template to look like this:
>
> <head>
>     <title>${tmpl_context.title} - New ${model} ${*rtt*} - Unos</title>
>     <style>
>         ${Markup(tmpl_context.crud_style)}
>     </style>
> </head>
>
> In order to pass new argument *rtt* I did the following:
>
> class AmendmentController_1(CrudRestController):
>     allow_only = predicates.in_group('users')
>     model = Amendments
>     title = 'Amandmani'
>
>     @expose('amandmani.templates.crud_new', inherit=True)
>     def new(self,  *args, **kw):
>         return super(AmendmentController_1, self).new(*args, **kw)
>
>     class Add_form(AddRecordForm):
>         __model__ = Amendments
>         __omit_fields__ = ['id', 'name_str'] #, 'operator_id',
> 'output_files', 'barcodes', 'operators', 'access_date'
>         __field_order__ = ['bill_id', 'name', 'desc']
>
>         def __init__(self,  session,  *rtt*,  *args,  **kw):
>             super(AddRecordForm,  self).__init__(session,  *args,  **kw)
>             self.*rtt* = *rtt*
>
>     table = Table(DBSession)
>     table_filler = Table_filler(DBSession)
>     new_form = Add_form(DBSession,  *'Test'*)
>
> but I am getting:
>
> File
> "/home/puska/src/turbogears/2.3.1/lib/python2.7/site-packages/Genshi-0.7-py2.7-linux-x86_64.egg/genshi/template/eval.py",
> line *413*, in undefined
>
> raise UndefinedError(key, owner=owner)
> UndefinedError: "rtt" not defined
>
> How should arguments be properly passed to a customized template for 
> rendering?
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/turbogears.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to