Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 956 Categories, Downloaded 50.382.187 Times

megrok.layout 1.2.0

Company: Souheil Chelfouh
Date Added: June 15, 2013  |  Visits: 465

megrok.layout

Report Broken Link
Printer Friendly Version


Product Homepage
Download (33 downloads)



The megrok.layout package provides a simple way to write view components which can be included into a defined layout. It turns around two main components : the Page and the Layout.<br />Layout<br /><br />The layout is a component allowing you to design your site. Often, it's the common structure shared between all the pages. Technically, it is a class based on the view components interface, providing a 'render' and 'update' method.<br /><br />Let's implement a simple Layout:<br /><br /> >>> from megrok.layout import Layout<br /> >>> from zope.interface import Interface<br /> >>> import grokcore.component as grok<br /><br /> >>> class MyLayout(Layout):<br /> ... grok.name('mylayout')<br /> ... grok.context(Interface)<br /> ...<br /> ... def render(self):<br /> ... return u"a simple layout"<br /><br />We grok our component:<br /><br /> >>> grok_component('MyLayout', MyLayout)<br /> True<br /><br />We check it has been correctly registered:<br /><br /> >>> from megrok.layout import ILayout<br /> >>> from zope.component import getMultiAdapter<br /> >>> from zope.publisher.browser import TestRequest<br /><br /> >>> layout = getMultiAdapter((TestRequest(), Interface), ILayout)<br /> >>> isinstance(layout, MyLayout)<br /> True<br /> >>> layout.render()<br /> u'a simple layout'<br /><br />Now let's see how to use this Layout in a specific context using a Page.<br />Page<br /><br />The page is the specific code that you want to control. It is based on the grokcore.View browser page implementation and therefore provides a render and update method. The render method will simply return the specific HTML code generated by the template or the render method code while __call__ will lookup for a Layout component and renders itself inside it.<br /><br />First, we'll create 2 models that will serve as exemples.<br /><br /> >>> class Aurochs(grok.Context):<br /> ... description = u'Looks like a bull'<br /><br /> >>> class Mammoth(grok.Context):<br /> ... description = u'Looks like an elephant'<br /><br />Let's create now a page that will display their description.<br /><br /> >>> from megrok.layout import Page<br /> >>> class AnimalDisplay(Page):<br /> ... grok.name('display')<br /> ... grok.context(Interface)<br /> ...<br /> ... def render(self):<br /> ... return self.context.description<br /><br />Grokking our Page will let us use it.<br /><br /> >>> grok_component('AnimalDisplay', AnimalDisplay)<br /> True<br /> >>> wooly = Mammoth()<br /> >>> page = getMultiAdapter((wooly, TestRequest()), name='display')<br /> >>> page.content()<br /> u'Looks like an elephant'<br /> >>> page()<br /> u'a simple layout'<br /><br />As we can see, the page is using the layout, on the __call__ to render. Of course, this example Layout doesn't provide any interesting feature. Let's create something more interesting, by using our page with the help of the 'content' method:<br /><br /> >>> class MammothLayout(Layout):<br /> ... grok.context(Mammoth)<br /> ...<br /> ... def render(self):<br /> ... return u'Header. Page: %s. Footer' % self.view.content()<br /><br /> >>> grok_component('MammothLayout', MammothLayout)<br /> True<br /> >>> page()<br /> u'Header. Page: Looks like an elephant. Footer'

Requirements: No special requirements
Platforms: *nix, Linux
Keyword: Class Component Components Create Description Gtgtgt Import Interface Layout Megroklayout Method Render Renderself Return Simple Specific Testrequest U039looks
Users rating: 0/10

License: Freeware Size: 20.48 KB
USER REVIEWS
More Reviews or Write Review


