I have a website where essentially the same page needs to be viewed in two (or 
more locations). In particular, I have a page where the user can edit their 
personal profile information, and I would also like an administrator to be able 
to edit any user's profile.  Keeping things DRY, I feel I should use the bulk 
of the same code for both pages.

The biggest difference with the page in two different locations is that certain 
links (such as cancel) need to link to a different page depending on which page 
linked to the profile edit page.  I've come up with several ways that this 
could be handled. Which one is the best practice (or is there a better way that 
I've completely missed <g>)?

1 Two completely separate pages (I think this violates the DRY principle).
2 Use the same template for both pages, but have different routes to each and 
different view callables (the view callables could share a lot of common code).
3 Set a flag in the session that indicates where the page came from. In the 
current application, I'm thinking of setting an 'in admin mode' flag as there 
are actually several common pages called in admin and non-admin mode with 
different locations in the site tree. I envision that this session flag would 
be set when the user chooses the admin menu option from the main menu and 
cleared when the user returns to the main menu.
4 Use the HTTP_REFERER header to figure out which page linked to the current 
page. I'm concerned abou this because it could mean changing code if I changed 
the layout of the website  (i.e. right now the HTTTP_REFERER might be 
.../main_menu, but I might restructure the code such that the same page was now 
at .../main or .../menu).
5 Store some sort of "breadcrumb" in a hidden field on a form. I think this 
would only work with forms.

Thanks,
Mark

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

Reply via email to