1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 """
20 Obiekt generujacy strone typu 'input'.
21
22 Obiekt generuje kod obsugujacy strone agregujaca widoki.
23
24 Dostepne znaczniki
25 ==================
26
27 1. B{TABLE} - Tabela do ktorej nalezy wstawic dane.
28 - I{name} - Nazwa tabeli.
29 2. B{INPUT} - Element przyjmujacy dane L{wiecej <ajango.database.inputs>}.
30
31 Generowany obiekt
32 =================
33
34 L{ajango.site.sites.input}
35 """
36
37 from django.core.management.base import CommandError
38 from ajango.generator.views import ViewBase
39 from ajango.database.inputs import input_factory
40
41 -class View(ViewBase):
42 """ Klasa generujaca widok wprowadzania danych. """
43 - def __init__(self, xmldoc, importRenderer, app):
48 """ Metoda inicjalizujaca. """
49 self.type = "input"
50 self.add_permited(["TABLE", "INPUT"])
51 - def post_init(self):
52 """ Czynnosci do wykonania po inicjalizacji. """
53 if self.table == "":
54 raise CommandError("Table name isn't define")
55 if len(self.inputs) == 0:
56 raise CommandError("Don't define any input object")
57 - def check(self, name, xmldoc_elem):
58 """ Oczytanie nodow wewnetrznych. """
59 if super(View, self).check(name, xmldoc_elem):
60 return True
61 if name.upper() == "TABLE":
62 self.table = xmldoc_elem.getAttribute("name")
63 return True
64 if name.upper() == "INPUT":
65 self.inputs.append(input_factory(xmldoc_elem))
66 return True
67 return False
68 - def execute(self, view, view_name='view'):
69 """ Wykonanie zadan obiektu. """
70 self.add_import("models", ".")
71 self.add_line("%s.set_models(models)" % view_name)
72 self.add_line("%s.set_table_name(%r)" % (view_name, self.table))
73 for elem in self.inputs:
74 elem.execute(self, view_name)
75