Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Sections
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Wesley St.Clair  
View profile  
 More options Mar 11 2012, 2:56 pm
From: "Wesley St.Clair" <wes.stcl...@gmail.com>
Date: Sun, 11 Mar 2012 11:56:09 -0700 (PDT)
Local: Sun, Mar 11 2012 2:56 pm
Subject: Sections

I feel like I am missing something obvious, but I have been struggling with
this for a couple of hours and haven't figured it out.  How do I override
the sections query that is used by the section_menu template tag?  It seems
like I should be able to add kwargs={'sections': my_sections} to my url
patterns to override the default sections query in SectionMenuNode, but I'm
not sure exactly what my_sections should be.  Before digging into the code,
I assumed it would be a queryset, but this does not appear to be the case.
 Specifically, I don't understand what this line of code is doing
(armstrong.core.arm_sections.template_tags.section_helpers.py).

            sections = self.sections.resolve(context)

Any help is greatly appreciated.

Thanks!
Wes


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave McLain  
View profile  
 More options Mar 11 2012, 4:20 pm
From: Dave McLain <dmcl...@gmail.com>
Date: Sun, 11 Mar 2012 15:20:09 -0500
Local: Sun, Mar 11 2012 4:20 pm
Subject: Re: [armstrong] Sections

Wes -

That is a standard way of resolving template context variables during
render time. In order to replace the queryset in the template using
something like:

{% section_menu sections=your_queryset %}

This will require using a view or context processor that populates your
template context with a variable containing your custom section queryset.

dave

On Sun, Mar 11, 2012 at 1:56 PM, Wesley St.Clair <wes.stcl...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wesley St.Clair  
View profile  
 More options Mar 11 2012, 7:16 pm
From: "Wesley St.Clair" <wes.stcl...@gmail.com>
Date: Sun, 11 Mar 2012 18:16:09 -0500
Local: Sun, Mar 11 2012 7:16 pm
Subject: Re: [armstrong] Sections

Thank you for the information!  That cleared things up for me.

In order to use my own queryset for sections, I am subclassing the
Armstrong generic views and overriding the get_context_data method to add
my_sections to the returned context.  This ends up being very little work
now that I have a better idea of what is going on, but it does require me
to maintain my own views (kind of).  I wonder if there shouldn't be a more
global method of defining the sections queryset. Thoughts?

Wes


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dave McLain  
View profile  
 More options Mar 11 2012, 7:57 pm
From: Dave McLain <dmcl...@texastribune.org>
Date: Sun, 11 Mar 2012 18:57:51 -0500
Local: Sun, Mar 11 2012 7:57 pm
Subject: Re: [armstrong] Sections

Determining where to put the logic for building the navigational elements
on the Texas Tribune is a source of constant back and forth. Three
solutions come to mind -- Class based view mixins, template context
processors and custom tags. They all have their pros and cons:

CBV Mixins

   - Pros: You can very quickly see where all your DB calls are coming from
   and it just feels like a better separation of logic in the
   Model/View/Controller mold (or Model/Template/View in django parlance)
   - Cons: Every time you write a new view you have to make sure you're
   bringing in all the right stuff to make your navigational fields work

Context Processor

   - Pros: This is really what context processors are for
   - Cons: They get run no matter what, so when you start doing logical
   things like caching a fancy, query-created menu, you might still end up
   paying for those trips back and forth to the database, even though you're
   just going to pull straight out of cache.

Custom Tags

   - Pros: They can really make your templates a lot simpler. Also, there's
   basically nothing you can't do once you're writing your own tags
   - Cons: You can quickly get to a point where your tags are complicated
   and something like {% section_menu %} is doing dozens of queries, which
   doesn't feel right. There has been talk about the Django templating
   language and making the internals work a lot faster in future versions, but
   it's not yet clear what that might mean for custom tags.

All that being said, it would be a logical refactoring of
https://github.com/armstrong/armstrong.core.arm_sections/blob/master/...
pull the highlighted section into a get_queryset method so that it
would
be easier to subclass and override.

*Dave McLain*
*The Texas Tribune - Software Engineer*
823 Congress Ave., Suite 210 Austin, TX 78701
www.texastribune.org

*M* (512) 203.5931* **F* (512) 716.8601

On Sun, Mar 11, 2012 at 6:16 PM, Wesley St.Clair <wes.stcl...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wesley St.Clair  
View profile  
 More options Mar 11 2012, 8:25 pm
From: "Wesley St.Clair" <wes.stcl...@gmail.com>
Date: Sun, 11 Mar 2012 19:25:19 -0500
Local: Sun, Mar 11 2012 8:25 pm
Subject: Re: [armstrong] Sections

Ah... Context Processor would be the "more global" method I was looking
for.  The database performance hit may be there, but it can be circumvented
without too much problem.  Cache the views and load the more dynamic
content (reader comments, ads, etc) via AJAX calls after the page loads.

I've learned a lot today.  Thanks again!

Wes

On Sun, Mar 11, 2012 at 6:57 PM, Dave McLain <dmcl...@texastribune.org>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »