pombreda / formalchemy

Automatically exported from code.google.com/p/formalchemy
MIT License
0 stars 0 forks source link

Cannot use FAs admin if other than mako engine used in project #139

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. paster create -t pylons_fa testproj
2. admin_controller: True, template_engine: genshi (NOT mako!), sqlalchemy:
True
3. paster serve development.ini; browse 127.0.0.1:5000/admin

What is the expected output? What do you see instead?
Expected: "Models" page of admin controller
Instead: exception 'Globals' does not have attribute 'mako_lookup'

What version of the product are you using? On what operating system?
Pylons-0.10rc1-py2.6.egg
FormAlchemy-1.3.2-py2.6.egg

Please provide any additional information below.
Honestly I do not know if it's FA's or Pylons' issue. I think that maybe
pylons_fa template should be changed so that other than mako engines could
be used in projects?

Original issue reported on code.google.com by mihail.l...@gmail.com on 2 Apr 2010 at 9:12

GoogleCodeExporter commented 9 years ago
Only mako is supported. But I think you can adapt the template engine in 
forms/__init__.py so:

1/ it can render mako template even if you use genshi

2/ it render your genshi templates

I guess 1 is the easy way. You need to set the proper config in pylons to also 
support mako template and use 
render_mako instead of render in forms/__init__

Feedback welcome.

Original comment by gael.pas...@gmail.com on 2 Apr 2010 at 10:19

GoogleCodeExporter commented 9 years ago
In forms/__init__ I can fix _forms_ rendering, but the issue is in admin 
interface,
not just forms.
I added few lines in config.environment module of my project:
== cut ==
...
from mako.lookup import TemplateLookup
from pylons.error import handle_mako_error
...
def load_environment(global_conf, app_conf):
    ...
    # Create the Mako TemplateLookup, with the default auto-escaping
    config['pylons.app_globals'].mako_lookup = TemplateLookup(
        directories=paths['templates'],
        error_handler=handle_mako_error,
        module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
        input_encoding='utf-8', default_filters=['escape'],
        imports=['from webhelpers.html import escape'])
        ...
== cut ==

and exception (AttributeError: 'Globals' object has no attribute 'mako_lookup') 
is
gone, but http://127.0.0.1:5000/admin now returns no response (zero-length 
content
returned). I don't know how I can debug as it raises no exception and I'm not
familiar enough with FA/pylons source code to find an issue...

Original comment by mihail.l...@gmail.com on 2 Apr 2010 at 3:19

GoogleCodeExporter commented 9 years ago
try to set an engine attribute to your controller:

class Ctrl(..):
    engine = forms.engine

If it does not fix the problem I cant really help without any traceback.

Original comment by gael.pas...@gmail.com on 2 Apr 2010 at 9:52

GoogleCodeExporter commented 9 years ago
I assume that this fix the problem.

Original comment by gael.pas...@gmail.com on 19 Apr 2010 at 6:28