def assemble(self): self.define_page(HTML5Page).use_layout( PageLayout( contents_layout=ColumnLayout('main').with_slots())) self.define_user_interface('/a_ui', UIWithSlots, {'text': 'main'}, name='myui')
def assemble(self): self.define_page(HTML5Page).use_layout( PageLayout(contents_layout=ColumnLayout( 'main', 'secondary').with_slots())) home = self.define_view('/', title='Home page') home.set_slot('main', Form.factory('myform')) home.set_slot('secondary', Form.factory('myform'))
def assemble(self): self.define_page(HTML5Page).use_layout( PageLayout(contents_layout=ColumnLayout('main').with_slots())) home = self.define_view('/', title='Hello') home.set_slot('main', P.factory(text='Hello world')) home.set_slot('nonexistantslotname', P.factory(text='I am breaking'))
def assemble(self): self.define_page(HTML5Page).use_layout( PageLayout(contents_layout=ColumnLayout( *view_slots.keys()).with_slots())) self.define_view('/', title='Home page', slot_definitions=view_slots)
def assemble(self): home = self.define_view('/', title='Hello') home.set_page(HTML5Page.factory().use_layout( PageLayout( contents_layout=ColumnLayout('main').with_slots()))) home.set_slot('main', P.factory(text='Hello world')) home.set_slot('footer', P.factory(text='I am the footer'))
def assemble(self): self.define_page(HTML5Page).use_layout( PageLayout(contents_layout=ColumnLayout('main').with_slots())) home = self.define_view('/', title='Home page') other_view = self.define_view('/page2', title='Page 2') home.set_slot('main', MyForm.factory('myform')) self.define_transition(model_object.events.an_event, home, other_view)
def assemble(self): self.define_page(HTML5Page).use_layout( PageLayout( contents_layout=ColumnLayout('main').with_slots())) self.define_user_interface('/a_ui', UIWithParameterisedUserInterfaces, IdentityDictionary(), name='myui')
def assemble(self): self.define_page(HTML5Page).use_layout( PageLayout( contents_layout=ColumnLayout('main').with_slots())) home = self.define_view('/a_view', 'Title', write_check=disallowed) home.set_slot('main', MyForm.factory())
def assemble(self): self.define_page(HTML5Page).use_layout( PageLayout( contents_layout=ColumnLayout('main').with_slots())) self.define_user_interface('/a_ui', UIWithDetour, IdentityDictionary(), name='test_ui')
def assemble(self): self.define_page(HTML5Page).use_layout( PageLayout( contents_layout=ColumnLayout('main').with_slots())) self.define_user_interface('/dhtml_ui', DhtmlUI, {'main_slot': 'main'}, name='test_ui', static_div_name='astatic')
def column_slots(fixture): """A ColumnLayout can be made that adds a Slot to each added column, named after the column it is added to.""" widget = Div(fixture.view).use_layout( ColumnLayout('column_name_a', 'column_name_b').with_slots()) column_a, column_b = widget.layout.columns.values() vassert('column_name_a' in column_a.available_slots) vassert('column_name_b' in column_b.available_slots)
def adding_unnamed_columns(fixture): """You can add a column by calling add_column on the ColumnLayout""" widget = Div(fixture.view).use_layout(ColumnLayout()) vassert(not widget.children) widget.layout.add_column(ResponsiveSize()) vassert(len(widget.children) == 1) vassert(isinstance(widget.children[0], Div))
def assemble(self): self.define_page(HTML5Page).use_layout( PageLayout( contents_layout=ColumnLayout('main').with_slots())) slot_definitions = {'main': Form.factory('the_form')} view = self.define_view('/', title='Hello', slot_definitions=slot_definitions) failing_precondition = ViewPreCondition( lambda: False, exception=SomeException) passing_precondition = ViewPreCondition(lambda: True) view.add_precondition(passing_precondition) view.add_precondition(failing_precondition)
def column_layout_basics(fixture): """A ColumnLayout turns its Widget into a sequence of columns, each of which is a Div.""" layout = ColumnLayout('column_a', 'column_b') widget = Div(fixture.view) vassert(not widget.children) widget.use_layout(layout) column_a, column_b = widget.children vassert(isinstance(column_a, Div)) vassert(isinstance(column_b, Div))
def order_of_columns(fixture): """Columns are added in the order given to the ColumnLayout constructor, and the Div representing each column can be obtained using dictionary access on Layout.columns.""" widget = Div(fixture.view).use_layout( ColumnLayout('column_name_a', 'column_name_b')) column_a = widget.layout.columns['column_name_a'] column_b = widget.layout.columns['column_name_b'] first_column, second_column = widget.children vassert(first_column is column_a) vassert(second_column is column_b)
def assemble(self): self.define_page(HTML5Page).use_layout( PageLayout( contents_layout=ColumnLayout('main').with_slots())) step1 = self.define_view('/firstStepOfDetour', title='Step 1', detour=True) step1.set_slot( 'main', A.factory_from_bookmark(step1.as_bookmark(self))) home = self.define_view('/initial', title='View a') home.set_slot('main', A.factory_from_bookmark(step1.as_bookmark(self)))
def assemble(self): self.define_page(HTML5Page).use_layout( PageLayout( contents_layout=ColumnLayout('main').with_slots())) detour_ui = self.define_user_interface('/uiWithDetour', UIWithDetour, IdentityDictionary(), name='second_ui') bookmark = detour_ui.get_bookmark( relative_path='/firstStepOfDetour') self.define_user_interface('/uiWithLink', UIWithLink, IdentityDictionary(), name='first_ui', bookmark=bookmark)
def assemble(self): self.define_page(HTML5Page).use_layout( PageLayout( contents_layout=ColumnLayout('main').with_slots())) home = self.define_view('/', title='Home page') other_view = self.define_view( '/page2', title='Page 2', view_class=ParameterisedView, event_argument1=IntegerField(required=True), view_argument=IntegerField(required=True)) home.set_slot('main', MyForm.factory('myform')) self.define_transition(model_object.events.an_event, home, other_view)
def columns_classes(fixture): """The Div added for each column specified to ColumnLayout is given a CSS class derived from the column name.""" widget = Div(fixture.view).use_layout(ColumnLayout('column_name_a')) column_a = widget.layout.columns['column_name_a'] vassert('column-column_name_a' in column_a.get_attribute('class'))
def with_size(self): """You can optionally specify the sizes a column should adhere to.""" self.layout = ColumnLayout('column_a', ('column_b', ResponsiveSize(default='1/2'))) self.expected_class_for_column_b = 'pure-u-1-2'
def assemble(self): self.define_page(HTML5Page).use_layout( PageLayout(contents_layout=ColumnLayout('main').with_slots())) home = self.define_view('/', title='Home page') other_view = self.define_view('/page2', title='Page 2') home.set_slot('main', MyForm.factory('myform', other_view))
def assemble(self): main = self.define_page(HTML5Page).use_layout( PageLayout(contents_layout=ColumnLayout('main').with_slots())) main.add_default_slot('main', P.factory(text='defaulted slot contents')) self.define_view('/', title='Hello')
def without_sizes(self): """Construct the ColumnLayout with a list of column names.""" self.layout = ColumnLayout('column_a', 'column_b') self.expected_class_for_column_b = 'pure-u'