<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><!-- generator="wordpress/2.0.5" --><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">

<channel>
	<title>thougths.as_blog()</title>
	<link>http://viestards.tosteris.com</link>
	<description>code and sports</description>
	<pubDate>Sat, 30 Jun 2007 12:58:13 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.5</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/viestards" type="application/rss+xml" /><item>
		<title />
		<link>http://viestards.tosteris.com/2007/06/30/23/</link>
		<comments>http://viestards.tosteris.com/2007/06/30/23/#comments</comments>
		<pubDate>Sat, 30 Jun 2007 12:58:13 +0000</pubDate>
		<dc:creator>viestards</dc:creator>
		
		<category>Uncategorized</category>

		<guid isPermaLink="false">http://viestards.tosteris.com/2007/06/30/23/</guid>
		<description><![CDATA[Have not posted for some time. Mosly because I was offline, in place where are no internet connection available, taking part in strawberry collection. Weather was pretty hot and sunny and I had a good time swimming and sunbathing besides working.  Overall it as nice not to sit in front of computer every day [...]]]></description>
			<content:encoded><![CDATA[<p>Have not posted for some time. Mosly because I was offline, in place where are no internet connection available, taking part in strawberry collection. Weather was pretty hot and sunny and I had a good time swimming and sunbathing besides working.  Overall it as nice not to sit in front of computer every day and I ate a whole lot of strawberries.<br />
For next few days I&#8217;ll try to write some more posts, I started to learn <a href="http://joomla.org">Joomla!</a>  CMS and it is pretty interesting.
</p>
]]></content:encoded>
			<wfw:commentRss>http://viestards.tosteris.com/2007/06/30/23/feed/</wfw:commentRss>
		</item>
		<item>
		<title>helpers sample project</title>
		<link>http://viestards.tosteris.com/2007/06/06/helpers-sample-project/</link>
		<comments>http://viestards.tosteris.com/2007/06/06/helpers-sample-project/#comments</comments>
		<pubDate>Wed, 06 Jun 2007 05:46:02 +0000</pubDate>
		<dc:creator>viestards</dc:creator>
		
		<category>programming</category>

		<category>django</category>

		<category>javascript</category>

		<category>helpers</category>

		<category>AJAX</category>

		<category>prototype</category>

		<guid isPermaLink="false">http://viestards.tosteris.com/2007/06/06/helpers-sample-project/</guid>
		<description><![CDATA[I made a simple Django project, that shows how to implement helpers. It consists of two examples: first is ping pong example, which shows how to implement link_to_remote function, and second is AJAX Form example- it demonstrates how to use form_remote_tag.
You can download it from Google Project page.

]]></description>
			<content:encoded><![CDATA[<p>I made a simple Django project, that shows how to implement helpers. It consists of two examples: first is ping pong example, which shows how to implement link_to_remote function, and second is AJAX Form example- it demonstrates how to use form_remote_tag.<br />
You can download it from <a href="http://django-helpers.googlecode.com/files/helpers.zip">Google Project page</a>.
</p>
]]></content:encoded>
			<wfw:commentRss>http://viestards.tosteris.com/2007/06/06/helpers-sample-project/feed/</wfw:commentRss>
		</item>
		<item>
		<title>AJAX.Update and Django errors</title>
		<link>http://viestards.tosteris.com/2007/06/06/ajaxupdate-and-django-errors/</link>
		<comments>http://viestards.tosteris.com/2007/06/06/ajaxupdate-and-django-errors/#comments</comments>
		<pubDate>Tue, 05 Jun 2007 23:07:48 +0000</pubDate>
		<dc:creator>viestards</dc:creator>
		
		<category>programming</category>

		<category>django</category>

		<category>helpers</category>

		<category>AJAX</category>

		<category>prototype</category>

		<guid isPermaLink="false">http://viestards.tosteris.com/2007/06/06/ajaxupdate-and-django-errors/</guid>
		<description><![CDATA[Prototype&#8217;s AJAX.Update seems to be nice, but it has problem, that it updates target div. Django usual practice is to show error description above form field, and not somewhere below. This is a problem, that can not be solved easily with helpers. I wonder how RoR does it, Google has not been very helpful here.
For [...]]]></description>
			<content:encoded><![CDATA[<p>Prototype&#8217;s AJAX.Update seems to be nice, but it has problem, that it updates target div. Django usual practice is to show error description above form field, and not somewhere below. This is a problem, that can not be solved easily with helpers. I wonder how RoR does it, Google has not been very helpful here.<br />
For now, errors are written in response div, it&#8217;s not so user-friendly.
</p>
]]></content:encoded>
			<wfw:commentRss>http://viestards.tosteris.com/2007/06/06/ajaxupdate-and-django-errors/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Django helpers on Google code</title>
		<link>http://viestards.tosteris.com/2007/05/25/django-helpers-on-google-code/</link>
		<comments>http://viestards.tosteris.com/2007/05/25/django-helpers-on-google-code/#comments</comments>
		<pubDate>Thu, 24 May 2007 23:53:07 +0000</pubDate>
		<dc:creator>viestards</dc:creator>
		
		<category>programming</category>

		<category>django</category>

		<category>helpers</category>

		<category>AJAX</category>

		<category>prototype</category>

		<guid isPermaLink="false">http://viestards.tosteris.com/2007/05/25/django-helpers-on-google-code/</guid>
		<description><![CDATA[Ok, today I put helpers on Google code under new BSD licene. Project page is here.
For now it supports:
helper- generic function, that can call any webhelpers.rails.protype function 
visual_effect
remote_function
form_remote_tag
submit_to_remote
periodically_call_remote
link_to_remote
observe_form
observe_field


]]></description>
			<content:encoded><![CDATA[<p>Ok, today I put helpers on Google code under new BSD licene. Project page is <a href="http://code.google.com/p/django-helpers/">here</a>.<br />
For now it supports:<br />
<code>helper</code>- generic function, that can call any <code>webhelpers.rails.protype</code> function </p>
<p><code>visual_effect<br />
remote_function<br />
form_remote_tag<br />
submit_to_remote<br />
periodically_call_remote<br />
link_to_remote<br />
observe_form<br />
observe_field<br />
</code>
</p>
]]></content:encoded>
			<wfw:commentRss>http://viestards.tosteris.com/2007/05/25/django-helpers-on-google-code/feed/</wfw:commentRss>
		</item>
		<item>
		<title>link_to_remote vs remote_function</title>
		<link>http://viestards.tosteris.com/2007/05/24/link_to_remote-vs-remote_function/</link>
		<comments>http://viestards.tosteris.com/2007/05/24/link_to_remote-vs-remote_function/#comments</comments>
		<pubDate>Wed, 23 May 2007 22:40:05 +0000</pubDate>
		<dc:creator>viestards</dc:creator>
		
		<category>programming</category>

		<category>django</category>

		<category>javascript</category>

		<category>helpers</category>

		<guid isPermaLink="false">http://viestards.tosteris.com/2007/05/24/link_to_remote-vs-remote_function/</guid>
		<description><![CDATA[There is problem with link_to_remote function. While it is nothing more than remote_function with &#60;a href=&#34;#&#34;
thingies, it produces some wierd error because Django does not uses routes. In the same time remote_function works ok. Looks like I just add HTML stuff at the end.

]]></description>
			<content:encoded><![CDATA[<p>There is problem with <code>link_to_remote</code> function. While it is nothing more than <code>remote_function </code>with &lt;a href=&quot;#&quot;<br />
thingies, it produces some wierd error because Django does not uses routes. In the same time remote_function works ok. Looks like I just add HTML stuff at the end.
</p>
]]></content:encoded>
			<wfw:commentRss>http://viestards.tosteris.com/2007/05/24/link_to_remote-vs-remote_function/feed/</wfw:commentRss>
		</item>
		<item>
		<title>quick rails style helper</title>
		<link>http://viestards.tosteris.com/2007/05/24/quick-rails-style-helper/</link>
		<comments>http://viestards.tosteris.com/2007/05/24/quick-rails-style-helper/#comments</comments>
		<pubDate>Wed, 23 May 2007 22:32:44 +0000</pubDate>
		<dc:creator>viestards</dc:creator>
		
		<category>programming</category>

		<category>django</category>

		<category>helpers</category>

		<category>AJAX</category>

		<category>prototype</category>

		<guid isPermaLink="false">http://viestards.tosteris.com/2007/05/24/quick-rails-style-helper/</guid>
		<description><![CDATA[I started to port all helpers stuff to Django, but it&#8217;s mainly boring. Then the idea came to me, what if there will be only one (or a little bit more) which handle all calls to webhelpers.
So, there is one function, that can call any Pylons webhelpers prototype function- I called it helper. The idea [...]]]></description>
			<content:encoded><![CDATA[<p>I started to port all helpers stuff to Django, but it&#8217;s mainly boring. Then the idea came to me, what if there will be only one (or a little bit more) which handle all calls to webhelpers.<br />
So, there is one function, that can call any Pylons webhelpers prototype function- I called it <code>helper</code>. The idea is that every function is very similar and repeating every function call is turning more into copy/paste. But there is easy with <code>getattr</code>.<br />
Result looks like this:<br />
<code><br />
Generic helper &lt;a href=&quot;#&quot; onclick=&quot;{% helper function_name:remote_function url:/frets/shell/ update:pongbox success:test_funct() %}; return false;&quot;&gt;here&lt;/a&gt;<br />
</code><br />
Just put it into your template  and create <code>pongbox</code> div.<br />
Templatetag file is available <a href="http://viestards.tosteris.com/files/helpers.py">here</a>, it is unclean, because I&#8217;m working on it, but it should work. Put into <code>templatetags</code> folder.</p>
]]></content:encoded>
			<wfw:commentRss>http://viestards.tosteris.com/2007/05/24/quick-rails-style-helper/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Django helpers diary- escaping URLs</title>
		<link>http://viestards.tosteris.com/2007/05/19/django-helpers-diary-escaping-urls/</link>
		<comments>http://viestards.tosteris.com/2007/05/19/django-helpers-diary-escaping-urls/#comments</comments>
		<pubDate>Sat, 19 May 2007 09:34:11 +0000</pubDate>
		<dc:creator>viestards</dc:creator>
		
		<category>programming</category>

		<category>django</category>

		<category>helpers</category>

		<category>AJAX</category>

		<category>prototype</category>

		<guid isPermaLink="false">http://viestards.tosteris.com/2007/05/19/django-helpers-diary-escaping-urls/</guid>
		<description><![CDATA[Have not written something in a while, was busy with one of my projects- porting Pylons webhelpers to Pylons. I didn&#8217;t know what to write, because there were no big things to write about.
Thinking of which I decided to start writing my project diary- all my problems, what I find out, hoping that others will [...]]]></description>
			<content:encoded><![CDATA[<p>Have not written something in a while, was busy with one of my projects- porting Pylons webhelpers to Pylons. I didn&#8217;t know what to write, because there were no big things to write about.<br />
Thinking of which I decided to start writing my project diary- all my problems, what I find out, hoping that others will find it useful. I decided to write at least three times a week, so this is first time.</p>
<p>When porting webhelpers, first problem was to create it the way that only the small part of code has to be rewritten. There is one problem thou, Pylons is using routes as their URL mapper, while Django uses regexps as URL mappers. My problem is that webhelpers escapes all apostropes because there has to be no such characters in URL! So I have a choice- rewrite parts that are responsible for urls (call to routes) or return direct value passing Template class, which is not usggested by Django team. For now I think, that best will be latter metod but just as proof of concept.
</p>
]]></content:encoded>
			<wfw:commentRss>http://viestards.tosteris.com/2007/05/19/django-helpers-diary-escaping-urls/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using Django with helpers</title>
		<link>http://viestards.tosteris.com/2007/05/07/using-django-with-helpers/</link>
		<comments>http://viestards.tosteris.com/2007/05/07/using-django-with-helpers/#comments</comments>
		<pubDate>Mon, 07 May 2007 11:03:42 +0000</pubDate>
		<dc:creator>viestards</dc:creator>
		
		<category>programming</category>

		<category>django</category>

		<category>helpers</category>

		<guid isPermaLink="false">http://viestards.tosteris.com/2007/05/07/using-django-with-helpers/</guid>
		<description><![CDATA[Long time Django was considered as AJAX-unfriendly web framework, which does not allow JavaScript code generation. On other hand , Pylons ported Rails helpers for their framework as webhelpers.
So maybe I can use Pylons templatetags in Django? Sounds hard, because Pylons use heavy Python coding in their templates, but you underestimate power of templatetags.
To show [...]]]></description>
			<content:encoded><![CDATA[<p>Long time Django was considered as AJAX-unfriendly web framework, which does not allow JavaScript code generation. On other hand , <a href="http://pylonshq.com">Pylons</a> ported Rails helpers for their framework as <a href="http://pylonshq.com/WebHelpers/">webhelpers</a>.<br />
So maybe I can use Pylons templatetags in Django? Sounds hard, because Pylons use heavy Python coding in their templates, but you underestimate power of templatetags.<br />
To show you how to use helpers, let&#8217;s translate <a href="http://docs.pythonweb.org/display/pylonscookbook/Getting+started+with+AJAX">Pylons AJAX tutorial</a> to Django.<br />
<a id="more-13"></a><br />
To use it, you need webhelpers installed. They come with Pylons, but are available at <a href="http://cheeseshop.python.org/pypi/WebHelpers/0.2.2">Cheeseshop</a> too. For JavaScript stuff, you need script.aculo.us, wihich comes with Prototype, get it <a href="http://script.aculo.us/downloads">here</a> and place it in your media folder.<br />
When everything is set, let&#8217;s start to create ping-pong site.<br />
I assume you have Django project ready, so create a pong entry in urls.py:<br />
<code><br />
    (r'^pong/?$','mysite.myproject.views.pong'),<br />
</code></p>
<p> Now, somewhere in ping template put this line:<br />
<code><br />
There is &lt;a href="/pong"&gt;ping&lt;/a&gt; <br />
</code><br />
To show something, create a view. In your <code>views.py</code> write pong function:<br />
<code><br />
def pong(request):<br />
&nbsp;&nbsp;&nbsp; return HttpResponse(&#8221;There is pong!&#8221;)<br />
</code><br />
This is basic page, but we need some AJAX powers. Download <a href="http://viestards.tosteris.com/files/helpers.py">helpers.py</a> code and put into templatetags folder.<br />
In ping template page add following line at start of page:<br />
<code>{% load helpers %}</code><br />
Change link to pong page to:<br />
<code><br />
There is &lt;a href="#" onclick="{% remote_function url:/pong/<br />
update:pongbox %}; return false;"&gt;ping&lt;/a&gt; <br />
&lt;div id=&#8221;pongbox&#8221;&gt;<br />&lt;/div&gt;<br />
</code><br />
As you see, href now points at # and there is templatetag <code>remote_function</code>, which calls webhelpers <code>remote_function</code> function. Now reload page, and if everthing is right, you will see <code>pong</code> message below link, where <code>pongbox</code> is.
</p>
]]></content:encoded>
			<wfw:commentRss>http://viestards.tosteris.com/2007/05/07/using-django-with-helpers/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JavaScript with Django templatetags</title>
		<link>http://viestards.tosteris.com/2007/05/02/javascript-with-django-templatetags/</link>
		<comments>http://viestards.tosteris.com/2007/05/02/javascript-with-django-templatetags/#comments</comments>
		<pubDate>Wed, 02 May 2007 14:13:03 +0000</pubDate>
		<dc:creator>viestards</dc:creator>
		
		<category>programming</category>

		<category>django</category>

		<category>javascript</category>

		<category>helpers</category>

		<guid isPermaLink="false">http://viestards.tosteris.com/2007/05/02/javascript-with-django-templatetags/</guid>
		<description><![CDATA[There are lots of tutorials in web concerning integrating AJAX into Django. But they look somehow out of place- you have to insert JavaScript test from view and it&#8217;s against DRY. So, I decided to implement JavaScript through templatetags.
First, you need to create templatetag (if you know nothing of templatetags, look at Django template documentation [...]]]></description>
			<content:encoded><![CDATA[<p>There are lots of tutorials in web concerning integrating AJAX into Django. But they look somehow out of place- you have to insert JavaScript test from view and it&#8217;s against DRY. So, I decided to implement JavaScript through templatetags.<br />
First, you need to create templatetag (if you know nothing of templatetags, look at Django template documentation for Python developers.<br />
For my example I will be using <a href="http://www.prototypejs.org/">Prototype</a> and <a href="http://script.aculo.us/">Script.alo.us</a> JavaScript frameworks<br />
So first things first- let&#8217;s create templatetag:<br />
<code><br />
def do_visual_effect(parser, token):<br />
&nbsp;&nbsp;&nbsp; "adds various JS visual effects to chosen element"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; effect = token.split_contents()<br />
&nbsp;&nbsp;&nbsp; wigdet="new Effect."+effect[1]+'("'+ effect[2] +'")'<br />
&nbsp;&nbsp;&nbsp; return VisualEffectNode(wigdet)</p>
<p></code><br />
As you can see, visual effect function is very simple and now works only with two arguments- EffectName and div id , but we will fix that later.<br />
Template Node class is the same as in Django documentation, so I will not get any deeper:</p>
<p><code><br />
class VisualEffectNode(template.Node):<br />
&nbsp;&nbsp;&nbsp; def __init__(self, widget_code):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print widget_code<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.widget_code= widget_code<br />
&nbsp;&nbsp;&nbsp; def render(self, context):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return self.widget_code&nbsp;&nbsp;<br />
</code></p>
<p>Only thing left is to register it as templatetag, so at the bottom of file write down:<br />
<code>register.tag('visual_effect', do_visual_effect)<br />
</code></p>
<p>Now for the template part: I saved file as helpers.py, so I&#8217;m gonna insert<br />
<code>{% load helpers %}</code><br />
at the top of template file.<br />
Now when you need any effect, just call</p>
<p><code><br />
&lt;div id="my_old_div"&gt;<br />
&lt;b&gt;sometext&lt;/b&gt;<br />
&lt;/div&gt;<br />
&lt;a href=&#8221;#&#8221; onclick=&#8217;{% visual_effect SwitchOff my_old_div %}&#8217;&gt;Get out of the way!&lt;/a&gt;<br />
</code><br />
This will create link, which remove div with id &#8220;my_old_div&#8221; when clicked.</p>
<p>But maybe we want to add some more arguments, such as duration? So, lets modify our code a little bit:<br />
<code><br />
def do_visual_effect(parser, token):<br />
&nbsp;&nbsp;&nbsp; "adds various JS visual effects to chosen element"<br />
&nbsp;&nbsp;&nbsp; effect = token.split_contents()<br />
&nbsp;&nbsp;&nbsp; #&nbsp; if addition opntions are ommited, add empty string<br />
&nbsp;&nbsp;&nbsp; if len(effect)==3:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; effect.append("")<br />
&nbsp;&nbsp;&nbsp; wigdet="new Effect."+effect[1]+'("'+ effect[2] +'",{'+ effect[3] + '})'<br />
&nbsp;&nbsp;&nbsp; return VisualEffectNode(wigdet)<br />
</code><br />
I just appended dictionary-like structure where additional arguments can be inserted.<br />
In template add something like this<br />
<code><br />
&lt;a href="#" onclick='{% visual_effect Highlight model2 duration:1 %}'&gt;Highlight model1&lt;/a&gt;<br />
</code><br />
and we&#8217;re set!<br />
That&#8217;s it for now, I try later to write something more.</p>
]]></content:encoded>
			<wfw:commentRss>http://viestards.tosteris.com/2007/05/02/javascript-with-django-templatetags/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Simple Django tutorial</title>
		<link>http://viestards.tosteris.com/2006/11/24/simple-django-tutorial/</link>
		<comments>http://viestards.tosteris.com/2006/11/24/simple-django-tutorial/#comments</comments>
		<pubDate>Thu, 23 Nov 2006 22:16:13 +0000</pubDate>
		<dc:creator>viestards</dc:creator>
		
		<category>programming</category>

		<category>django</category>

		<guid isPermaLink="false">http://viestards.tosteris.com/2006/11/24/simple-django-tutorial/</guid>
		<description><![CDATA[Some time ago I&#8217;have written simple tutorial how to create simple blog with Django in Latvian. You can find it here.

]]></description>
			<content:encoded><![CDATA[<p>Some time ago I&#8217;have written simple tutorial how to create simple blog with Django in Latvian. You can find it <a href="http://viestards.tosteris.com/Django_blog_Tutorial1.html">here</a>.
</p>
]]></content:encoded>
			<wfw:commentRss>http://viestards.tosteris.com/2006/11/24/simple-django-tutorial/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
