WordPress to Python Dictionary for Web2Py

Web/web2py_utils: docs/source/wordpress2py.rst@648560fd3b20

docs/source/wordpress2py.rst
author “Thadeus Burgess <[email protected]>”
Fri Nov 12 11:08:14 2010 -0600 (2 months ago)
changeset 45 648560fd3b20
permissions -rw-r–r–
Added tag R-0.0.13 for changeset 0a4c0f986e18
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l1" id="l1">     1</a> WordPress to Python
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l2" id="l2">     2</a> ===================
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l3" id="l3">     3</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l4" id="l4">     4</a> Turns a wordpress export xml file into a python dictionary
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l5" id="l5">     5</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l6" id="l6">     6</a> .. note::
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l7" id="l7">     7</a>     taking coffee for donations :)
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l8" id="l8">     8</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l9" id="l9">     9</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l10" id="l10">    10</a> Usage
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l11" id="l11">    11</a> -----
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l12" id="l12">    12</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l13" id="l13">    13</a>     >>> from web2py_utils import wordpress2py
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l14" id="l14">    14</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l15" id="l15">    15</a> Retrieve a python dict that represents the wordpress database::
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l16" id="l16">    16</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l17" id="l17">    17</a>     >>> data = wordpress2py.word2py(open('/path/to/wordpress.2009-11-30.xml', 'r'))
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l18" id="l18">    18</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l19" id="l19">    19</a> Insert data into web2py DAL using a schema
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l20" id="l20">    20</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l21" id="l21">    21</a>     >>> ids_inserted = wordpress2py.schema_migrate(db, schema, '/path/to/wordpress.2009-11-30.xml')
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l22" id="l22">    22</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l23" id="l23">    23</a> Use the data dictionary to create a custom migration function.
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l24" id="l24">    24</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l25" id="l25">    25</a> Dictionary layout is documented in the word2py function.
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l26" id="l26">    26</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l27" id="l27">    27</a> Schema Key Patterns
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l28" id="l28">    28</a> -------------------
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l29" id="l29">    29</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l30" id="l30">    30</a> .. code-block:: python
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l31" id="l31">    31</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l32" id="l32">    32</a>     {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l33" id="l33">    33</a>         '<DATA TABLE>': {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l34" id="l34">    34</a>             '<DATA COLUMN>': '<DAL TABLE>/<DAL FIELD>',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l35" id="l35">    35</a>         },
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l36" id="l36">    36</a>         '<DATA TABLE>': {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l37" id="l37">    37</a>             '<PYTHON EXEC doit>': {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l38" id="l38">    38</a>                 '<DATA COLUMN>': '<DAL TABLE>/<DAL FIELD>',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l39" id="l39">    39</a>             }
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l40" id="l40">    40</a>         }
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l41" id="l41">    41</a>     }
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l42" id="l42">    42</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l43" id="l43">    43</a> Schema Options
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l44" id="l44">    44</a> --------------
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l45" id="l45">    45</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l46" id="l46">    46</a> .. code-block:: python
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l47" id="l47">    47</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l48" id="l48">    48</a>     '<DATA TABLE>': {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l49" id="l49">    49</a>         'categories',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l50" id="l50">    50</a>         'tags',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l51" id="l51">    51</a>         'posts',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l52" id="l52">    52</a>         'comments',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l53" id="l53">    53</a>         'post_categories',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l54" id="l54">    54</a>         'post_tags',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l55" id="l55">    55</a>     }
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l56" id="l56">    56</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l57" id="l57">    57</a>     '<DATA COLUMN>': {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l58" id="l58">    58</a>         'categories' ->
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l59" id="l59">    59</a>             name
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l60" id="l60">    60</a>             slug
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l61" id="l61">    61</a>             parent
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l62" id="l62">    62</a>         'tags' ->
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l63" id="l63">    63</a>             name
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l64" id="l64">    64</a>             slug
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l65" id="l65">    65</a>         'posts' ->
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l66" id="l66">    66</a>             id
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l67" id="l67">    67</a>             title
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l68" id="l68">    68</a>             slug
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l69" id="l69">    69</a>             status
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l70" id="l70">    70</a>             type
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l71" id="l71">    71</a>             link
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l72" id="l72">    72</a>             pub_date
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l73" id="l73">    73</a>             description
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l74" id="l74">    74</a>             content
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l75" id="l75">    75</a>             post_date
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l76" id="l76">    76</a>             post_date_gmt
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l77" id="l77">    77</a>             categories -> list of strings (categories slug)
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l78" id="l78">    78</a>             tags -> list of strings (tags slug)
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l79" id="l79">    79</a>         'comments' ->
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l80" id="l80">    80</a>             id
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l81" id="l81">    81</a>             author
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l82" id="l82">    82</a>             author_email
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l83" id="l83">    83</a>             author_url
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l84" id="l84">    84</a>             author_ip
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l85" id="l85">    85</a>             date
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l86" id="l86">    86</a>             date_gmt
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l87" id="l87">    87</a>             content
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l88" id="l88">    88</a>             approved
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l89" id="l89">    89</a>     }
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l90" id="l90">    90</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l91" id="l91">    91</a> EXEC ENVIRONMENT
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l92" id="l92">    92</a> ----------------
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l93" id="l93">    93</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l94" id="l94">    94</a> .. warning::
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l95" id="l95">    95</a>     IMPORTANT
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l96" id="l96">    96</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l97" id="l97">    97</a>     THIS CODE MUST BE VALID PYTHON CODE
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l98" id="l98">    98</a>     IT MUST SET A VARIABLE NAMED doit TO EITHER TRUE OR FALSE
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l99" id="l99">    99</a>     IF TRUE, THE RECORDS IN THE CORRESPONDING DICT ARE INSERTED INTO THE DATABASE
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l100" id="l100">   100</a>     THIS CAN BE RECURSIVE
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l101" id="l101">   101</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l102" id="l102">   102</a>     EXEC ENVIRONMENT HAS ACCESS TO THESE VARIABLES
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l103" id="l103">   103</a>     data <dict> (this is the data from wordpress)
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l104" id="l104">   104</a>     data['title'] # sample for posts
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l105" id="l105">   105</a>     data['parent'] # sample for categories
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l106" id="l106">   106</a>     This data matches options for <DATA COLUMN>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l107" id="l107">   107</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l108" id="l108">   108</a> Example Schemas
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l109" id="l109">   109</a> ---------------
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l110" id="l110">   110</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l111" id="l111">   111</a> The module comes with two example schemas
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l112" id="l112">   112</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l113" id="l113">   113</a> wordpress2py.default_mengu_blog_schema::
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l114" id="l114">   114</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l115" id="l115">   115</a>     {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l116" id="l116">   116</a>         'categories': {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l117" id="l117">   117</a>             'name': 'category/title',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l118" id="l118">   118</a>         },
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l119" id="l119">   119</a>         'posts': {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l120" id="l120">   120</a>             'doit = True if data["type"] == "post" else False': {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l121" id="l121">   121</a>                 'title': 'post/title',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l122" id="l122">   122</a>                 'content': 'post/body',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l123" id="l123">   123</a>                 'post_date': 'post/dateline',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l124" id="l124">   124</a>             },
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l125" id="l125">   125</a>             'doit = True if data["type"] == "page" else False': {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l126" id="l126">   126</a>                 'title': 'page/title',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l127" id="l127">   127</a>                 'content': 'page/content',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l128" id="l128">   128</a>             },
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l129" id="l129">   129</a>         },
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l130" id="l130">   130</a>         'comments': {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l131" id="l131">   131</a>             'id_post': 'comment/post_id',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l132" id="l132">   132</a>             'author': 'comment/name',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l133" id="l133">   133</a>             'author_email': 'comment/email',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l134" id="l134">   134</a>             'content': 'comment/comment',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l135" id="l135">   135</a>             'date': 'comment/dateline',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l136" id="l136">   136</a>         },
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l137" id="l137">   137</a>         'post_categories': {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l138" id="l138">   138</a>             'id_category': 'relations/category',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l139" id="l139">   139</a>             'id_post': 'relations/post',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l140" id="l140">   140</a>         },
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l141" id="l141">   141</a>     }
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l142" id="l142">   142</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l143" id="l143">   143</a> .. note::
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l144" id="l144">   144</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l145" id="l145">   145</a>     Take a good look at the 'doit' keys. This is how to use EXEC ENVIRONMENT
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l146" id="l146">   146</a>     effectively. This basically allows you some control over how
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l147" id="l147">   147</a>     your data will go into the database. In case you have multiple
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l148" id="l148">   148</a>     tables for different post types.
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l149" id="l149">   149</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l150" id="l150">   150</a> wordpress2py.default_schema::
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l151" id="l151">   151</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l152" id="l152">   152</a>      {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l153" id="l153">   153</a>         'categories': {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l154" id="l154">   154</a>             'name': 'category/title',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l155" id="l155">   155</a>             'parent': 'category/parent',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l156" id="l156">   156</a>         },
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l157" id="l157">   157</a>         'tags': {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l158" id="l158">   158</a>             'name': 'tag/title',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l159" id="l159">   159</a>         },
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l160" id="l160">   160</a>         'posts': {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l161" id="l161">   161</a>             'title': 'post/title',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l162" id="l162">   162</a>             'slug': 'post/slug',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l163" id="l163">   163</a>             'status': 'post/status',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l164" id="l164">   164</a>             'type': 'post/type',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l165" id="l165">   165</a>             'post_date': 'post/pub_date',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l166" id="l166">   166</a>             'content': 'post/content',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l167" id="l167">   167</a>         },
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l168" id="l168">   168</a>         'comments': {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l169" id="l169">   169</a>             'id_post': 'comment/id_post',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l170" id="l170">   170</a>             'author': 'comment/author',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l171" id="l171">   171</a>             'author_email': 'comment/email',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l172" id="l172">   172</a>             'author_url': 'comment/site',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l173" id="l173">   173</a>             'date': 'comment/posted_on',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l174" id="l174">   174</a>             'approved': 'comment/approved',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l175" id="l175">   175</a>             'content': 'comment/content',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l176" id="l176">   176</a>         },
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l177" id="l177">   177</a>         'post_categories': {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l178" id="l178">   178</a>             'id_category': 'category_relations/category',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l179" id="l179">   179</a>             'id_post': 'category_relations/post',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l180" id="l180">   180</a>         },
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l181" id="l181">   181</a>         'post_tags': {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l182" id="l182">   182</a>             'id_tag': 'tag_relations/tag',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l183" id="l183">   183</a>             'id_post': 'tag_relations/post',
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l184" id="l184">   184</a>         },
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l185" id="l185">   185</a>     }
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l186" id="l186">   186</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l187" id="l187">   187</a> Example Custom Migration
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l188" id="l188">   188</a> ------------------------
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l189" id="l189">   189</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l190" id="l190">   190</a> This is an example custom migration script to export to mengu blog.
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l191" id="l191">   191</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l192" id="l192">   192</a> This is just here for a full reference in case you have more complex needs.
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l193" id="l193">   193</a> However the schema works perfectly and is very versatile.::
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l194" id="l194">   194</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l195" id="l195">   195</a>     def custom_migrate_to_mengu_database(db):
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l196" id="l196">   196</a>         data = word2py(open('wordpress_export.xml', 'r'))
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l197" id="l197">   197</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l198" id="l198">   198</a>         category_ids = {}
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l199" id="l199">   199</a>         post_ids = {}
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l200" id="l200">   200</a>         comment_ids = {}
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l201" id="l201">   201</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l202" id="l202">   202</a>         for c in data['categories']:
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l203" id="l203">   203</a>             category_ids[c['name']] = db.category.insert(title=c['name'])
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l204" id="l204">   204</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l205" id="l205">   205</a>         for post in data['posts']:
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l206" id="l206">   206</a>             if post['type'] == 'post':
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l207" id="l207">   207</a>                 post_id = db.post.insert(
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l208" id="l208">   208</a>                     title = post['title'],
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l209" id="l209">   209</a>                     body = post['content'],
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l210" id="l210">   210</a>                     dateline = post['pub_date'],
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l211" id="l211">   211</a>                 )
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l212" id="l212">   212</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l213" id="l213">   213</a>                 for c in post['categories']:
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l214" id="l214">   214</a>                     db.relations.insert(
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l215" id="l215">   215</a>                         post = post_id,
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l216" id="l216">   216</a>                         category = category_ids[c]
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l217" id="l217">   217</a>                     )
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l218" id="l218">   218</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l219" id="l219">   219</a>                 for c in post['comments']:
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l220" id="l220">   220</a>                     comment_id = db.comment.insert(
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l221" id="l221">   221</a>                         post_id = post_id,
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l222" id="l222">   222</a>                         name = c['author'],
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l223" id="l223">   223</a>                         email = c['author_email'],
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l224" id="l224">   224</a>                         comment = c['content'],
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l225" id="l225">   225</a>                         dateline = c['date']
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l226" id="l226">   226</a>                     )
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l227" id="l227">   227</a>             elif post['type'] == 'page':
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l228" id="l228">   228</a>                 post_id = db.page.insert(
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l229" id="l229">   229</a>                     title = post['title'],
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l230" id="l230">   230</a>                     content = post['content']
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l231" id="l231">   231</a>                 )
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l232" id="l232">   232</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l233" id="l233">   233</a> Word 2 Py
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l234" id="l234">   234</a> ---------
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l235" id="l235">   235</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l236" id="l236">   236</a> Requires elementtree
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l237" id="l237">   237</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l238" id="l238">   238</a> Returns python dictionary representing the wordpress blog.
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l239" id="l239">   239</a> Certain metadata may be missing.
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l240" id="l240">   240</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l241" id="l241">   241</a> Content is sorted based on the arrangment of the data in the xml file.
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l242" id="l242">   242</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l243" id="l243">   243</a> Dict structure::
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l244" id="l244">   244</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l245" id="l245">   245</a>     # -> means a list, or array.
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l246" id="l246">   246</a>
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l247" id="l247">   247</a>     db {
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l248" id="l248">   248</a>         title
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l249" id="l249">   249</a>         link
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l250" id="l250">   250</a>         description
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l251" id="l251">   251</a>         pub_date
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l252" id="l252">   252</a>         language
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l253" id="l253">   253</a>         categories ->
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l254" id="l254">   254</a>             name
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l255" id="l255">   255</a>             slug
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l256" id="l256">   256</a>             parent
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l257" id="l257">   257</a>             description (if available)
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l258" id="l258">   258</a>         tags ->
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l259" id="l259">   259</a>             name
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l260" id="l260">   260</a>             slug
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l261" id="l261">   261</a>         posts ->
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l262" id="l262">   262</a>             id
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l263" id="l263">   263</a>             title
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l264" id="l264">   264</a>             slug
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l265" id="l265">   265</a>             status
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l266" id="l266">   266</a>             type
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l267" id="l267">   267</a>             link
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l268" id="l268">   268</a>             pub_date
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l269" id="l269">   269</a>             description
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l270" id="l270">   270</a>             content
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l271" id="l271">   271</a>             post_date
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l272" id="l272">   272</a>             post_date_gmt
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l273" id="l273">   273</a>             categories -> flat array
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l274" id="l274">   274</a>             tags -> flat array
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l275" id="l275">   275</a>             comments ->
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l276" id="l276">   276</a>                 id
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l277" id="l277">   277</a>                 author
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l278" id="l278">   278</a>                 author_email
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l279" id="l279">   279</a>                 author_url
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l280" id="l280">   280</a>                 author_ip
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l281" id="l281">   281</a>                 date
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l282" id="l282">   282</a>                 date_gmt
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l283" id="l283">   283</a>                 content
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l284" id="l284">   284</a>                 approved
<a class="linenr" href="http://hg.thadeusb.com/Web/web2py_utils/file/648560fd3b20/docs/source/wordpress2py.rst#l285" id="l285">   285</a>     }
0

