I wonder how ``is_public`` supposed to be used in FreeComments? Neither get_comment_count nor get_comment_list seems aware of it.
Recently i set up comment_utils app, which can use akismet module and some other ways to decide if comment shouldn't be public. Akismet check works very good, and spam comments get ``is_public`` flag set to false. However, comments template tags get_comment_count and get_comment_list don't use it. And display/count comments no matter if they're public or not.
As of now, i do the following:
{% get_free_comment_list for blog.entry object.id as comment_list %}
{% for comment in comment_list %}
{%if comment.is_public %}
[...]
{% endif %}
{% endfor %}
get_free_comment_count still returns the number of all comments though.
After adding
autoescape stuff to Django svn, at least several things have broken it seems.
Firstly i noticed the problem with ``flat pages``. Instead of seeing my static data, i got ``Unhadled exeption`` in reply. In logs i found following:
2007-12-01 17:39:13: (mod_fastcgi.c.2588) FastCGI-stderr: Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/flup/server/fcgi_base.py", line 558, in run
protocolStatus, appStatus = self.server.handler(self)
File "/usr/lib/python2.5/site-packages/flup/server/fcgi_base.py", line 1120, in handler
write(data)
File "/usr/lib/python2.5/site-packages/flup/server/fcgi_base.py", line 1062, in write
assert type(data) is str, 'write() argument must be string'
AssertionError: write() argument must be string
As seen above, error reported by Flup, which is used by Django to run as fastcgi server.
Type of data passed to line 1062 is django.utils.safestring.SafeString now and AssertionError is raised.
There's a ticket already created because of this issue, and even reported to flup's author. But there's no solution to the problem as of now.
Transcript of special IRC meeting, where OpenSUSE developers answer questions regarding recent agreement between Novell and Microsoft
Recently i added some javascript files to my site, and planning to add more later. But the size of these files is pretty big. Because of this i decided to setup mod_deflate.
Mod_deflate in apache2 is pretty much the same as mod_gzip in apache1.3, and
mod_deflate is included in apache2 source package. Both modules let to compress the output of Apache server dynamically. Compression can be setup server wide or for some virtual host
only. Types of content which need to be compressed can be specified explicitly AddOutputFilterByType and compression level can be specified with DeflateCompressionLevel. Maximum compression level is 9.
To setup compression for some virtual host, one needs to do the following:
$ sudo a2enmod deflate
Module deflate installed; run /etc/init.d/apache2 force-reload to enable.
Then add similar lines to the virtual host definition:
<VirtualHost *>
...
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-javascript
DeflateCompressionLevel 9
..
</VirtualHost>
After this apache needs to be restarted. To check if compression works, we can use telnet to connect to web server:
$ telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.1
Host: yourhosthere
Accept-Encoding: gzip
HTTP/1.1 200 OK
Date: Fri, 10 Nov 2006 07:10:41 GMT
Server: Apache/2.0.55 (Ubuntu) mod_python/3.2.8 Python/2.4.4c1 PHP/4.4.2-1.1 mod_ssl/2.0.55 OpenSSL/0.9.8b
Vary: Accept-Encoding
Content-Encoding: gzip
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8
....
After that you should see gzip'ed version of your content.
Just found a great product dp.SyntaxHighlighter. Its name is selfdescriptive. Using javascript and css it lets your code snippets look very neat in browser window.
It already supports major popular languages, here's the list of supported languages as of version 1.4.1 (released on: September 19th, 2006):
css
c#, c-sharp, csharp
c, cpp, c++
vb, vb.net
delphi, pascal
js, jscript, javascript
php
py, python
ruby
sql
xml, xhtml, xslt, html, xhtml
To setup it on your site, download and put under your javascript folder everything
from Scripts folder and copy Styles/SyntaxHighlighter.css into your css folder. Then you have to add links to these files on your pages:
In the head section you can load only the languages you need (shBrush<lang>.js files).
After this, just put your code within textarea element, give it a name "code" and
assign it a class corresponding to your language. For example:
<textarea name="code" class="python" rows="10" cols="100">
def print_hello():
print "hello world"
if __name__ == "__main__":
print_hello()
</textarea>
This should look similar to the following snippet in a browser window:
Also, there are some controls available:
nogutter
Will display no gutter.
nocontrols
Will display no controls at the top.
collapse
Will collapse the block by default.
firstline[value]
Will begin line count at value. Default value is 1.
showcolumns
Will show row columns in the first line.
They can be appended to the class name, e.g. class="python:nogutter:nocontrols"
As soon as your blog content updates, you may want to ping some services like Technorati. Django already has module django.contrib.sitemaps, which can ping google along with sitemap generation.
But what if you want to update other search engines too? There's a plenty of services, which
support RPC, so it is possible to ping them once your blog
got updated. Or you can use a wonderful service Ping-O-Matic, which will do the work for you.
Ping-O-Matic is a service to update different search engines that your blog has updated.
You can let it know about your updates using ordinary GET request, or using RPC call. This
RPC call is just an HTTP request with some details in xml format. Python has a great
XML-RPC client library xmlrpclib which makes work with RPC simple and pleasant.
Here's the simple code, which you can save in your app directory:
That's all! Now all you need to do is to call it once your blog gets updated. This can be done
by subclassing save() method of your model:
Entry is the name of my model in the Blog application.
After a long period of time while my domain
fxp0.org.ua
was unused, i finally made a small blog application with
Django and put it on the web. Actually, i've been playing
with Django since January, but i have not written anything, that i could utilize on the web.
So here's my first micro app :) Though it's hardly can be called an application :) Django made
development so easy and pleasant! Entire blog application can be written in a few simple steps! Due to the fact that i'm sysadmin, i spent
much
more time playing with all that html/css stuff :) And this partially explains the weird look of my
site :)