Patchwork pages?

View: New views
10 Messages — Rating Filter:   Alert me  

Patchwork pages?

by mettwoch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

I've a question about merging multiple results from multiple
controllers and templates together. The problem raises when I have a 1
to many relationship to represent. Let's say an invoice (with Nr,
date, customer, ...) and below the invoice lines. I'ld like to have
separate controllers for the invoice detail with a "form"template
exposed and another controller with a "list"template exposed and get
the page put together from these pieces.

How should I do it the right way?

Marc
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Patchwork pages?

by Daniel Fetchinson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> I've a question about merging multiple results from multiple
> controllers and templates together. The problem raises when I have a 1
> to many relationship to represent. Let's say an invoice (with Nr,
> date, customer, ...) and below the invoice lines. I'ld like to have
> separate controllers for the invoice detail with a "form"template
> exposed and another controller with a "list"template exposed and get
> the page put together from these pieces.

Could you explain it more clearly what you mean?
I simply don't understand what you try to accomplish.

Cheers,
Daniel
--
Psss, psss, put it down! - http://www.cafepress.com/putitdown

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Patchwork pages?

by Diez B. Roggisch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Tuesday 01 July 2008 15:35:35 mettwoch wrote:

> Hi,
>
> I've a question about merging multiple results from multiple
> controllers and templates together. The problem raises when I have a 1
> to many relationship to represent. Let's say an invoice (with Nr,
> date, customer, ...) and below the invoice lines. I'ld like to have
> separate controllers for the invoice detail with a "form"template
> exposed and another controller with a "list"template exposed and get
> the page put together from these pieces.
>
> How should I do it the right way?

Separate controllers is not the way, at least not in TG. But you can use
Widgets to separate the representation of various items of your pages, and in
a controller gather data & widgets that you return then to be rendered in
your template.

Diez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Patchwork pages?

by mettwoch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

The point is that if you have let's say an invoice to show/edit, you
need to provide a form with the invoice-number, invoice-date,
customer, employee, ... . That's the "1" side of the relation ship. A
simple formwidget and the associated controller method does the job.
Now below this form, on the same page I'ld like to present the
productlines bought in a list style display. That's the "many" side of
the relation. Is there a way to have another controller method to
provide the data for that list with an @expose(d) template to display
that list and that I can "include" below the form in the first
template.

Thx for any advice

On Jul 2, 5:23 am, "Daniel Fetchinson" <fetchin...@...>
wrote:

> > I've a question about merging multiple results from multiple
> > controllers and templates together. The problem raises when I have a 1
> > to many relationship to represent. Let's say an invoice (with Nr,
> > date, customer, ...) and below the invoice lines. I'ld like to have
> > separate controllers for the invoice detail with a "form"template
> > exposed and another controller with a "list"template exposed and get
> > the page put together from these pieces.
>
> Could you explain it more clearly what you mean?
> I simply don't understand what you try to accomplish.
>
> Cheers,
> Daniel
> --
> Psss, psss, put it down! -http://www.cafepress.com/putitdown
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Patchwork pages?

by Jorge Godoy-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wednesday 02 July 2008 06:07:48 Diez B. Roggisch wrote:

> On Tuesday 01 July 2008 15:35:35 mettwoch wrote:
> > Hi,
> >
> > I've a question about merging multiple results from multiple
> > controllers and templates together. The problem raises when I have a 1
> > to many relationship to represent. Let's say an invoice (with Nr,
> > date, customer, ...) and below the invoice lines. I'ld like to have
> > separate controllers for the invoice detail with a "form"template
> > exposed and another controller with a "list"template exposed and get
> > the page put together from these pieces.
> >
> > How should I do it the right way?
>
> Separate controllers is not the way, at least not in TG. But you can use
> Widgets to separate the representation of various items of your pages, and
> in a controller gather data & widgets that you return then to be rendered
> in your template.
It would be easier to do as Diez says.

But you can do the way you want using AJAX.

When you update the master. you trigger some event to update the detail part.  
So, when you have the invoice list ready you start some JS that will check the
selected entry and get the details for that specific invoice.  When the user
selects another invoice, you trigger another event that will update the list
and so on.

But using widgets is easier to get this done and to get the JS code inserted
and run at the right time.

--
Jorge Godoy      <jgodoy@...>




signature.asc (204 bytes) Download Attachment

Re: Patchwork pages?

by mettwoch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

I only partially agree because one same controller has to supply the
dictionary with all the data for all the widgets on that single page.
I believe that it's not the right way to write reusable code. A
controller method should be specialized for one purpose and should be
reusable along with it's (partial) template to display on a "composed"
page.

Marc

On Jul 2, 11:07 am, "Diez B. Roggisch" <de...@...> wrote:

> On Tuesday 01 July 2008 15:35:35 mettwoch wrote:
>
> > Hi,
>
> > I've a question about merging multiple results from multiple
> > controllers and templates together. The problem raises when I have a 1
> > to many relationship to represent. Let's say an invoice (with Nr,
> > date, customer, ...) and below the invoice lines. I'ld like to have
> > separate controllers for the invoice detail with a "form"template
> > exposed and another controller with a "list"template exposed and get
> > the page put together from these pieces.
>
> > How should I do it the right way?
>
> Separate controllers is not the way, at least not in TG. But you can use
> Widgets to separate the representation of various items of your pages, and in
> a controller gather data & widgets that you return then to be rendered in
> your template.
>
> Diez
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Patchwork pages?

