SlideShare una empresa de Scribd logo
1 de 33
Descargar para leer sin conexión
Reusando componentes Zope fuera de Zope
(y la web)
Roberto Allende
Menttes / Plone Foundation
rallende@menttes.com
http://robertoallende.com
twitter: robertoallende
 Buildout
 ZODB
 Zope Page Templates
 Adaptadores
Buildout is a Python-based build system for
creating, assembling and deploying applications
from multiple parts, some of which may be non-
Python-based. It lets you create a buildout
configuration and reproduce the same software
later.
Buildout
Tool for working with eggs
Repeatable
Developer oriented
Buildout | Features
$ easy_install zc.buildout
Buildout | Install
$ svn co http://miproyecto
$ python bootstrap.py
$ bin/buildout -v
…
$ bin/miproyecto.py
Buildout | Deploy con buildout
project/
bootstrap.py
buildout.cfg
.installed.cfg
parts/
develop-eggs/
bin/
buildout
miproyecto
eggs/
downloads/
Buildout | Deploy con buildout
[buildout]
index-url = http://pypi.it.uwosh.edu/
parts = instance
zopepy
eggdeps
degraph
extends = http://download.zope.org/Zope2/index/2.13.0a3/versions.cfg
eggs = tl.eggdeps
[instance]
recipe = plone.recipe.zope2instance
user = admin:admin
http-address = 8080
products = ${buildout:directory}/products
Buildout | buildout.cfg
http://buildout.org
Buildout | Mas información
Don’t squeeze your objects into tables:
store them in an object database.
ZODB
Transparent persistence for Python objects
Full ACID-compatible transaction support
History/undo ability
Efficient support for binary large objects (BLOBs)
Pluggable storages
Scalable architecture
ZODB | Features
$ easy_install ZODB3$ easy_install ZODB3
……
$ python$ python
>>> import ZODB>>> import ZODB
ZODB | Instalación
>>> from ZODB.FileStorage import FileStorage>>> from ZODB.FileStorage import FileStorage
>>> from ZODB.DB import DB>>> from ZODB.DB import DB
>>> storage = FileStorage('Data.fs')>>> storage = FileStorage('Data.fs')
>>> db = DB(storage)>>> db = DB(storage)
>>> connection = db.open()>>> connection = db.open()
>>> root = connection.root()>>> root = connection.root()
ZODB | Configuración
>>> root['account-1'] = Account()>>> root['account-1'] = Account()
>>> root['account-2'] = Account()>>> root['account-2'] = Account()
ZODB | Haciendo un objeto persistente
>>> import transaction>>> import transaction
>>> transaction.commit()>>> transaction.commit()
>>> root.keys()>>> root.keys()
['account-1', 'account-2']['account-1', 'account-2']
ZODB | Transactions
http://zodb.orghttp://zodb.org
ZODB | Mas Lectura
Zope Page Template allows you to generateZope Page Template allows you to generate
HTML dynamically.HTML dynamically.
Chameleon compiles templates to Python byte-code. It includes aChameleon compiles templates to Python byte-code. It includes a
complete implementation of the Zope Page Templates (ZPT) language andcomplete implementation of the Zope Page Templates (ZPT) language and
a partial implementation of the Genshi language.a partial implementation of the Genshi language.
ZPT vía Chameleon
ZPT templates are valid XML documentsZPT templates are valid XML documents
It uses namespaces for attributes and tags toIt uses namespaces for attributes and tags to
define the template behaviour.define the template behaviour.
Works on Python 2.4, 2.5 and 2.6, includingWorks on Python 2.4, 2.5 and 2.6, including
Google App EngineGoogle App Engine
PHP, Java, PerlPHP, Java, Perl
ZPT vía Chameleon
$ easy_install Chameleon$ easy_install Chameleon
ZPT vía Chameleon | Install
<table border="1"><table border="1">
<tr<tr tal:repeat="row range(10)"tal:repeat="row range(10)">>
<td<td tal:repeat="column range(10)"tal:repeat="column range(10)">>
<span<span tal:define="x repeat.row.number;tal:define="x repeat.row.number;
y repeat.column.number;y repeat.column.number;
z x * y"z x * y"
tal:replace="string:$x * $y = $z"tal:replace="string:$x * $y = $z">1 * 1 =>1 * 1 =
</span></span>
</td></td>
</tr></tr>
</table></table>
ZPT vía Chameleon | Template loader
from chameleon.zpt import loaderfrom chameleon.zpt import loader
template_path = os.path.join(os.path.dirname(__file__), "..", "templates")template_path = os.path.join(os.path.dirname(__file__), "..", "templates")
template_loader = loader.TemplateLoader(template_path,template_loader = loader.TemplateLoader(template_path,
auto_reload=os.environ['SERVER_SOFTWARE'].startswith('Dev'))auto_reload=os.environ['SERVER_SOFTWARE'].startswith('Dev'))
ZPT vía Chameleon | Ejemplo
def TestHandler(RequestHandler):def TestHandler(RequestHandler):
def get(self):def get(self):
template = template_loader.load("test.pt")template = template_loader.load("test.pt")
self.response.body = template(name="test")self.response.body = template(name="test")
ZPT vía Chameleon | Ejemplo
http://chameleon.repoze.orghttp://chameleon.repoze.org
http://blog.notdot.nethttp://blog.notdot.net
Webapps on App Engine, part 4: TemplatingWebapps on App Engine, part 4: Templating
ZPT vía Chameleon | Mas Lectura
Dynamic adaptation might feel like a typeDynamic adaptation might feel like a type
declaration, but it's not!declaration, but it's not!
It specifies a behavior, not a type; it's dynamic;It specifies a behavior, not a type; it's dynamic;
it's optional.it's optional.
Adapters
class File(object):class File(object):
body = 'foo bar'body = 'foo bar'
class FileSize(object):class FileSize(object):
def __init__(self, context):def __init__(self, context):
self.context = contextself.context = context
def getSize(self):def getSize(self):
return len(self.context.body)return len(self.context.body)
tamano = FileSize(File())tamano = FileSize(File())
print client.request()print client.request()
Adapters | Wrapper
Intrusivo clase baseIntrusivo clase base
Test aisladamenteTest aisladamente
Control factoryControl factory
Colision de nombresColision de nombres
Patches compitenPatches compiten
Lo hace RubyLo hace Ruby
Wrapping es molestoWrapping es molesto
Zope es Cool!Zope es Cool!
Adapters | Comparación con Otros
por Brandon Craig Rhodes
Herencia
oo
xx
xx
xx
Mixin
oo
oo
xx
xx
MonkeyPatch
oo
xx
xx
xx
Adapter
oo
oo
oo
oo
xx
oo
oo
oo
oo
oo
oo
Adapter
a'la Zope
1. Define an interface1. Define an interface
2. Register our adapter2. Register our adapter
3. Request adaptation3. Request adaptation
Adapters | 1, 2, 3
$ easy_install zope.interface$ easy_install zope.interface
$ easy_install zope.component$ easy_install zope.component
Adapters | Install
import zope.interfaceimport zope.interface
class IFile(zope.interface.Interface):class IFile(zope.interface.Interface):
body = zope.interface.Attribute('Contents of the file.')body = zope.interface.Attribute('Contents of the file.')
class ISize(zope.interface.Interface):class ISize(zope.interface.Interface):
def getSize():def getSize():
'Return the size of an object.''Return the size of an object.'
Adapters | Define an interface
from zope.interface.adapter import AdapterRegistryfrom zope.interface.adapter import AdapterRegistry
registry = AdapterRegistry()registry = AdapterRegistry()
registry.register([IFile], ISize, '', FileSize)registry.register([IFile], ISize, '', FileSize)
Adapters | Register our adapterRegister our adapter
>>>>>> def hook(provided, object):def hook(provided, object):
>>>>>> adapter = registry.lookup1(zope.interface.providedBy(object),adapter = registry.lookup1(zope.interface.providedBy(object),
>>>>>> provided, '')provided, '')
>>>>>> return adapter(object)return adapter(object)
>>>>>> from zope.interface.interface import adapter_hooksfrom zope.interface.interface import adapter_hooks
>>>>>> adapter_hooks.append(hook)adapter_hooks.append(hook)
>>> size = ISize(file)>>> size = ISize(file)
>>> size.getSize()>>> size.getSize()
77
Adapters | Request adaptationRequest adaptation
Using the Adapter RegistryUsing the Adapter Registry
http://docs.zope.org/zope3/Book/ifaceschema/human/show.htmlhttp://docs.zope.org/zope3/Book/ifaceschema/human/show.html
Using Grok to walk like a DuckUsing Grok to walk like a Duck
Brandon Rhodes - Pycon08, PloneConf 08Brandon Rhodes - Pycon08, PloneConf 08
Adapters | Mas Lectura
Muchas Gracias
Roberto Allende
http://robertoallende.com
Twitter: robertoallende
rallende@menttes.com

