<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,10 +1,12 @@
 from google.appengine.ext import db
 from google.appengine.ext import webapp
 from google.appengine.api.users import User
+from datetime import datetime
 import wsgiref.handlers
 
 class Entry(db.Model):
   user = db.UserProperty()
+  published = db.DateTimeProperty()
 
 entries = ['jonasgalvez@gmail.com', 'fabricio@gmail.com']
 
@@ -12,7 +14,7 @@ for entry in Entry.all():
   entry.delete()
 
 for entry in entries:
-  e = Entry(user=User(email=entry))
+  e = Entry(user=User(email=entry), published=datetime.now())
   e.put()
 
 class EntriesHandler(webapp.RequestHandler):</diff>
      <filename>examples/entries/entries.py</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,49 @@
+'''
+Configuration File
+
+Setup this file according to your application Models as to map their
+attributes to the equivalent atom elements.
+'''
+
+'''
+gae-rest needs to import the files containing your Models since it is
+unable to dynamic infer what are all the available entity kinds
+(content types) in your application
+'''
 models = ['entries.py']
-creator = {'Entry': 'user'}
-published = {}
+
+'''
+which attribute on each Entity can be used as atom &lt;author&gt; element
+Example: author = {'Entry': 'author'}
+'''
+author = {'Entry': 'user'}
+
+'''
+&lt;title&gt;
+Example: title = {'Entry': 'title'}
+'''
+title = {}
+
+'''
+&lt;content&gt;
+Example: content = {'Entry': 'body_html'}
+'''
+content = {}
+
+'''
+&lt;summary&gt;
+Example: summary = {'Entry': 'excerpt'}
+'''
+summary = {}
+
+'''
+&lt;published&gt;
+Example: published = {'Entry': 'published'}
+'''
+published = {'Entry': 'published'}
+
+'''
+&lt;updated&gt;
+Example: updated = {'Entry': 'updated'}
+'''
 updated = {}
\ No newline at end of file</diff>
      <filename>examples/entries/gae-rest/config.py</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,5 @@
 from __future__ import with_statement
+from datetime import datetime
 import os, re, sys, types
 sys.path += [os.path.split(os.path.abspath(__file__))[0]]
 import glob, urllib2
@@ -24,11 +25,7 @@ def expose(only=[]):
     sys.path.remove(pydir)
   return loadedfiles
 
-loadedfiles = expose()
-
-def retrieve_model_property_list(entity):
-  q = db.GqlQuery(&quot;SELECT * FROM XNExposedModel WHERE name = :1&quot;, entity)
-  return q[0].model_properties
+expose()
 
 class XNQueryHandler(webapp.RequestHandler):
   def get(self, format, version, query):
@@ -39,32 +36,53 @@ class XNQueryHandler(webapp.RequestHandler):
     kind = xnquery.resources.content.selectors.type.rightside
     atom = AtomBuilder(kind, objects)
     self.response.out.write(str(atom))
-
+
 class AtomBuilder:
   FEED_NS = {
     'xmlns': 'http://www.w3.org/2005/Atom',
     'xmlns:xn': 'http://www.ning.com/atom/1.0'
-  }
+  }
+  HANDLERS = {
+    'title': lambda value: value,
+    'content': lambda value: value.replace('&lt;','&amp;lt;'),
+    'summary': lambda value: value.replace('&lt;','&amp;lt;'),
+    'published': lambda value: '%sZ' % value.isoformat(),
+    'updated': lambda value: '%sZ' % value.isoformat(),
+    'author': 'process_author'
+  }
   def __init__(self, kind, objects):
     xml = builder(version='1.0', encoding='utf-8')
+    self.xml = xml
+    self.kind = kind
     with xml.feed(**self.FEED_NS):
       xml.title(&quot;GAE-REST Test Atom Feed&quot;)
       for object in objects:
         with xml.entry:
-          for property in object.properties().keys():
+          properties = object.properties()
+          self.process_known_elements(object, properties)
+          for property in properties:
             value = getattr(object, property)
-            if (kind in config.creator) and property == config.creator[kind]:
-              with xml.author:
-                if type(value) == User:
-                  xml.name(value.nickname())
-                  xml.email(value.email())
-                else:
-                  xml.name(value)
-            elif type(value) == list:
-              xml[&quot;xn:%s&quot; % property](' '.join(getattr(object, property)))
+            if type(value) == list:
+              xml[&quot;xn:%s&quot; % property](' '.join(value))
             else:
-              xml[&quot;xn:%s&quot; % property](getattr(object, property))
+              xml[&quot;xn:%s&quot; % property](str(value).replace('&lt;','&amp;lt;'))
     self.xml = xml