0
 

Using Google Services API by command line

Using Google Services API by command line | Francisco Souza:

Google has a lot of useful services (and useless too): Youtube, Blogger, Calendar, Docs, Picasa, etc. For each of those services, Google provides a powerful API, and now, we can consume that APIs using the a command line tool, written in Python! :)

“GoogleCL brings Google services to the command line” – extract from official website. So, let’s try it…

Google currently supports Blogger, Calendar, Contacts, Docs, Picasa and Youtube. Using GoogleCL, we can upload a video to Youtube or edit a document of Google Docs. Here is same examples:

Posting something to Blogger:

$ google blogger post –title “Exploring GoogleCL” –tags “GoogleCL, Google, command line, python” “I am really excited with the power of this new Google service”

Uploading a video to Youtube:

$ google youtube post –category Humor kid_dancing.avi

Uploading some photos to Picasa, in a new album

$ google picasa create –title “Travel to South Africa” /home/francisco/Pictures/SouthAfricaTravel/*jpg

How do I install it?

As I said above, GoogleCL is a Python written tool, so you can install it using pip:

$ [sudo] pip install gdata googlecl

As you can see, we also installed gdata, a Python library used to speak with the Google Data APIs. Learn more about it here.

How do it works?

GoogleCL uses OAuth to grant access from services to the command line application. When you run a command for the first time, you will need to grant access in your browser and after grant the access, you can use the service freely.

I used GoogleCL for a simple example, creating a album called “My wallpapers” on Picasa. Here is my terminal output:

francisco@radukibook ~  $ google picasa post –title “My wallpapers” ~/Pictures/Wall/*.jpg
Please specify user: [email protected]
(Hint: You can automatically launch your browser by adding “auth_browser = ” to your config file under the GENERAL section, or define the BROWSER environment variable.)
Please log in and/or grant access via your browser at [supressed] then hit enter.
Loading file /home/francisco/Pictures/Wall/21940_1223712046050_122_1015lo.jpg to album My wallpapers
[...]

So after upload all jpg files that was inside of my ~/Pictures/Wall directory, I listed my albums and see the public URL for “My wallpapers album”:

francisco@radukibook ~  $ google picasa list-albums
My wallpapers,http://picasaweb.google.com/franciscossouza/MyWallpapers
[...]

If you access the provided URL, you can see my wallpapers :)

Share
This entry was posted in google and tagged , , . Bookmark the permalink.

2 Responses to Using Google Services API by command line

  1. Luca Bastos says:

    >Typo?

    $ [sudo] pip install gdata googlecl

  2. Francisco Souza says:

    >Hi Luca, thanks for the help, I fixed the post ;)

Leave a Reply

0

0
 

gdbe Google-Docs Base Editor

gdbe – Project Hosting on Google Code:

Logo
                

The Google-Docs Base Editor (GDBE) is a web based text editor built to model the existing Google-Docs editors. It integrates with Google-Docs via the GData API.

The purpose of GDBE is to give developers a starting point for building editors for different document types that can be integrated into Google’s editor suite.

GDBE is written in Java and makes use of the GData API to communicate with Google Docs. The client side is implemented GWT and the server side is built with AppEngine in mind.

Projects Using GDBE

LaTeX Lab – LaTeX Editor for Google Docs

Cloudie – Desktop Editor for Google Docs

Live Version

The latest GDBE version is available here.

0

0
 

pyswf

Examples – Swftools:

pyswf

Examples for movies generated using the Python interface for librfxswf.

The python versions of the h.263 movie-compression abuse:

distort1.swf.screenshot.png Picture Distorter (Source)

zoom.swf.screenshot.png Picture artificial detail zoom (Source)

xor.swf.snapshot.png X^Y Transform (Source)

coltunnel.screenshot.png Color Tunnel

Another h.263 based effect The whole movie was actually generated using a combination of swfc and Python. First, the tunnel itself was generated by coltunnel.py. Then, to hide the seed in the middle of the picture, a black-to transparent gradient image created by gradient.sc was overlayed using swfcombine -zT tunnel_raw.swf gradient.swf -o coltunnel.swf.

0

0
 

SVG-edit Online Google Code

SVG-edit:

















Layers

Layer 1

Move elements to:

L a y e r s






B
i


>>




Image Properties

Canvas Dimensions


Included Images


Editor Preferences

Editor Background

Note: Background will not be saved with image.


0

0
 

Bumpbox – a lightbox clone with support for PDF, flv, swf, audio, images and html files.

Bumpbox - a lightbox clone with support for PDF, flv, swf, audio, images and html files.

 

Bumpbox is another lightbox clone with a few advantages over other lightboxes – it supports not only all common media types but also PDF’s.

 

Easy to implement

Yet, the integration and implementation on your own site is pretty simple. Just add the scripts to your head section, add classes to your links that should use bumpbox, define a rel tag with the size that the bumpbox should have and you’re ready to roll.

 

Automatic media detection

Bumpbox automatically detects what kind of filetype you wish to show in the box, so you do not need to specify the type, easing the process of integration.

 

PLEASE NOTE: We do not answer support questions about bumpbox any more. If you need information or help. check out our blog.

 

Bumpbox lightbox samples

 

 

0

0
 

host2py – Host your own file with App Engine

host2py – Project Hosting on Google Code:

A simple file hosting that can be run on google app engine.

This is created with web2py, so you need web2py to run this application.

Install instructions: This step is optional if you don’t want to sett the appname in url. – put the host2py folder in applications, and copy routes.py in web2py root folder. Once setup, login then go to /default/setup or /host2py/default/setup to add permissions.

You can see it live at http://host2py.appspot.com

Also you can check my blog post if you don’t know anything about anything to set this up. http://faisal.altlimit.com/2010/08/free-privatepublic-file-hosting-with.html

0

0
 

OpenCast/camsoftware

OpenCast/camsoftware – The Science Media Network:

OpenCast relevant software in Cambridge

Service public site source code
talks.cam http://www.talks.cam.ac.uk http://source.caret.cam.ac.uk/talks.cam/trunk/
CamTV/mediaplayer database http://mediaplayer.group.cam.ac.uk
UCS-SMS upload tool no public site ftp://ftp.csx.cam.ac.uk/pub/software/multimedia/sms/
UCS-SMS job scheduler no public site ftp://ftp.csx.cam.ac.uk/pub/software/multimedia/sms/
UCS-SMS web front end/rss http://sms.csx.cam.ac.uk  ?

For licensing see relevant source code.

http://www.steeple.org.uk/wiki/faq/software

0

0
 

Web Application Exploits and Defenses (Part 3)

Web Application Exploits and Defenses (Part 3)

A Codelab by Bruce Leban, Mugdha Bendre, and Parisa Tabriz

UPDATED July 13, 2010: We have changed the name of the codelab application to Gruyere and have moved the location to this page. Please update your bookmarks.

Client-State Manipulation

When a user interacts with a web application, they do it indirectly through a browser. When the user clicks a button or submits a form, the browser sends a request back to the web server. Because the browser runs on a machine that can be controlled by an attacker, the application must not trust any data sent by the browser.

It might seem that not trusting any user data would make it impossible to write a web application but that’s not the case. If the user submits a form that says they wish to purchase an item, it’s OK to trust that data. But if the submitted form also includes the price of the item, that’s something that cannot be trusted.

Elevation of Privilege

Convert your account to an administrator account.

Hint 1

Hint 2

Exploit and Fixes

Cookie Manipulation

Because the HTTP protocol is stateless, there’s no way a web server can automatically know that two requests are from the same user. For this reason, cookies were invented. When a web site includes a cookie (an arbitrary string) in a HTTP response, the browser automatically sends the cookie back to the browser on the next request. Web sites can use the cookie to save session state. Gruyere uses cookies to remember the identity of the logged in user. Since the cookie is stored on the client side, it’s vulnerable to manipulation. Gruyere protects the cookies from manipulation by adding a hash to it. Notwithstanding the fact that this hash isn’t very good protection, you don’t need to break the hash to execute an attack.

Get Gruyere to issue you a cookie for someone else’s account.

Hint 1

Hint 2

Exploit and Fix

Cross-Site Request Forgery (XSRF)

The previous section said “If the user submits a form that says they wish to purchase an item, it’s OK to trust that data.” That’s true as long as it really was the user that submitted the form. If your site is vulnerable to XSS, then the attacker can fake any request as if it came from the user. But even if you’ve protected against XSS, there’s another attack that you need to protect against: cross-site request forgery.

When a browser makes requests to a site, it always sends along any cookies it has for that site, regardless of where the request comes from. Additionally, web servers generally cannot distinguish between a request initiated by a deliberate user action (e.g., user clicking on “Submit” button) versus a request made by the browser without user action (e.g., request for an embedded image in a page). Therefore, if a site receives a request to perform some action (like deleting a mail, changing contact address), it cannot know whether this action was knowingly initiated by the user — even if the request contains authentication cookies. An attacker can use this fact to fool the server into performing actions the user did not intend to perform.

More details

XSRF Challenge

The goal here is to find a way to perform an account changing action on behalf of a logged in Gruyere user without their knowledge. Assume you can get them to visit a web page under your control.

Find a way to get someone to delete one of their Gruyere snippets.

Hint

Exploit and Fix

Cross Site Script Inclusion (XSSI)

0

0
 

tokland: My personal repository for code and documentation

Python

LangBots

LangBots is a framework to make programmable bots fight in a battlefield. The framework itself is written in Python and Pygame, but participants may implement their bots in the programming language they like.

http://code.google.com/p/langbots/

PySheng

PySheng downloads a book from Google Books and saves the PNG images for each page (and a unique PDF). It can be run either from the command-line or using a simple graphical interface. It should work out-of-the box for Unix systems (GNU/Linux, BSD) and (with minor modifications) for Windows.

http://code.google.com/p/pysheng

Youtube-upload

Upload videos to Youtube from the command-line (splitting the video if necessary):

http://code.google.com/p/youtube-upload

Spynner

Programmatic web browser module for Python with Javascript/AJAX support based upon the QtWebKit framework.

http://code.google.com/p/spynner/

Simple subtitles Python library

Currently this module only scales (adjusts fps timing) for SRT subtitles:

http://code.google.com/p/tokland/source/browse/trunk/subtitles

Sudoku solver

Yet another brute-force sudoku solver, but written following Functional Programming paradigm:

http://code.google.com/p/tokland/source/browse/#svn/trunk/sudoku

Hotkeys for the X-Window

Xhotkeys provides a simple and easily configurable hotkey launcher for the X-Window System, binding keys and mouse buttons to configurable commands. It should work on all desktops (Gnome, KDE, …) available for the GNU/Linux operating system. Configuration files can be modified manually or using a graphical GTK+ configurator.

http://xhotkeys.googlecode.com

Asterisk Phonepatch

The term phonepatch usually refers to the hardware device used to connect a radio transceiver and a phoneline. Asterisk-phonepatch do that task, but it’s mainly software, as it uses the Asterisk software PBX.

http://www.nongnu.org/asterisk-phpatch

RPN calculator

A Python command-line interactive Reverse Polish notation calculator:

http://tokland.googlecode.com/svn/trunk/rpn/rpn.py

Extract audio from a CD

Extract/rip audio tracks from a CD (people used to do that, before the P2P era) with song titles obtained from Gracenote (formerly CDDB).

http://tokland.googlecode.com/svn/trunk/cd2ogg/cd2ogg.py

Automatic SSH backlinks

The SSH protocol is very useful to create secure port-forwarding between computers. If you need permanent SSH links (typically with some forwarded ports), sshlink may be useful to you.

http://www.nongnu.org/sshlink/

Simple math game solver

Given a bunch of numbers, and using the four basic operations (add, subtract, multiply, divide), find -or be as close as possible to- another given number. Spanish readers will recall it from the popular Cifras y Letras TV quiz show.

http://tokland.googlecode.com/svn/trunk/cifras/cifras.py

$ python cifras.py 3 7 10 50 100 8 546 
546 = ((((50+7)*8)-10)+100)

Pyeuler Project

The Euler Project proposes some mathematical problems to be solved using any programming language. In this wiki, we see and discuss solutions using Python and functional programming. Python is not a functional-language, but it was interesting anyhow:

http://pyeuler.wikidot.com

Uya Wifi router web interface

OSPF Router Configurator with a web interface developed with CherryPy.

http://code.google.com/p/uya/

UTM converter

Python module to convert UTM to/from Latitude-Longitude coordinates.

http://tokland.googlecode.com/svn/trunk/utm/utm.py

Colorize regular expressions in files

Simple script to Detect and colorize regular expressions in files or standard input:

http://code.google.com/p/tokland/source/browse/trunk/colorize/colorize.py

Python FAQ

I mantain the official FAQ page for Python-es mailing list.

http://python-es-faq.wikidot.com/

0

0