Más contenido relacionado

La actualidad más candente

Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...Puppet
 
Introducing Command Line Applications with Ruby
Introducing Command Line Applications with RubyIntroducing Command Line Applications with Ruby
Introducing Command Line Applications with RubyNikhil Mungel
 
Asynchronous Systems with Fn Flow
Asynchronous Systems with Fn FlowAsynchronous Systems with Fn Flow
Asynchronous Systems with Fn FlowJosé Paumard
 
Spl in the wild - zendcon2012
Spl in the wild - zendcon2012Spl in the wild - zendcon2012
Spl in the wild - zendcon2012Elizabeth Smith
 
C++ for Java Developers (JavaZone 2017)
C++ for Java Developers (JavaZone 2017)C++ for Java Developers (JavaZone 2017)
C++ for Java Developers (JavaZone 2017)Patricia Aas
 
Learning Python from Data
Learning Python from DataLearning Python from Data
Learning Python from DataMosky Liu
 
Using spl tools in your code
Using spl tools in your codeUsing spl tools in your code
Using spl tools in your codeElizabeth Smith
 
Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Workhorse Computing
 
Keep your repo clean
Keep your repo cleanKeep your repo clean
Keep your repo cleanHector Canto
 
C++ for Java Developers (SwedenCpp Meetup 2017)
C++ for Java Developers (SwedenCpp Meetup 2017)C++ for Java Developers (SwedenCpp Meetup 2017)
C++ for Java Developers (SwedenCpp Meetup 2017)Patricia Aas
 
