The main place I use [(url, label)] pairs is in breadcrumbs, which I
set in the controller:
c.crumbs = [("url", "label")]
You can certainly pickle to a BLOB column in a SQL database, the
(non-Pylons) session2 package does this for session handling. I think
SQLAlchemy might have a Pickle column type that does this for you.
But if you're talking about URL/label pairs, it might make more sense
to store them in a two-column table rather than as pickles. (With a
third or fourth column saying who these links belong to, and on what
page.)
But what kind of application needs internal links pickled? The only
use I can think of is some kind of history feature ("Where have I
been?") Otherwise, for ordinary site navigation, wouldn't it be
better to recreate the links each time using url_for and whatever
arguments are necessary -- which you would already have available?
--Mike
On 6/11/07, voltron <[EMAIL PROTECTED]> wrote:
>
> Thats a nice idea Mike, I would have to mange more content in the
> lists but its a compromise. I intend ultimately to retrieve these
> lists from a database as pickeld data, do you have any experience in
> this nature?
>
> Thanks
>
> On Jun 12, 1:13 am, "Mike Orr" <[EMAIL PROTECTED]> wrote:
> > On 6/11/07, voltron <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > On Jun 11, 9:42 pm, "Mike Orr" <[EMAIL PROTECTED]> wrote:
> > > > On 6/11/07, voltron <[EMAIL PROTECTED]> wrote:
> >
> > > > > I have to "clean" and create a few links, for example, Cheese?
> >
> > > > > so I have this construct
> >
> > > > > <li><a href="${h.url_for(url.replace(' ', '_').replace('?',
> > > > > '').lower()) |trim}">${url}</a></li>
> >
> > > > > this, I thought is not scalebale and messey so I thought I could
> > > > > create a function for cleaning:
> >
> > > > > <%def name="clean_link(link)">
> > > > > ${link.replace(' ', '_').replace('?', '').replace('!', '').lower()}
> > > > > <% return link %>
> > > > > </%def>
> >
> > > > > <li><a href="${h.url_for(clean_link(url)) | trim}">${url}</a></li>
> >
> > > > > unfortunately, this does not produce the right links anymore with
> > > > > url_for(), it cleans the link, but all the subdirectories in the link
> > > > > are gone.
> >
> > > > > What would be the best way to go about this?
> >
> > > > How did the links get dirty in the first place? Do they come from an
> > > > external/legacy source? Or are you generating the dirty URLs to
> > > > display to the user? I normally name all my routes, then pass in the
> > > > arguments needed to recreate them:
> >
> > > > h.url_for("pizza", cheese=1, pepperoni=0)
> >
> > > > rather than passing in URLs. Why can you not do this?
> >
> > > they are actually being recreated Mike
> > > example:
> >
> > > g.links = ["home", "Who we are", "Test?"]
> >
> > > <div id="menu">
> > > % for item in g.links:
> > > <a href="/${item.lower().replace(' ', '')}" title="${item}"
> > > class="level_menu">${item}</a><img src="img/menu_seperator.gif"
> > > alt="">
> > > % endfor
> > > </div>
> >
> > Here's what I do in this case:
> >
> > g.links = [("/home", "home"), ("/who", "Who we are"), ("/test", "Test?")
> >
> > % for url, label in g.links:
> > <a href="${url}">${label}</a>
> > % endfor
> >
> > I also have a h.link(label, *url_for_args, **url_for_kw) that does a
> > combination of h.url_for and h.link_to. This is useful to prevent
> > overly long template expressions.
> >
> > --
> > Mike Orr <[EMAIL PROTECTED]>
>
>
> >
>
--
Mike Orr <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---