MEGROK.LAYOUT RELATED
Database Tools  -  cbMySQL 4.0.2
cbMySQL is a PHP Class witch can create, alter, and modify MySQL databases and tables. For backup issues, you can export CSV data directly with only one class method. The MySQL object is much easier to handle than PHPs built in functions, and...
44.03 KB  
Programming  -  dolmen.forms.base 1.0 Beta 2
dolmen.forms.base is a package in charge of providing basic functionalities to work with zeam.form Forms. From the form to the field dolmen.forms.base provides few functions dedicated to the task of applying dict datas to object...
10.24 KB  
Network & Internet  -  zope.mimetype 1.3.1
This package provides a way to work with MIME content types. There are several interfaces defined here, many of which are used primarily to look things up based on different bits of information. The basic idea behind this is that...
61.44 KB  
Database Tools  -  SPSQLite Class 1.0
SPSQLite Class simplifies the use of SQLite databases. With SPSQLite Class you can create an SQLite database, connect to a database, execute a query, perform simple transactions.
10 KB  
Modules  -  Auto locale import 5.x-1.x-de
The autolocale module and enclosed localized install profile provides a profile to automatically import interface translations in install time and later when modules are enabled / disabled.Most of the module's functionality (with better...
20.48 KB  
Network & Internet  -  ifGraph 0.4.10rc3
ifGraph provides a tool to create graphs of network interface traffic via SNMP queries. ifGraph is a set of Perl scripts created to help network administrators to visualize network flow on a daily, weekly, monthly, and yearly basis. The graphics...
 
Libraries  -  Tree::PseudoIncLib 0.05
Tree::PseudoIncLib is a Perl class for encapsulating a description of pseudo-INC array. ABSTRACT This module encapsulates a perl-type library description data and provides methods for manipulating that data. It is in no way associated with any...
38.91 KB  
Libraries  -  Bio::Tools::Run::PiseApplication::align2model 1.4
Bio::Tools::Run::PiseApplication::align2model is a Bioperl class for align2model - create a multiple alignment of sequences to an existing model. Parameters: align2model (String) run (String) Run name db (Sequence) Sequences to align...
829.44 KB  
Libraries  -  General Applet Interface Library 0.5.10
The goal of the General Applet Interface Library is to give programmers a simple yet powerful applet interface. This library supports wmapplet/dockapps, GNOME 2 panel applets, and ROX panel applets. This library supports at the moment Dockapps,...
286.72 KB  
Libraries  -  Class::Multimethods::Pure 0.13
Class::Multimethods::Pure is a Perl module that contains a method-ordered multimethod dispatch. SYNOPSIS use Class::Multimethods::Pure; package A; sub magic { rand() > 0.5 } package B; use base A; package C; use base A; BEGIN { multi...
15.36 KB  
NEW DOWNLOADS IN LINUX SOFTWARE, PROGRAMMING
Linux Software  -  EasyEDA PCB Designer for Linux 2.0.0
EasyEDA, a great web based EDA(Electronics Design Automation) tool, online PCB tool, online PCB software for electronics engineers, educators, students, makers and enthusiasts. Theres no need to install any software. Just open EasyEDA in any...
34.4 MB  
Linux Software  -  wpCache® WordPress HTTP Cache 1.9
wpCache® is a high-performance, distributed object, caching system application, generic in nature, but intended for use in speeding up dynamic web applications, by decreasing database load time. wpCache® decreases dramatically the page...
3.51 MB  
Linux Software  -  Polling Autodialer Software 3.4
ICTBroadcast Auto Dialer software has a survey campaign for telephone surveys and polls. This auto dialer software automatically dials a list of numbers and asks them a set of questions that they can respond to, by using their telephone keypad....
488 B  
Linux Software  -  Total Video Converter Mac Free 3.5.5
Total Video Converter Mac Free developed by EffectMatrix Ltd is the official legal version of Total Video Converter which was a globally recognized brand since 2006. Total Video Converter Mac Free is a free but powerful all-in-one video...
17.7 MB  
Linux Software  -  Skeith mod_log_sql Analyzer 2.10beta2
Skeith is a php based front end for analyzing logs for Apache using mod_log_sql.
47.5 KB  
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  Math::GMPf 0.29
Math::GMPf - perl interface to the GMP library's floating point (mpf) functions.
30.72 KB  
Programming  -  Net::Wire10 1.08
Net::Wire10 is a Pure Perl connector that talks to Sphinx, MySQL and Drizzle servers. Net::Wire10 implements the low-level network protocol, alias the MySQL wire protocol version 10, necessary for talking to one of the aforementioned...
30.72 KB  
Programming  -  logilab-common 0.56.2
a bunch of modules providing low level functionnalities shared among some python projects devel Please note that some of the modules have some extra dependencies. For instance, logilab.common.db will require a db-api 2.0 compliant...
174.08 KB  
Programming  -  OpenSSL for linux 1.0.0a
The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a...
3.83 MB