Perl Tidy Perl Critic
Perl Tidy Perl CriticPerl Tidy Perl Critic
Perl Tidy Perl Criticolegmmiller
 
Doing It Wrong with Puppet -
Doing It Wrong with Puppet - Doing It Wrong with Puppet -
Doing It Wrong with Puppet - Puppet
 
Zend expressive workshop
Zend expressive workshopZend expressive workshop
Zend expressive workshopAdam Culp
 
나도 할 수 있다 오픈소스
나도 할 수 있다 오픈소스나도 할 수 있다 오픈소스
나도 할 수 있다 오픈소스효준 강
 
Composer - Package Management for PHP. Silver Bullet?
Composer - Package Management for PHP. Silver Bullet?Composer - Package Management for PHP. Silver Bullet?
Composer - Package Management for PHP. Silver Bullet?Kirill Chebunin
 
Bash in theory and in practice - part two
Bash in theory and in practice - part twoBash in theory and in practice - part two
Bash in theory and in practice - part twoValerio Balbi
 

La actualidad más candente (20)

Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
 
Introducing Command Line Applications with Ruby
Introducing Command Line Applications with RubyIntroducing Command Line Applications with Ruby
Introducing Command Line Applications with Ruby
 
Asynchronous Systems with Fn Flow
Asynchronous Systems with Fn FlowAsynchronous Systems with Fn Flow
Asynchronous Systems with Fn Flow
 
