~ubuntu-branches/ubuntu/trusty/grantlee/trusty

« back to all changes in this revision

Viewing changes to dox/differences_django.dox

  • Committer: Bazaar Package Importer
  • Author(s): Harald Sitter
  • Date: 2010-06-11 23:41:45 UTC
  • Revision ID: james.westby@ubuntu.com-20100611234145-oas7rhdrbwy8j55c
Tags: upstream-0.1.1
ImportĀ upstreamĀ versionĀ 0.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
namespace Grantlee
 
3
{
 
4
 
 
5
/**
 
6
 
 
7
  @page differences_django Differences between Django and Grantlee
 
8
 
 
9
  There are several notable differences between Django and %Grantlee, which arise mostly due to different implementation languages and features of the Qt framework.
 
10
 
 
11
  Everything in python is a first class object, which means that django filter functions and tag functions can have properties and attributes. In %Grantlee, it is necessary to use classes to obtain the same effect, where Django uses only functions for filters. Additionally, C++ classes need to share an interface if they are to be treated the same way. This is not necessary in Django because python uses dynamic typing, and all methods behave similarly to virtual functions. %Grantlee uses the Abstract Factory pattern to achieve the same affect for tags, and a simple interface for filters.
 
12
 
 
13
  Django tag libraries are loaded through normal python modules. This means that all libraries can be loaded dynamically. %Grantlee achieves the same effect by using the <a href="http://doc.trolltech.com/latest/plugins-howto.html">QtPlugin system</a> to load additional libraries dynamically.
 
14
 
 
15
  In Django, any python object can be inserted into a Context. Then, methods which can change a class must have the 'alters_data' attribute, so that rendering a template can not alter the objects being rendered. Objects in %Grantlee are only introspectable to a limited amount determined by Q_PROPERTIES defined in wrapper classes. Therefore, the programmer can decide which properties to make available to the template system by wrapping them or not. It is encouraged, but not enforced to make sure scriptable wrapper methods are const.
 
16
 
 
17
  Python dictionary objects can be processed in templates. In %Grantlee, QVariantHash is supported, which has the same effect. QVariantHash keys must be strings, whereas python dictionary keys may be any pickle-able object.
 
18
 
 
19
  Django uses PHP datetime string format for the @gr_tag{now} tag, whereas %Grantlee uses QDateTime format.
 
20
 
 
21
  The Django autoescape system is based on marking a string object as safe. In Qt, this is not directly possible, so a wrapper class, Grantlee::SafeString is provided with several convenient operator overloads. This has (hopefully) minimal impact on plugin writers.
 
22
 
 
23
  Django performs string escaping on the assumption that the output string is HTML. In %Grantlee it is possible to implement escaping for other markups and text outputs by reimplementing OutputStream::escape.
 
24
 
 
25
  The Django cache system makes a lot of sense where templates are rendered in a fire-and-forget manner for a stateless protocol. It is not implemented in %Grantlee because we're generally not rendering similar templates from scratch multiple times and the templates can keep state for multiple uses.
 
26
 
 
27
*/
 
28
 
 
29
}
 
30