-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 01/30/2011 01:21 PM, Mike Orr wrote: > On Sun, Jan 30, 2011 at 8:25 AM, Wade Leftwich wrote: >> Actually a bit more in keeping with the spirit of Traversal, and again >> keeping your calls to Mongo to a mininum, would be something like >> this: >> >> /blog/month/2011/01/29/my-post-about-pyramid would do this: >> >> archive = Blog['archive'] >> year = archive['2011'] = archive.__getitem__('2011') = Year(y=2011) >> month = year['01'] = year.__getitem__('01') = Month(y=2011, m=1) >> day = month['29'] = month.__getitem__('01') = Day(y=2011, m=1, d=29) >> post = day['my-post-about-pyramid'] = day.__getitem__('my-post-about- >> pyramid') = Post(y=2011, m=1, d=29, slug='my-post-about-pyramid') >> ... and the default view for Post would be to query Mongo >> >> This would handle shorter paths in a natural way -- e.g. '/blog/month/ >> 2011/01' would map to the default view for Month(y=2011, m=1), which >> would call Post.list_posts_for_month() . > > Are you traversing each level of the date here, or using a subpath from > archive? > > It seems like extra overhead to create a temporary Year class and > Month class just to traverse through them. What are you gaining?
One advantage: this strategy allows registering views against those transient classes, which means that in the "reusable app" scenario the re-using app can override those views selectively. Another advantage: the logic is in the code, not in per-deployment configuration, which makes it unit-testable. > I'm thinking of making a CMS site with articles embedding nested > comments. Chris suggested making the article a repoze.folder.Folder > subclass. I said it seems funny to think of an artlcle as a folder. He > said he makes almost everything folders nowadays, as it makes it > easier to both use the object and traverse through it. Could > ArchiveYear and ArchiveMonth be made into Folder subclasses to factor > away some of the code? That would makes sense if you actually want to *store* the entries inside the archive/year/month tree (a perfectly reasonable strategy). Making the *entry* a folder would make sense if you wanted to store other items (images, audio / video clips, tarballs, PDFs) inside it. Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tsea...@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk1G5xgACgkQ+gerLs4ltQ78OACfSx7iwBQjabB/GYwpG4qlD/Q0 LOIAn02erOioBx5CWRb/pwEVxDxHFaru =1kAq -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-devel@googlegroups.com. To unsubscribe from this group, send email to pylons-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-devel?hl=en.