On Mon, Oct 3, 2011 at 10:11 AM, Bruno Rocha <rochacbr...@gmail.com> wrote:
> You can always set
> if x:
> response.view = 'folder/file.html'
> elif y:
> response.view = '....'
> Also, you can use:
> def action:
>      return response.render("file.html", dict(context=context))
>
I tried this with the following code in my controller:

        if (isinstance(p, TestProtocol)):
            response.view = "connection/templates/test.html"


and I get this error:
Traceback (most recent call last):
  File "/home/mbroadstone/app/src/web2py/gluon/template.py", line 437,
in _get_file_text
    fileobj = open(filepath, 'rb')
IOError: [Errno 2] No such file or directory:
'/home/mbroadstone/app/src/web2py/applications/app/views/../edit.html'

I then tried to print out what response.view should have been prior,
and it contained "connection/edit.html" as expected. What am I doing
wrong here?

Matt


> On Mon, Oct 3, 2011 at 10:16 AM, Matt Broadstone <mbroa...@gmail.com> wrote:
>>
>> Good morning,
>>   I have a situation where I want to display composite views (a view
>> for an object inside a view for its parent object). I have a class
>> Connection that has a Profile associated with it. Profile can be one
>> of a number of different subclasses (AProfile, BProfile, CProfile). I
>> also have views associated for each of the profiles, within a
>> "template" directory under the "views/connection" directory. The way
>> I've tried to go about solving this is to make a view.html (associated
>> with the view() method in the controller) as a base template with a
>> block for "profile_section" inside of it. Then, in each of the profile
>> templates, I extend view.html and then fill out the block for the
>> profile.
>>
>> The problem I am now facing is how to properly route to the right
>> template file from within the controller's view method. I know I could
>> just create a new method in the controller for each profile type, but
>> I'd rather not do that if possible. I also think that a simple
>> redirect is not the right solution here. Can anyone advise as to the
>> best way to do this? Or am I just on the wrong track with the whole
>> "extend" idea?
>>
>> Thank you,
>> Matt
>
>
>
> --
>
>
>
> --
> Bruno Rocha
> [ About me: http://zerp.ly/rochacbruno ]
> [ Aprenda a programar: http://CursoDePython.com.br ]
> [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
> [ Consultoria em desenvolvimento web: http://www.blouweb.com ]
>

Reply via email to