+  def process_author(self, value):
+    with self.xml.author:
+      if type(value) == User:
+        self.xml.name(value.nickname())
+        self.xml.email(value.email())
+      else:
+        self.xml.name(value)
+  def process_known_elements(self, object, properties):
+    for element in AtomBuilder.HANDLERS.keys():
+      m_element = getattr(config, element).get(self.kind, None)
+      if m_element != None:
+        if type(AtomBuilder.HANDLERS[element]) != str:
+          self.xml[element](AtomBuilder.HANDLERS[element](getattr(object, m_element)))
+        else:
+          getattr(self, AtomBuilder.HANDLERS[element])(getattr(object, m_element))
+        del properties[m_element]
   def __str__(self):
     return str(self.xml)
 </diff>
      <filename>examples/entries/gae-rest/xn.py</filename>
    </modified>
    <modified>
      <diff>@@ -25,11 +25,7 @@ def expose(only=[]):
     sys.path.remove(pydir)
   return loadedfiles
 
-loadedfiles = expose()
-
-def retrieve_model_property_list(entity):
-  q = db.GqlQuery(&quot;SELECT * FROM XNExposedModel WHERE name = :1&quot;, entity)
-  return q[0].model_properties
+expose()
 
 class XNQueryHandler(webapp.RequestHandler):
   def get(self, format, version, query):
@@ -46,36 +42,47 @@ class AtomBuilder:
     'xmlns': 'http://www.w3.org/2005/Atom',
     'xmlns:xn': 'http://www.ning.com/atom/1.0'
   }
+  HANDLERS = {
+    'title': lambda value: value,
+    'content': lambda value: value.replace('&lt;','&amp;lt;'),
+    'summary': lambda value: value.replace('&lt;','&amp;lt;'),
+    'published': lambda value: '%sZ' % value.isoformat(),
+    'updated': lambda value: '%sZ' % value.isoformat(),
+    'author': 'process_author'
+  }
   def __init__(self, kind, objects):
     xml = builder(version='1.0', encoding='utf-8')
+    self.xml = xml
+    self.kind = kind
     with xml.feed(**self.FEED_NS):
       xml.title(&quot;GAE-REST Test Atom Feed&quot;)
       for object in objects:
         with xml.entry:
-          for property in object.properties().keys():
+          properties = object.properties()
+          self.process_known_elements(object, properties)
+          for property in properties:
             value = getattr(object, property)
-            if (kind in config.creator) and property == config.creator[kind]:
-              with xml.author:
-                if type(value) == User:
-                  xml.name(value.nickname())
-                  xml.email(value.email())
-                else:
-                  xml.name(value)
-            elif (kind in config.title) and property == config.title[kind]:
-              xml.title(value)
-            elif (kind in config.content) and property == config.content[kind]:
-              xml.content(value.replace('&lt;','&amp;lt;'))
-            elif (kind in config.summary) and property == config.summary[kind]:
-              xml.summary(value.replace('&lt;','&amp;lt;'))
-            elif (kind in config.published) and property == config.published[kind]:
-              xml.published('%sZ' % value.isoformat())
-            elif (kind in config.updated) and property == config.updated[kind]:
-              xml.updated('%sZ' % value.isoformat())
-            elif type(value) == list:
+            if type(value) == list:
               xml[&quot;xn:%s&quot; % property](' '.join(value))
             else:
               xml[&quot;xn:%s&quot; % property](str(value).replace('&lt;','&amp;lt;'))
     self.xml = xml
+  def process_author(self, value):
+    with self.xml.author:
+      if type(value) == User:
+        self.xml.name(value.nickname())
+        self.xml.email(value.email())
+      else:
+        self.xml.name(value)
+  def process_known_elements(self, object, properties):
+    for element in AtomBuilder.HANDLERS.keys():
+      m_element = getattr(config, element).get(self.kind, None)
+      if m_element != None:
+        if type(AtomBuilder.HANDLERS[element]) != str:
+          self.xml[element](AtomBuilder.HANDLERS[element](getattr(object, m_element)))
+        else:
+          getattr(self, AtomBuilder.HANDLERS[element])(getattr(object, m_element))
+        del properties[m_element]
   def __str__(self):
     return str(self.xml)
 </diff>
      <filename>xn.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>f4877316bdbb043fc217a66a29f64f114e934660</id>
    </parent>
    <parent>
      <id>ebd9c6edb5f6365ea9b34f4c3498a16cef83a446</id>
    </parent>
  </parents>
  <author>
    <name>Fabricio Zuardi</name>
    <email>fabricio@Zuardi-main.local</email>
  </author>
  <url>http://github.com/fczuardi/gae-rest/commit/4ece816195a2ceb3f46780cf783bff4f0f9533d2</url>
  <id>4ece816195a2ceb3f46780cf783bff4f0f9533d2</id>
  <committed-date>2008-07-06T20:48:01-07:00</committed-date>
  <authored-date>2008-07-06T20:48:01-07:00</authored-date>
  <message>Merge branch 'galvez/master'</message>
  <tree>b89e5b9c0b6f9a868288dd809214dfefab286554</tree>
  <committer>
    <name>Fabricio Zuardi</name>
    <email>fabricio@Zuardi-main.local</email>
  </committer>
</commit>
