<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -66,31 +66,39 @@ def handle_tiddler_div(bagname, tiddler_div, store):
     &quot;&quot;&quot;
     Create a new Tiddler from a tiddler div, in BeautifulSoup form.
     &quot;&quot;&quot;
-    new_tiddler = Tiddler(tiddler_div['title'], bag=bagname)
+    tiddler = get_tiddler_from_div(tiddler_div)
+    tiddler.bag = bagname
+    try:
+        store.put(tiddler)
+    except OSError, exc:
+        # This tiddler has a name that we can't yet write to the
+        # store. For now we just state the error and carry on.
+        import sys
+        print &gt;&gt; sys.stderr, 'Unable to write %s: %s' % (tiddler.title, exc)
+
 
+def get_tiddler_from_div(node):
+    &quot;&quot;&quot;
+    Create a Tiddler from a BeautifulSoup DIV node
+    &quot;&quot;&quot;
+    tiddler = Tiddler(node['title'])
     try:
-        new_tiddler.text = _html_decode(tiddler_div.find('pre').contents[0])
+        tiddler.text = _html_decode(node.find('pre').contents[0])
     except IndexError:
         # there are no contents in the tiddler
-        new_tiddler.text = ''
+        tiddler.text = ''
 
-    for attr, value in tiddler_div.attrs:
-        data = tiddler_div.get(attr, None)
+    for attr, value in node.attrs:
+        data = node.get(attr, None)
         if data and attr != 'tags':
             if attr in (['modifier', 'created', 'modified']):
-                new_tiddler.__setattr__(attr, data)
+                tiddler.__setattr__(attr, data)
             elif (attr not in ['title', 'changecount'] and
                 not attr.startswith('server.')):
-                new_tiddler.fields[attr] = data
-    new_tiddler.tags = _tag_string_to_list(tiddler_div.get('tags', ''))
+                tiddler.fields[attr] = data
+    tiddler.tags = _tag_string_to_list(node.get('tags', ''))
 
-    try:
-        store.put(new_tiddler)
-    except OSError, exc:
-        # This tiddler has a name that we can't yet write to the
-        # store. For now we just state the error and carry on.
-        import sys
-        print &gt;&gt; sys.stderr, 'Unable to write %s: %s' % (new_tiddler.title, exc)
+    return tiddler
 
 
 def _tag_string_to_list(string):</diff>
      <filename>tiddlywebwiki/tiddlywiki.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>cfb5b73d686c5dc94dca192cdd11113906267cee</id>
    </parent>
  </parents>
  <author>
    <name>FND</name>
    <email>fnd@oda.(none)</email>
  </author>
  <url>http://github.com/tiddlyweb/tiddlywebwiki/commit/5028fc78f8e2fec058faa477ea051498330a76c3</url>
  <id>5028fc78f8e2fec058faa477ea051498330a76c3</id>
  <committed-date>2009-11-05T06:44:55-08:00</committed-date>
  <authored-date>2009-11-05T06:44:53-08:00</authored-date>
  <message>refactored handle_tiddler_div to provide reusable get_tiddler_from_div</message>
  <tree>fdb8abd16e827fb1951a6939bfa7763284157b13</tree>
  <committer>
    <name>FND</name>
    <email>fnd@oda.(none)</email>
  </committer>
</commit>
