>> 1) h.url_for is a great idiom to generate urls to dynamic
>> pages. But what should be used to generate links to
>> *static* resources? (...)
>
> (...)
> map.connect("attachments", "/attachments/:rec_id/:(filename).jpg
> h.url_for("attachments", rec_id=5, filename="foo")
> => "/attachments/5/foo.jpg"
Thanks for the detailed suggestion, I could almost copy it ;-)
There is slight assymetry using this solution (pylons serve files
using their disk location, bur generates urls using routes rules),
but, well, I am not sure whether something better is possible.
Or maybe it is? Can I use routes rules to manage static controller?
>> Is it possible to have static controller serving some
>> files, and template controller handling other files
>> from the same directory (...)
>
> (... some technical details cut, thx for them)
> However, I suspect that getting with the program and keeping
> templates and static files separate will lead to easier maintenance
> in the long run.
Hmm, depends. If I have some page with images, it is usually easier to
refer to those images correctly, remove them together with the article
etc, when they lie together. Having used zope for some years I would
probably prefer to define handling methods using extensions. Maybe
this is a subject worth analysing in a bit more details against
different usage scenarios - in some docs?
>> 3) What is the typical approach to generate things like
>> table of contents, page-list menu etc. Do people tend
>> to write such things manually? If I would like to
>> scan my package for files and generate indexes automatically,
>> should I use pkg_resources, os, or sth else?
>
> Dynamic applications usually require dynamic indexes, so you write
> these like any other dynamic page. If you have a lot of static files
> you want to index, you can use a template to create a static
> index.html in websetup.py. If you want to guarantee the index is up
> to date every time the application starts, put the code in
> environment.py or middleware.py.
I am not sure whether I wrote my question correctly - I wanted
to ask HOW usually such code looks like - considering that
a) app can be packaged into egg and b) app can mix dynamic
forms, templates and static pages it need not be so obvious.
Maybe I should rather ask about example of content-oriented
(noticeable number of text pages) pylons website I could
take a look at to learn sth...
Thanks for the idea of generating some indexes during startup,
it can be more efficient than building them always on demand.
>> 4) What about search? (...)
>>
> packages like pyLucene might help. (...)
Thanks for the hint, I will take a look. I understand that there
is no established practice for pylons.
>> 5) How would you implement simple constants referred thorough
>> the site in different templates? At the moment I have sth
>> like
>> _const.mako
>> <%def name="author_name()" buffered="True">Marcin Kasperski</%def>
>
> I put those in the base controller's .__call__ method:
>
> c.author_name = u"Marcin Kaperski".
Hmm. This is a little bit troublesome when I need to override sth
for just a few pages (duplicating controller looks like overkill).
But, well, maybe there is no good solution. Thx for the hint.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---