Spl in the wild - zendcon2012
Spl in the wild - zendcon2012Spl in the wild - zendcon2012
Spl in the wild - zendcon2012
 
Power of Puppet 4
Power of Puppet 4Power of Puppet 4
Power of Puppet 4
 
Basics of ANT
Basics of ANTBasics of ANT
Basics of ANT
 
C++ for Java Developers (JavaZone 2017)
C++ for Java Developers (JavaZone 2017)C++ for Java Developers (JavaZone 2017)
C++ for Java Developers (JavaZone 2017)
 
Learning Python from Data
Learning Python from DataLearning Python from Data
Learning Python from Data
 
Using spl tools in your code
Using spl tools in your codeUsing spl tools in your code
Using spl tools in your code
 
Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.
 
Keep your repo clean
Keep your repo cleanKeep your repo clean
Keep your repo clean
 
C++ for Java Developers (SwedenCpp Meetup 2017)
C++ for Java Developers (SwedenCpp Meetup 2017)C++ for Java Developers (SwedenCpp Meetup 2017)
C++ for Java Developers (SwedenCpp Meetup 2017)
 
Perl Tidy Perl Critic
Perl Tidy Perl CriticPerl Tidy Perl Critic
Perl Tidy Perl Critic
 
Doing It Wrong with Puppet -
Doing It Wrong with Puppet - Doing It Wrong with Puppet -
Doing It Wrong with Puppet -
 
Java Full Throttle
Java Full ThrottleJava Full Throttle
Java Full Throttle
 
Php extensions
Php extensionsPhp extensions
Php extensions
 
Zend expressive workshop
Zend expressive workshopZend expressive workshop
Zend expressive workshop
 
나도 할 수 있다 오픈소스
나도 할 수 있다 오픈소스나도 할 수 있다 오픈소스
나도 할 수 있다 오픈소스
 
Composer - Package Management for PHP. Silver Bullet?
Composer - Package Management for PHP. Silver Bullet?Composer - Package Management for PHP. Silver Bullet?
Composer - Package Management for PHP. Silver Bullet?
 
Bash in theory and in practice - part two
Bash in theory and in practice - part twoBash in theory and in practice - part two
Bash in theory and in practice - part two
 

Destacado

1001 formas de promover Python
1001 formas de promover Python1001 formas de promover Python
1001 formas de promover Pythonmenttes
 
Plone 3 Products Development Cookbook
Plone 3 Products Development CookbookPlone 3 Products Development Cookbook
Plone 3 Products Development Cookbookmenttes
 
From copy to paster: A middle-class Plone developer tale
From copy to paster: A middle-class Plone developer taleFrom copy to paster: A middle-class Plone developer tale
From copy to paster: A middle-class Plone developer talementtes
 
Plone 4 — what's up doc?
Plone 4 — what's up doc?Plone 4 — what's up doc?
Plone 4 — what's up doc?menttes
 
CMS + CRM: Integrando Plone y Salesforce
CMS + CRM: Integrando Plone y SalesforceCMS + CRM: Integrando Plone y Salesforce
CMS + CRM: Integrando Plone y Salesforcementtes
 
Construindo uma Intranet Corporativa utilizando Plone
Construindo uma Intranet Corporativa utilizando PloneConstruindo uma Intranet Corporativa utilizando Plone
Construindo uma Intranet Corporativa utilizando Plonementtes
 
El estado de Plone
El estado de PloneEl estado de Plone
El estado de Plonementtes
 
Management para emprendimientos: Lean Startup
Management para emprendimientos: Lean Startup Management para emprendimientos: Lean Startup
Management para emprendimientos: Lean Startup menttes
 

Destacado (8)

