<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title> &#187; programming</title>
	<atom:link href="http://blog.kfirbreger.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.kfirbreger.com</link>
	<description></description>
	<lastBuildDate>Tue, 24 Jan 2012 09:47:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Some bash script tips</title>
		<link>http://blog.kfirbreger.com/2011/12/09/some-bash-script-tips/</link>
		<comments>http://blog.kfirbreger.com/2011/12/09/some-bash-script-tips/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 10:13:59 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/?p=390</guid>
		<description><![CDATA[Every morning do a refresh of all my repositories so that I know I don&#8217;t fall behind on the code if I need to solve some problem or continue developing. Doing this manually is not practical, and so I created a bash script to refresh all my repositories. While I was at it I added [...]]]></description>
			<content:encoded><![CDATA[<p>Every morning do a refresh of all my repositories so that I know I don&#8217;t fall behind on the code if I need to solve some problem or continue developing. Doing this manually is not practical, and so I created a bash script to refresh all my repositories. While I was at it I added a starting command for the apache and mysql. Since I do not desire to start them if they are already running, the script check first if they are already running. Writing this script I learned a lot about shell scripting. Here are some of the things I picked up</p>
<p>Adding -x to the shebang will make bash output everything that is going on, helps with debugging</p>
<p>Giving a variable as a parameter to a function, if you just give the variable name it will be treated as a string value and that will be passed to the function. I ended up encapsulating it as <code>"${var}"</code> since the value was a string. If your value is not a string you probably need some other solution.</p>
<p>Comparing a variable to a string is best achieved with the following syntax: <code>if[ "${var}" = "foo" ]; then</code> Notice the space between the brackets and the values inside.</p>
<p>Using grep to pick something out of a list of processes requires an extra step in which you remove the grep itself from the list. <code>ps -e | grep -v grep | grep searchstring</code> Otherwise grep might find its own search process, which is of course not the desired effect.</p>
<p>Hopefully this will save you some time in scripting.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2011/12/09/some-bash-script-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal 7 phantom block</title>
		<link>http://blog.kfirbreger.com/2011/12/02/drupal-7-phantom-block/</link>
		<comments>http://blog.kfirbreger.com/2011/12/02/drupal-7-phantom-block/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 09:04:44 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[blocks]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[context]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[drupal 7]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/?p=384</guid>
		<description><![CDATA[Today I can across an interesting change in the way Drupal 7 handles blocks created via modules. In a module I made, I defined a block using the hook_block_info and hook_block_view. This block was added to the site&#8217;s front page. After some implementation details changed it became apparent that the current block was not what [...]]]></description>
			<content:encoded><![CDATA[<p>Today I can across an interesting change in the way Drupal 7 handles blocks created via modules. In a module I made, I defined a block using the <em>hook_block_info</em> and <em>hook_block_view</em>. This block was added to the site&#8217;s front page. After some implementation details changed it became apparent that the current block was not what was needed but a whole series of other blocks. Both hooks were completely rewritten to reflect this.</p>
<p>I noticed that the <em>hook_block_view</em> was called one to many times. Looking at the front page, I saw that the, now removed block was still there. The block admin page, however, did not show it. This was to be expected as there was no info available for it.<br />
It was possible to configure the block though. Either through typing the correct url, or through the small gear on the top right side of that block.<br />
Both clearing the cache and turning the module on and off have failed to remove this phantom block, which had no implementation but was still around. Deinstalling the module was the only way to clear it out of the block table (aside forma  custom sql query of course). Since my module did not have any custom information in the database this was not a problem. However if your module does have such information, deinstalling it will remove all that data. Since my module was available for deinstallation leads me the believe that this is by design. Keep this in mind when building your modules.</p>
<p>Even after the block has been removed from the blocks table, it was still visible. Further research led to the <strong>Context</strong> module. The block was added to the display via a context reaction, and it seems that context does not check if a block is still available. And so the <em>hook_block_view</em> of my module was called with the delta of the old, non-existing, block. Opening the reaction interface for context does not show that the block is part of it, because, I assume, it is not defined. In the database however it is still present. Saving the context with the phantom block without making any changes does remove it from the database, and has removed it from the front page as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2011/12/02/drupal-7-phantom-block/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The finer points of respondsToSelector</title>
		<link>http://blog.kfirbreger.com/2011/05/27/the-finer-points-of-respondstoselector/</link>
		<comments>http://blog.kfirbreger.com/2011/05/27/the-finer-points-of-respondstoselector/#comments</comments>
		<pubDate>Fri, 27 May 2011 11:46:33 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[os x]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/?p=327</guid>
		<description><![CDATA[Cocoa&#8217;s object model is something I really like. Coming from Java, being able to declare a property and have the getters and setters auto generated is really wonderful. The key value way to interact with an object is also a very powerful tool. The problem is what happens when these two collide. For a project [...]]]></description>
			<content:encoded><![CDATA[<p>Cocoa&#8217;s object model is something I really like. Coming from Java, being able to declare a property and have the getters and setters auto generated is really wonderful. The key value way to interact with an object is also a very powerful tool. The problem is what happens when these two collide.</p>
<p>For a project at work I needed to parse some XML. The xml contained several entries of entries. Only part of the information given for each entry was actually needed by the software. Therefor the object used did not have a property for each field in the entry. Just doing the follow code will not work:</p>
<p><code><br />
[currentObject setValue:(id)elemValue forKey:objProperty];<br />
</code></p>
<p>This will raise an exception as soon as an attempt is made to set a property that does not exist. Wrapping the setter in a check to see if the object has this property will solve this problem. Using responseToSelector a test can be made to see if the object reacts to a selector</p>
<p><code><br />
if ([currentObject responseToSelector:NSSelectorFromString(objProperty)]) {<br />
	[currentObject setValue:(id)elemValue forKey:objProperty];<br />
}<br />
</code></p>
<p>This should do it. Except it doesn&#8217;t completely. If your object has a function that is named like objProperty, responseToSelector will return true, because your object does response to it. Its just not a property that is set-able, but instead, a method. Actually, reponseToSelector only controls for function. Since synthesizing a property creates a method with the name of the property, it works for detecting properties as well. To avoid getting an exception on setting values for keys. Make sure that objProperty does not contain a value equal to a method in currentObject that does not represent a property.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2011/05/27/the-finer-points-of-respondstoselector/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>NSXMLParser and error code 4</title>
		<link>http://blog.kfirbreger.com/2011/05/25/nsxmlparser-and-error-code-4/</link>
		<comments>http://blog.kfirbreger.com/2011/05/25/nsxmlparser-and-error-code-4/#comments</comments>
		<pubDate>Wed, 25 May 2011 09:31:22 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[objective c]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/?p=325</guid>
		<description><![CDATA[Today I had one of the strangest bugs I have seen to date. I am working on an iOS app that does  a lot of communication with a web app api. the communication is done via XML. Since the web app requires autherntication, I am useing specific requests and placing the response xml in a [...]]]></description>
			<content:encoded><![CDATA[<p>Today I had one of the strangest bugs I have seen to date. I am working on an iOS app that does  a lot of communication with a web app api. the communication is done via XML. Since the web app requires autherntication, I am useing specific requests and placing the response xml in a string.</p>
<p>NSXMLParser requires a NSData object to init with data. Following the conversion cod eI found on Apple&#8217;s site I did the following:</p>
<p><code><br />
NSData *xmlData = [NSData dataWithBytes:[xml dataUsingEncoding:NSUTF8StringEncoding] length:[xml lengthOfBytesUsingEncoding:NSUTF8StringEncoding]];<br />
</code></p>
<p>Passing the xmlData through to the parser ended in me getting an error 4, which means document empty. I tried everything. Printed out the xml string to see it was full, compared length of data and string, releasing the parser. Still error 4. For the heck of it I tried giving the parser a nil for data. That gave an error 5. Trying to give an empty NSData object also gave error code 4. After 3 hours spent in google and stack overflow I was not even a small step further.</p>
<p>I really didn&#8217;t know what to do when, while scanning all these pages I saw a piece of code of converting the string to data without giving the length. for the heck of it I decided to try this:</p>
<p><code><br />
NSData* xmlData = [xml dataUsingEncoding:NSUTF8StringEncoding];<br />
</code></p>
<p>What do you know it worked. No idea why. Naturally. I wanted to know what the length of the data object was now. I was fully expecting it to be bigger than original. To my surprise it was the same length as the string. The same length I was giving it in the first call.</p>
<p>Why this now wrks I have no idea. The first and the second calls should give the same results, yet somehow they don&#8217;t. If you got this problem, then converting without giving the function a length. Good luck and happy programming.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2011/05/25/nsxmlparser-and-error-code-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up Solr for Drupal under tomcat</title>
		<link>http://blog.kfirbreger.com/2010/07/13/setting-up-solr-for-drupal-under-tomcat/</link>
		<comments>http://blog.kfirbreger.com/2010/07/13/setting-up-solr-for-drupal-under-tomcat/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 06:37:56 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[setup]]></category>
		<category><![CDATA[solr]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/?p=263</guid>
		<description><![CDATA[Disclaimer: This method will probably not work for all servers running tomcat, it is more a personal guide then a general one. Solr is a &#8220;popular, blazing fast open source enterprise search platform from the Apache Lucene project&#8221;. Drupal search has traditionally been less then adequate. Using Solr to index and search you Drupal site [...]]]></description>
			<content:encoded><![CDATA[<p>Disclaimer: This method will probably not work for all servers running tomcat, it is more a personal guide then a general one.</p>
<p>Solr is a &#8220;popular, blazing fast open source enterprise search platform from the Apache Lucene project&#8221;. Drupal search has traditionally been less then adequate. Using Solr to index and search you Drupal site is therefore quite helpful.</p>
<p>To start, download the Solr package (<a href="http://www.apache.org/dyn/closer.cgi/lucene/solr/">link</a>) and the Solr drupal module (<a href="http://drupal.org/project/apachesolr">link</a>). the current standard distribution is Solr 1.4 and Drupal 6.<br />
Unarchive the tar files in a location that is reachable from your server.</p>
<p>We will assume that tomcat is installed in <code>/opt/tomcat</code></p>
<p>In the Solr package there is an example application. That is the Solr application we are going to use. If you can write your own, you probably don&#8217;t need this tutorial.</p>
<p><strong>Step 1:</strong><br />
Copy the example application, found in the solr package under <code>example/webapps</code> to the tomecat webapps folder which should be <code>/opt/tomcat/webapps</code>. when copying the file rename it to something other the solr. this will enable you to have multiplie solr installations running under one Tomcat container. We will assume the app is renamed <code>new_solr_inst</code>. If you are in the tomcat root folder the command should like like this:<br />
<code>cp /path/to/solr/package/apache-solr-1.4.0/apache-solr-1.4.0/example/webapps/solr.war webapps/new_solr_inst.war</code></p>
<p>Tomcat will pick up the war file and open it automatically after a restart.</p>
<p><strong>Step 2:</strong><br />
In the tomcat root folder create a folder to hold your Solr configuration and data.<br />
<code>mkdir new_solr_inst</code><br />
Copy the example app configuration into that folder<br />
<code>cp -R /path/to/solr/package/apache-solr-1.4.0/apache-solr-1.4.0/example/solr/* new_solr_inst</code></p>
<p><strong>Step 3:</strong><br />
You need to replace the original <code>schema.xml</code> and <code>solrconfig.xml</code> with the ones provided by the drupal module. Copy these two files to your Solr configuration folder. Assuming you are currently at the tomcat root folder<br />
<code>cp /path/to/solr/module/schema.xml new_solr_inst/conf</code><br />
<code>cp /path/to/solr/module/solrconfig.xml new_solr_inst/conf</code><br />
The Solr app is now ready for use.</p>
<p><strong>Step 4:</strong><br />
The last step is needed to inform Tomcat about the app and its settings. Go to <code>conf/Catalina/localhost</code> and create the file <code>new_solr_inst.xml</code>. In that file fill the following content:</p>
<div id="_mcePaste"><code>&lt;Context docBase="/opt/tomcat/webapps/new_solr_inst.war" debug="0" privileged="true" allowLinking="true" crossContext="true"&gt;</code></div>
<div id="_mcePaste"><code>&lt;Environment name="solr/home" type="java.lang.String" value="/opt/tomcat/new_solr_inst" override="true" /&gt;</code></div>
<div id="_mcePaste"><code>&lt;/Context&gt;</code></div>
<p><strong>Step 5:</strong><br />
You need to restart tomcat<br />
<code>/opt/tomcat/bin/shutdown.sh</code><br />
<code>/opt/tomcat/bin/startup.sh</code><br />
And your Solr should be running. There are three tests we can use to check everything went well.</p>
<ul>
<li>Tomcat has opened the war file. There is now a folder <code>new_solr_inst</code> in the <code>webapps</code> folder of Tomcat.</li>
<li>Solr has made a <code>data</code> directory in the Solr home folder (that is <code>/opt/tomcat/new_solr_inst</code>)</li>
<li>In your browser go to the Solr app <code>http://domain:tomcat_port/new_solr_inst</code> and you should see a welcome screen</li>
</ul>
<p>If all is well you are ready to combine this Solr installation with your Drupal</p>
<p><strong>Step 6:</strong><br />
Activate the Apache-Solr module and go to the Solr module settings page <code>admin/settings/apachesolr</code><br />
Assuming tomcat and drupal are running on the same server fill in <code>localhost</code> as the host name, fill in the port tomcat is running on and solr path should be your app name in the tomcat webapps folder. In our case is it <code>new_solr_inst</code>.</p>
<p>Save the settings. Drupal should inform you that a connection is made with Solr</p>
<p>Notes</p>
<ul>
<li>It is not nessecary to put the app configuration in the Tomcat root folder. you can probably (though I have not tested this) place it anywhere you want. you do need to make sure that the environment tag in the Tomact configuration file (the one in the <code>conf/Catalina/localhost</code> folder) is pointing to the right place.</li>
<li>If you make changes to the schema you may need to dump all the indices Solr has made. you can do this via the Drupal admin interface for the Solr module.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2010/07/13/setting-up-solr-for-drupal-under-tomcat/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery animation problem in ie7</title>
		<link>http://blog.kfirbreger.com/2010/05/28/jquery-animation-problem-in-ie7/</link>
		<comments>http://blog.kfirbreger.com/2010/05/28/jquery-animation-problem-in-ie7/#comments</comments>
		<pubDate>Fri, 28 May 2010 11:24:30 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[ie problems]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/2010/05/28/jquery-animation-problem-in-ie7/</guid>
		<description><![CDATA[For one of our projects, I was creating a photo bar. When the mouse was over one of the photos it was ment to increase in size and decrease back to original size when the mouse left. Unfortunately the client for which this was developed uses ie7 exclusively. This has brought two problems: 1. ie7 [...]]]></description>
			<content:encoded><![CDATA[<p>For one of our projects, I was creating a photo bar. When the mouse was over one of the photos it was ment to increase in size and decrease back to original size when the mouse left. Unfortunately the client for which this was developed uses ie7 exclusively. This has brought two  problems:<br />
1. ie7 does not support the mouseleave event. I needed to replace it with mouseout event.<br />
2. ie7 does not accept the position property in the jQuery animate function. Giving the position as a parameter will cause an error.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2010/05/28/jquery-animation-problem-in-ie7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting session ID in Drupal 6</title>
		<link>http://blog.kfirbreger.com/2010/02/25/getting-session-id-in-drupal-6/</link>
		<comments>http://blog.kfirbreger.com/2010/02/25/getting-session-id-in-drupal-6/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 20:49:22 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[guide]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/?p=257</guid>
		<description><![CDATA[Drupal saves its sessions in the sessions table. One can always query they table to get the session ID. There is however a faster way. If the user is logged it, the session id can be found with the following code: global $user; $user->sid; In any case the session id can also be read from [...]]]></description>
			<content:encoded><![CDATA[<p>
Drupal saves its sessions in the sessions table. One can always query they table to get the session ID. There is however a faster way.<br />
If the user is logged it, the session id can be found with the following code:</p>
<pre>
global $user;
$user->sid;
</pre>
<p><span>In any case the session id can also be read from the cookie:</span></p>
<pre>
$_COOKIE[session_name()];
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2010/02/25/getting-session-id-in-drupal-6/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to truly disable drupal cache</title>
		<link>http://blog.kfirbreger.com/2009/05/29/how-to-truly-disable-drupal-cache/</link>
		<comments>http://blog.kfirbreger.com/2009/05/29/how-to-truly-disable-drupal-cache/#comments</comments>
		<pubDate>Fri, 29 May 2009 10:26:05 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[guide]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/?p=168</guid>
		<description><![CDATA[Drupal, like most CMSes uses cache intensively to speed things up. In a production site that is exactly what you what. However when developing, cache can cause you much pain. If your an expert in drupal you probably already realized when you need to clear the cache in order to see changes and when not [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>
Drupal, like most CMSes uses cache intensively to speed things up. In a production site that is exactly what you what. However when developing, cache can cause you much pain.</p>
</div>
<div>
<p>
If your an expert in drupal you probably already realized when you need to clear the cache in order to see changes and when not too. the developer module even makes it quite easy to do. However for me, and I am quite sure to quite a lot of other people it is not that clear.
</p>
</div>
<div>
<p>&#8220;Wait&#8221;, you might say. &#8220;Drupal has a disable cache setting&#8221;. You would be right to say that. Only it doesn&#8217;t completely disable the cache, only part of the cache, namely the page caching. To truly disable cache you need to do a bit of a hacking to the cache code. Yes I know they say to never hack core (cache is part of the core drupal release). for me this was worth it. I figure as long as you remember its there and don&#8217;t use it in production you should be fine. The following piece of code needs to be added in <code>include/cache.inc</code>. There are two functions there that you need to edit:</p>
<ul>
<li><code>cache_get</code></li>
<li><code>cache_set</code></li>
</ul>
<p>In <code>cache_get</code> place the code right after the <code>global $user</code>. In <code>cache_set</code>  place it at the start of the function. Here is the code that you need to add.<br />
<code><br />
if(variable_get('cache', CACHE_DISABLED) == CACHE_DISABLED) {<br />
    return 0;<br />
}<br />
</code><br />
Kudos for this hack goes to Rolf van de Krol. Cheers mate.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2009/05/29/how-to-truly-disable-drupal-cache/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Django and static files</title>
		<link>http://blog.kfirbreger.com/2008/09/26/django-and-static-files/</link>
		<comments>http://blog.kfirbreger.com/2008/09/26/django-and-static-files/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 18:18:18 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/?p=90</guid>
		<description><![CDATA[After a long break I have resumed my side project in django. Last night I came upon a problem. When testing a page outside django, the page was rendered correctly. When it was rendered through django the javascript files were not located. At this point I have to admit I was a bit fullish and [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>After a long break I have resumed my side project in django. Last night I came upon a problem. When testing a page outside django, the page was rendered correctly. When it was rendered through django the javascript files were not located.</p>
</div>
<div>
<p>At this point I have to admit I was a bit fullish and forgot to look at the web server&#8217;s log to see if the files were correctly served. that was an hour and a half of trying to figure out why the javascript functions were not found. So after smartening up I found out that the javascript files were not found. It seemed that django kept looking for them in the wrong location. Using the example <a href="http://docs.djangoproject.com/en/dev/howto/static-files/?from=olddocs">here</a> I eventually got it all to working.</p>
</div>
<div>
<p>It comes down to this. in the settings.py file there is a reference to the media URL and to the file system path to the media directory. Adding the following code to the urls.py<br />
<code><br />
if settings.DEBUG:<br />
urlpatterns += patterns('',<br />
(r'^tripcalc/media/(?P<br />
.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),<br />
)<br />
</code><br />
Will make sure that while django is in debug mode, serving of the static files will be done via django. for production sites it is better to let a dedicated web server (such as Apache) serve these static files.<br />
And that took care of it. I can now continue with the development. And it also enabled me to call the CSS file, so style is also shown. hurray.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2008/09/26/django-and-static-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Secret software</title>
		<link>http://blog.kfirbreger.com/2008/08/07/secret-software/</link>
		<comments>http://blog.kfirbreger.com/2008/08/07/secret-software/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 11:17:40 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[it]]></category>
		<category><![CDATA[spyware]]></category>
		<category><![CDATA[thinking]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/?p=76</guid>
		<description><![CDATA[An interesting talk about secret software and why it should not be allowed in the public sector]]></description>
			<content:encoded><![CDATA[<div>
<p>
An interesting talk about secret software and why it should not be allowed in the public sector
</p>
</div>
<p>
<embed src="http://blip.tv/play/AcSDRIT3Pg" type="application/x-shockwave-flash" width="240" height="200" allowscriptaccess="always" allowfullscreen="true"></embed> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2008/08/07/secret-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

