June 7, 2009 § Leave a Comment
It’s nice that Pylons include nosetest and TestUnit as part of its testing framework.
Unfortunately, using those for unit testing inside Pylons is not trivial, not obvious, and inconvenient.
- I can only run nosetests on top-level directory because config is expecting ‘test.ini’ file. That’s inconvenient.
- It is not obvious how build sqlalchemy’s engine inside tests/__init__.py. Ideally, I can build the engine based on test.ini configurations.
The __init__ file solves various problems:
- I can run nosetests anywhere inside project’s directory tree.
- With simple convention, __init__ will look for test.ini file on top-level directory.
- SqlAlchemy engine is built using configuration set in test.ini
I hope this snippet can help readers in getting up to speed in Pylons even quicker.
May 31, 2009 § 1 Comment
For the longest time I kept staring at ‘plain text mode’ while editing Mako templates. No Mas!
TextMate bundle for Mako template has existed.
cd ~/Library/Application\ Support/TextMate/Bundles/
svn co http://svn.makotemplates.org/contrib/textmate/Mako.tmbundle
After Reloading your bundle, syntax highlighting is available under HTML (Mako).
May 25, 2009 § 6 Comments
Do you have that problem? I do.
EDIT(05/31/2009): Even better solutions:
General CSS solution:
The HTML solution:
use <wbr>. (But you have to figure out yourself where to put the tag)
The IE-specific CSS solution:
wordwrap(‘your_very_long_string_here’, 15) // Break after 15 characters
textwrap.fill(‘your_very_long_string_here’, 15) # Break after 15 characters
May 25, 2009 § Leave a Comment
Original Article here: http://lafalafu.com/krc/privilege.html
The article is thoroughly descriptive and I didn’t even realize some of them until I read it.
May 24, 2009 § Leave a Comment
By default Mako HTML escapes all output.
To NOT have this behavior, change the setting of TemplateLookup in environment.py.
May 17, 2009 § Leave a Comment
distance_of_time_in_words is a useful function that converts boring looking datetime into something more attractive (and SEO optimized) like: 30 seconds ago.
Pylons gain this functionality via WebHelper which blatantly inspired by Rails.
But, out of the box, this functionality does not exists in my templates. To enable it, I need to add this line in helpers.py:
from webhelpers.date import distance_of_time_in_words
May 16, 2009 § Leave a Comment