1001 formas de promover Python
1001 formas de promover Python1001 formas de promover Python
1001 formas de promover Python
 
Plone 3 Products Development Cookbook
Plone 3 Products Development CookbookPlone 3 Products Development Cookbook
Plone 3 Products Development Cookbook
 
From copy to paster: A middle-class Plone developer tale
From copy to paster: A middle-class Plone developer taleFrom copy to paster: A middle-class Plone developer tale
From copy to paster: A middle-class Plone developer tale
 
Plone 4 — what's up doc?
Plone 4 — what's up doc?Plone 4 — what's up doc?
Plone 4 — what's up doc?
 
CMS + CRM: Integrando Plone y Salesforce
CMS + CRM: Integrando Plone y SalesforceCMS + CRM: Integrando Plone y Salesforce
CMS + CRM: Integrando Plone y Salesforce
 
Construindo uma Intranet Corporativa utilizando Plone
Construindo uma Intranet Corporativa utilizando PloneConstruindo uma Intranet Corporativa utilizando Plone
Construindo uma Intranet Corporativa utilizando Plone
 
El estado de Plone
El estado de PloneEl estado de Plone
El estado de Plone
 
Management para emprendimientos: Lean Startup
Management para emprendimientos: Lean Startup Management para emprendimientos: Lean Startup
Management para emprendimientos: Lean Startup
 

Similar a Reusando componentes Zope fuera de Zope

Django on Jython, PyCon 2009
Django on Jython, PyCon 2009Django on Jython, PyCon 2009
Django on Jython, PyCon 2009Leonardo Soto
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy Systemadrian_nye
 
Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Deepak Garg
 
Building Content Types with Dexterity
Building Content Types with DexterityBuilding Content Types with Dexterity
Building Content Types with DexterityDavid Glick
 
Rifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotRifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotTsai Tsung-Yi
 
Making the most of your Test Suite
Making the most of your Test SuiteMaking the most of your Test Suite
Making the most of your Test Suiteericholscher
 
All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$Joe Ferguson
 
Building JBoss AS 7 for Fedora
Building JBoss AS 7 for FedoraBuilding JBoss AS 7 for Fedora
Building JBoss AS 7 for Fedorawolfc71
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller ColumnsJonathan Fine
 
ZopeSkel & Buildout packages
ZopeSkel & Buildout packagesZopeSkel & Buildout packages
ZopeSkel & Buildout packagesQuintagroup
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Ondřej Machulda
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShellBoulos Dib
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfonyFrancois Zaninotto
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterHaehnchen
 
Acceptance testing plone sites and add ons with robot framework and selenium
Acceptance testing plone sites and add ons with robot framework and seleniumAcceptance testing plone sites and add ons with robot framework and selenium
Acceptance testing plone sites and add ons with robot framework and seleniumAsko Soukka
 
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...Jesse Gallagher
 
Writing your Third Plugin
Writing your Third PluginWriting your Third Plugin
Writing your Third PluginJustin Ryan
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-wayRobert Lujo
 

Similar a Reusando componentes Zope fuera de Zope (20)

Django on Jython, PyCon 2009
Django on Jython, PyCon 2009Django on Jython, PyCon 2009
Django on Jython, PyCon 2009
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy System
 
Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Bangpypers april-meetup-2012
Bangpypers april-meetup-2012
 
Building Content Types with Dexterity
Building Content Types with DexterityBuilding Content Types with Dexterity
Building Content Types with Dexterity
 
Rifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotRifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobot
 
Making the most of your Test Suite
Making the most of your Test SuiteMaking the most of your Test Suite
Making the most of your Test Suite
 
All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$
 
Building JBoss AS 7 for Fedora
Building JBoss AS 7 for FedoraBuilding JBoss AS 7 for Fedora
Building JBoss AS 7 for Fedora
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
 
ZopeSkel & Buildout packages
ZopeSkel & Buildout packagesZopeSkel & Buildout packages
ZopeSkel & Buildout packages
 