by Diez B. Roggisch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Wednesday 02 July 2008 13:12:08 mettwoch wrote:
> Hi,
>
> I only partially agree because one same controller has to supply the
> dictionary with all the data for all the widgets on that single page.
> I believe that it's not the right way to write reusable code. A
> controller method should be specialized for one purpose and should be
> reusable along with it's (partial) template to display on a "composed"
> page.

A controller method is responsible for serving one page. That's the design TG
uses, and there isn't much you can do about that.

You are of course free to call other controller methods inside your controller
to get a dict with prepared values, or use support methods/functions to do
so. And you might even be able to delegate that to the template, using the
template to pull data instead of pushing it through the returned controller
method dict.

Diez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Patchwork pages?

by mettwoch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


What about Kid's document() function?
Couldn't we imagine to use this to "call" parts together from
different controllers with their associated template fragments?
What's the purpose of the fragment parameter in the expose decorator?

Admittedly I really don't feel comfortable with all that Ajax stuff
(sorry I'm 42 ;-) and moved a hard way from terminal app's to the web
so far) and I need another, more classic way to achieve a similar
result.

Please don't misunderstand me! I really like TG. I've been looking
around more than 5 years and closely followed Webkit, TG, Django,
Pylons ... and finally decided several months ago to use TG with MySQL
to write an integrated POS and BO system for the shop I'm running. TG
is a great deal and allows me to do things in such a natural way that
I sometimes can't believe it's so easy. But, I really miss a simple
way to do what I've described above. I really think that this is a
missing feature.

Marc

On Jul 2, 1:45 pm, "Diez B. Roggisch" <de...@...> wrote:

> On Wednesday 02 July 2008 13:12:08 mettwoch wrote:
>
> > Hi,
>
> > I only partially agree because one same controller has to supply the
> > dictionary with all the data for all the widgets on that single page.
> > I believe that it's not the right way to write reusable code. A
> > controller method should be specialized for one purpose and should be
> > reusable along with it's (partial) template to display on a "composed"
> > page.
>
> A controller method is responsible for serving one page. That's the design TG
> uses, and there isn't much you can do about that.
>
> You are of course free to call other controller methods inside your controller
> to get a dict with prepared values, or use support methods/functions to do
> so. And you might even be able to delegate that to the template, using the
> template to pull data instead of pushing it through the returned controller
> method dict.
>
> Diez
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Patchwork pages?

by Diez B. Roggisch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Wednesday 02 July 2008 14:30:23 mettwoch wrote:
> What about Kid's document() function?

Not really helping, as it does not provide means for passing needed parameters
and such.

> Couldn't we imagine to use this to "call" parts together from
> different controllers with their associated template fragments?
> What's the purpose of the fragment parameter in the expose decorator?

It might be helpful. What is missing is a way to essentially dispatch a call
to a controller method by a path, from within a template.

Out of my head I don't know how to do that, but you should be able to get a
hold on the root controller and then work your way down.

Admittedly, there is some magic cherrypy does you need to mimic, such as
dispatching to default() or index().

Once you have such a function, you can put it into the template namespace and
call it using py:replace and such.

> Please don't misunderstand me! I really like TG. I've been looking
> around more than 5 years and closely followed Webkit, TG, Django,
> Pylons ... and finally decided several months ago to use TG with MySQL
> to write an integrated POS and BO system for the shop I'm running. TG
> is a great deal and allows me to do things in such a natural way that
> I sometimes can't believe it's so easy. But, I really miss a simple
> way to do what I've described above. I really think that this is a
> missing feature.

You might have a point there - however, so far I'm not aware of a canned
solution.

Diez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Patchwork pages?

by mettwoch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I think I'll not force the use of TG in a way it's not designed for.
So I'll go the "widgets" way of doing it. But maybe someone of the TG
gurus sees a way (or even a need?) of implementing that "modular" page
feature in the future. It might be nice having multiple lists
(paginating) and forms on the same page and handled by their dedicated
controller.

Thanks for all your kind replies

On Jul 2, 11:07 am, "Diez B. Roggisch" <de...@...> wrote:

> On Tuesday 01 July 2008 15:35:35 mettwoch wrote:
>
> > Hi,
>
> > I've a question about merging multiple results from multiple
> > controllers and templates together. The problem raises when I have a 1
> > to many relationship to represent. Let's say an invoice (with Nr,
> > date, customer, ...) and below the invoice lines. I'ld like to have
> > separate controllers for the invoice detail with a "form"template
> > exposed and another controller with a "list"template exposed and get
> > the page put together from these pieces.
>
> > How should I do it the right way?
>
> Separate controllers is not the way, at least not in TG. But you can use
> Widgets to separate the representation of various items of your pages, and in
> a controller gather data & widgets that you return then to be rendered in
> your template.
>
> Diez
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---