Changeset 1612 for trunk/pylucid/tests/unittest_plugin/unittest_plugin.py
- Timestamp:
- 05/31/08 22:01:20 (22 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/pylucid/tests/unittest_plugin/unittest_plugin.py
r1609 r1612 17 17 """ 18 18 19 from pprint import pformat 20 19 21 from PyLucid.system.BasePlugin import PyLucidBasePlugin 20 22 … … 34 36 # db_table is optional 35 37 # db_table = 'PyLucid_test' 36 #app_label = 'PyLucidPlugins'37 app_label = 'PyLucid'38 app_label = 'PyLucidPlugins' 39 # app_label = 'PyLucid' 38 40 39 41 class TestAlbum(models.Model): … … 46 48 47 49 createby = models.ForeignKey(User, related_name="test_createby", 48 null=True, blank=True49 )50 lastupdateby = models.ForeignKey(User, related_name="test_lastupdateby",51 50 null=True, blank=True 52 51 ) … … 54 53 # db_table is optional 55 54 # db_table = 'PyLucid_test' 56 #app_label = 'PyLucidPlugins'57 app_label = 'PyLucid'55 app_label = 'PyLucidPlugins' 56 # app_label = 'PyLucid' 58 57 59 58 def __unicode__(self): 60 return u"TestAlbum '%s', ID %s" % (self.name, self.id) 59 return u"TestAlbum '%s', ID %s, createby: %s" % ( 60 self.name, self.id, self.createby 61 ) 61 62 62 63 PLUGIN_MODELS = (TestArtist, TestAlbum) … … 72 73 PyLucid.template_addons.lucidTag 73 74 """ 74 self.response.write("args: %r, kwargs: %r" % (args, kwargs)) 75 self.response.write("<pre>\n") 76 self.response.write("args:\n") 77 self.response.write("%s\n" % pformat(args)) 78 self.response.write("pformarted kwargs:\n") 79 self.response.write("%s\n" % pformat(kwargs)) 80 self.response.write("</pre>") 75 81 76 82 def hello_world(self): … … 90 96 self.response.write("Test the plugin models\n") 91 97 self.response.write("Create TestArtist\n") 92 artist 1= TestArtist(name="A test Artist\n")93 artist 1.save()94 self.response.write("entry with ID '%s' created\n" % artist 1.id)98 artist = TestArtist(name="A test Artist\n") 99 artist.save() 100 self.response.write("entry with ID '%s' created\n" % artist.id) 95 101 self.response.write("Create TestAlbum\n") 96 album 1= TestAlbum(97 artist = artist 1,102 album = TestAlbum( 103 artist = artist, 98 104 name = "A test Album", 99 105 num_stars = 10, 106 createby = self.request.user 100 107 ) 101 album1.save() 102 self.response.write("entry with ID '%s' created\n" % album1.id) 108 album.save() 109 self.response.write("entry with ID '%s' created:\n" % album.id) 110 self.response.write(u"%s\n" % album) 111 self.response.write("</pre>") 112 113 def all_models(self): 114 """ 115 Display all existing models 116 """ 117 self.response.write("<pre>\n") 103 118 self.response.write("All Albums:\n") 104 119 albums = TestAlbum.objects.all() 105 120 for album in albums: 106 121 self.response.write(u"%s: %s\n" % (album.id, album)) 122 123 self.response.write("</pre>") 107 124 108 125