Rails 101
Rails 101Rails 101
Rails 101
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
Acceptance testing plone sites and add ons with robot framework and selenium
Acceptance testing plone sites and add ons with robot framework and seleniumAcceptance testing plone sites and add ons with robot framework and selenium
Acceptance testing plone sites and add ons with robot framework and selenium
 
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
 
Writing your Third Plugin
Writing your Third PluginWriting your Third Plugin
Writing your Third Plugin
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-way
 

Más de menttes

Qué puede aprender Drupal de Plone
Qué puede aprender Drupal de PloneQué puede aprender Drupal de Plone
Qué puede aprender Drupal de Plonementtes
 
Integrando Plone con cualquier cosa
Integrando Plone con cualquier cosaIntegrando Plone con cualquier cosa
Integrando Plone con cualquier cosamenttes
 
Menttes: 5 años emprendiendo con Software Libre
Menttes: 5 años emprendiendo con Software LibreMenttes: 5 años emprendiendo con Software Libre
Menttes: 5 años emprendiendo con Software Librementtes
 
Intranets flexibles y escalables con Plone
Intranets flexibles y escalables con PloneIntranets flexibles y escalables con Plone
Intranets flexibles y escalables con Plonementtes
 
Combinación ganadora: Plone como CMS, tu framework preferido como frontend
Combinación ganadora: Plone como CMS, tu framework preferido como frontendCombinación ganadora: Plone como CMS, tu framework preferido como frontend
Combinación ganadora: Plone como CMS, tu framework preferido como frontendmenttes
 
No me hagas pensar. Buenas Prácticas para desarrollar en la web
No me hagas pensar. Buenas Prácticas para desarrollar en la webNo me hagas pensar. Buenas Prácticas para desarrollar en la web
No me hagas pensar. Buenas Prácticas para desarrollar en la webmenttes
 

Más de menttes (6)

Qué puede aprender Drupal de Plone
Qué puede aprender Drupal de PloneQué puede aprender Drupal de Plone
Qué puede aprender Drupal de Plone
 
Integrando Plone con cualquier cosa
Integrando Plone con cualquier cosaIntegrando Plone con cualquier cosa
Integrando Plone con cualquier cosa
 
Menttes: 5 años emprendiendo con Software Libre
Menttes: 5 años emprendiendo con Software LibreMenttes: 5 años emprendiendo con Software Libre
Menttes: 5 años emprendiendo con Software Libre
 
Intranets flexibles y escalables con Plone
Intranets flexibles y escalables con PloneIntranets flexibles y escalables con Plone
Intranets flexibles y escalables con Plone
 
Combinación ganadora: Plone como CMS, tu framework preferido como frontend
Combinación ganadora: Plone como CMS, tu framework preferido como frontendCombinación ganadora: Plone como CMS, tu framework preferido como frontend
Combinación ganadora: Plone como CMS, tu framework preferido como frontend
 
No me hagas pensar. Buenas Prácticas para desarrollar en la web
No me hagas pensar. Buenas Prácticas para desarrollar en la webNo me hagas pensar. Buenas Prácticas para desarrollar en la web
No me hagas pensar. Buenas Prácticas para desarrollar en la web
 

