Package ajango :: Package generator :: Package views :: Module empty
[hide private]
[frames] | no frames]

Source Code for Module ajango.generator.views.empty

 1  ########################################################################### 
 2  #                                                                         # 
 3  #  Copyright (C) 2016  Rafal Kobel <rafyco1@gmail.com>                    # 
 4  #                                                                         # 
 5  #  This program is free software: you can redistribute it and/or modify   # 
 6  #  it under the terms of the GNU General Public License as published by   # 
 7  #  the Free Software Foundation, either version 3 of the License, or      # 
 8  #  (at your option) any later version.                                    # 
 9  #                                                                         # 
10  #  This program is distributed in the hope that it will be useful,        # 
11  #  but WITHOUT ANY WARRANTY; without even the implied warranty of         # 
12  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the           # 
13  #  GNU General Public License for more details.                           # 
14  #                                                                         # 
15  #  You should have received a copy of the GNU General Public License      # 
16  #  along with this program.  If not, see <http://www.gnu.org/licenses/>.  # 
17  #                                                                         # 
18  ########################################################################### 
19  """ 
20  Obiekt generujacy strone typu 'empty'. 
21   
22  Obiekt generuje kod obsugujacy strone wyswietlajaca proste napisy. 
23   
24  Dostepne znaczniki 
25  ================== 
26   
27      1. B{ECHO} - Tag okalajacy tekst do wyswietlenia. 
28   
29  Generowany obiekt 
30  ================= 
31   
32  L{ajango.site.sites.empty} 
33  """ 
34   
35  from xml.dom                     import minidom 
36  from django.core.management.base import CommandError 
37  from ajango.generator.views      import ViewBase 
38   
39 -class EchoElem(object):
40 """ Klasa obiektu wyswietlajacego. """
41 - def __init__(self, text):
42 self.text = text
43 - def set_text(self, text):
44 """ Ustawienie tekstu do wyswietlenia. """ 45 self.text = text
46 - def render(self, view_name='view'):
47 """ Renderowanie elementu. """ 48 return "%s.add_echo(%r)" % (view_name, self.text)
49
50 -class View(ViewBase):
51 """ Klasa widoku wyswietlajacego. """
52 - def __init__(self, xmldoc, importRenderer, app):
53 self.code_elems = [] 54 ViewBase.__init__(self, xmldoc, importRenderer, app)
55 - def init(self):
56 """ Metoda inicjalizujaca. """ 57 self.type = "empty" 58 self.add_permited(["ECHO"])
59 - def execute(self, view, view_name='view'):
60 """ Wykonanie zadan obiektu. """ 61 for elem in self.code_elems: 62 self.add_line(elem.render(view_name))
63 - def check(self, name, xmldoc_elem):
64 """ Oczytanie nodow wewnetrznych. """ 65 if ViewBase.check(self, name, xmldoc_elem): 66 return True 67 if name.upper() == "ECHO": 68 if isinstance(xmldoc_elem.childNodes[0], minidom.Text): 69 self.code_elems.append( 70 EchoElem(xmldoc_elem.childNodes[0].toxml())) 71 return True 72 else: 73 raise CommandError("This element in ECHO is not str") 74 return False
75