Último

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Último (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Reusando componentes Zope fuera de Zope

  • 1. Reusando componentes Zope fuera de Zope (y la web) Roberto Allende Menttes / Plone Foundation rallende@menttes.com http://robertoallende.com twitter: robertoallende
  • 2.  Buildout  ZODB  Zope Page Templates  Adaptadores
  • 3. Buildout is a Python-based build system for creating, assembling and deploying applications from multiple parts, some of which may be non- Python-based. It lets you create a buildout configuration and reproduce the same software later. Buildout
  • 4. Tool for working with eggs Repeatable Developer oriented Buildout | Features
  • 6. $ svn co http://miproyecto $ python bootstrap.py $ bin/buildout -v … $ bin/miproyecto.py Buildout | Deploy con buildout
  • 8. [buildout] index-url = http://pypi.it.uwosh.edu/ parts = instance zopepy eggdeps degraph extends = http://download.zope.org/Zope2/index/2.13.0a3/versions.cfg eggs = tl.eggdeps [instance] recipe = plone.recipe.zope2instance user = admin:admin http-address = 8080 products = ${buildout:directory}/products Buildout | buildout.cfg
  • 10. Don’t squeeze your objects into tables: store them in an object database. ZODB
  • 11. Transparent persistence for Python objects Full ACID-compatible transaction support History/undo ability Efficient support for binary large objects (BLOBs) Pluggable storages Scalable architecture ZODB | Features
  • 12. $ easy_install ZODB3$ easy_install ZODB3 …… $ python$ python >>> import ZODB>>> import ZODB ZODB | Instalación
  • 13. >>> from ZODB.FileStorage import FileStorage>>> from ZODB.FileStorage import FileStorage >>> from ZODB.DB import DB>>> from ZODB.DB import DB >>> storage = FileStorage('Data.fs')>>> storage = FileStorage('Data.fs') >>> db = DB(storage)>>> db = DB(storage) >>> connection = db.open()>>> connection = db.open() >>> root = connection.root()>>> root = connection.root() ZODB | Configuración
  • 14. >>> root['account-1'] = Account()>>> root['account-1'] = Account() >>> root['account-2'] = Account()>>> root['account-2'] = Account() ZODB | Haciendo un objeto persistente
  • 15. >>> import transaction>>> import transaction >>> transaction.commit()>>> transaction.commit() >>> root.keys()>>> root.keys() ['account-1', 'account-2']['account-1', 'account-2'] ZODB | Transactions
  • 17. Zope Page Template allows you to generateZope Page Template allows you to generate HTML dynamically.HTML dynamically. Chameleon compiles templates to Python byte-code. It includes aChameleon compiles templates to Python byte-code. It includes a complete implementation of the Zope Page Templates (ZPT) language andcomplete implementation of the Zope Page Templates (ZPT) language and a partial implementation of the Genshi language.a partial implementation of the Genshi language. ZPT vía Chameleon
  • 18. ZPT templates are valid XML documentsZPT templates are valid XML documents It uses namespaces for attributes and tags toIt uses namespaces for attributes and tags to define the template behaviour.define the template behaviour. Works on Python 2.4, 2.5 and 2.6, includingWorks on Python 2.4, 2.5 and 2.6, including Google App EngineGoogle App Engine PHP, Java, PerlPHP, Java, Perl ZPT vía Chameleon
  • 19. $ easy_install Chameleon$ easy_install Chameleon ZPT vía Chameleon | Install
  • 20. <table border="1"><table border="1"> <tr<tr tal:repeat="row range(10)"tal:repeat="row range(10)">> <td<td tal:repeat="column range(10)"tal:repeat="column range(10)">> <span<span tal:define="x repeat.row.number;tal:define="x repeat.row.number; y repeat.column.number;y repeat.column.number; z x * y"z x * y" tal:replace="string:$x * $y = $z"tal:replace="string:$x * $y = $z">1 * 1 =>1 * 1 = </span></span> </td></td> </tr></tr> </table></table> ZPT vía Chameleon | Template loader
  • 21. from chameleon.zpt import loaderfrom chameleon.zpt import loader template_path = os.path.join(os.path.dirname(__file__), "..", "templates")template_path = os.path.join(os.path.dirname(__file__), "..", "templates") template_loader = loader.TemplateLoader(template_path,template_loader = loader.TemplateLoader(template_path, auto_reload=os.environ['SERVER_SOFTWARE'].startswith('Dev'))auto_reload=os.environ['SERVER_SOFTWARE'].startswith('Dev')) ZPT vía Chameleon | Ejemplo
  • 22. def TestHandler(RequestHandler):def TestHandler(RequestHandler): def get(self):def get(self): template = template_loader.load("test.pt")template = template_loader.load("test.pt") self.response.body = template(name="test")self.response.body = template(name="test") ZPT vía Chameleon | Ejemplo
  • 23. http://chameleon.repoze.orghttp://chameleon.repoze.org http://blog.notdot.nethttp://blog.notdot.net Webapps on App Engine, part 4: TemplatingWebapps on App Engine, part 4: Templating ZPT vía Chameleon | Mas Lectura
  • 24. Dynamic adaptation might feel like a typeDynamic adaptation might feel like a type declaration, but it's not!declaration, but it's not! It specifies a behavior, not a type; it's dynamic;It specifies a behavior, not a type; it's dynamic; it's optional.it's optional. Adapters
  • 25. class File(object):class File(object): body = 'foo bar'body = 'foo bar' class FileSize(object):class FileSize(object): def __init__(self, context):def __init__(self, context): self.context = contextself.context = context def getSize(self):def getSize(self): return len(self.context.body)return len(self.context.body) tamano = FileSize(File())tamano = FileSize(File()) print client.request()print client.request() Adapters | Wrapper
  • 26. Intrusivo clase baseIntrusivo clase base Test aisladamenteTest aisladamente Control factoryControl factory Colision de nombresColision de nombres Patches compitenPatches compiten Lo hace RubyLo hace Ruby Wrapping es molestoWrapping es molesto Zope es Cool!Zope es Cool! Adapters | Comparación con Otros por Brandon Craig Rhodes Herencia oo xx xx xx Mixin oo oo xx xx MonkeyPatch oo xx xx xx Adapter oo oo oo oo xx oo oo oo oo oo oo Adapter a'la Zope
  • 27. 1. Define an interface1. Define an interface 2. Register our adapter2. Register our adapter 3. Request adaptation3. Request adaptation Adapters | 1, 2, 3
  • 28. $ easy_install zope.interface$ easy_install zope.interface $ easy_install zope.component$ easy_install zope.component Adapters | Install
  • 29. import zope.interfaceimport zope.interface class IFile(zope.interface.Interface):class IFile(zope.interface.Interface): body = zope.interface.Attribute('Contents of the file.')body = zope.interface.Attribute('Contents of the file.') class ISize(zope.interface.Interface):class ISize(zope.interface.Interface): def getSize():def getSize(): 'Return the size of an object.''Return the size of an object.' Adapters | Define an interface
  • 30. from zope.interface.adapter import AdapterRegistryfrom zope.interface.adapter import AdapterRegistry registry = AdapterRegistry()registry = AdapterRegistry() registry.register([IFile], ISize, '', FileSize)registry.register([IFile], ISize, '', FileSize) Adapters | Register our adapterRegister our adapter
  • 31. >>>>>> def hook(provided, object):def hook(provided, object): >>>>>> adapter = registry.lookup1(zope.interface.providedBy(object),adapter = registry.lookup1(zope.interface.providedBy(object), >>>>>> provided, '')provided, '') >>>>>> return adapter(object)return adapter(object) >>>>>> from zope.interface.interface import adapter_hooksfrom zope.interface.interface import adapter_hooks >>>>>> adapter_hooks.append(hook)adapter_hooks.append(hook) >>> size = ISize(file)>>> size = ISize(file) >>> size.getSize()>>> size.getSize() 77 Adapters | Request adaptationRequest adaptation
  • 32. Using the Adapter RegistryUsing the Adapter Registry http://docs.zope.org/zope3/Book/ifaceschema/human/show.htmlhttp://docs.zope.org/zope3/Book/ifaceschema/human/show.html Using Grok to walk like a DuckUsing Grok to walk like a Duck Brandon Rhodes - Pycon08, PloneConf 08Brandon Rhodes - Pycon08, PloneConf 08 Adapters | Mas Lectura