This document introduces Repoze.BFG, a Python web framework that aims to provide a simple yet powerful way to build web applications. It allows developers to use popular Zope technologies like security, templating, and components without needing the full Zope framework. BFG stands for "Big Friendly Giant" and provides common features like routing, security, and templating while avoiding complexity and only including what is necessary. It uses the Chameleon templating engine and allows the use of Zope interfaces, components and other utilities via lightweight integration.
Generative Artificial Intelligence: How generative AI works.pdf
Everything Should Be Simple But Not Simpler - An Introduction to Repoze.BFG
1. REPOZE.BFG
Rok Garbas, python/zope/plone consultingOct. 2009
“Everything should be made as simple as possible, but not
simpler.” ~ Einstein
BFG is a "pay only for what you eat" Python web framework. You can get started
easily and learn new concepts as you go, and only if you need them. It's simple, well
tested, well documented, and fast.
http://bfg.repoze.org
2. WHAT MATTERS
I’M A PLONISTA, I LOVE PLONE, I LOVE PLONE
COMMUNITY, BUT…
ON THE END IT DOESN’T REALLY MATTER
WHAT YOU ARE USING
WHAT MATTER IS HOW PASIONATE YOU ARE
ABOUT IT
3. THANK YOU …
Chris McDonough
Tres Seaver
Paul Everitt,
Carlos de la Guardia
Malthe Borch
Stefan Eletzhofer
Fernando Neto-Correa
4. WHY NAME IT BFG
repoze.bfg should have just been named "BFG".
BFG's goals are somewhat sideways of the original
Repoze goals.
The BFG 9000 is a fictional futuristic weapon found
in Doom. It is the most
powerful weapon in the
game, and is capable of
destroying nearly any
player or enemy with a
single hit.
5. ABOUT
July 2008 – Initial release
July 2009 – 1.0 released, API promissed to be
backwards compatible
10th of October 2009 – Latest release … 1.1a5
Allow Zope developers to use WSGI technologies
more easily and even out of Zope framework.
Allow non-Zope developers to use Zope
technologies without using all of Zope.
7. WHAT IT DOES
Graph traversal / URL Dispatch: maps
URLs to code
Security: provides mechanisms that allow
developers to make declarative security
assertions
Templating: provides text and HTML
templating facilities
Zope libs: use wonderful zope stuff
8. WHAT IT DOESN’T DO
Database / persistence
Sessions
Indexing / searching
ZMI / TTW code
View code sharing with Z3 / Five
...
9. HOW YOUR BFG APP WORKS
You are not running framework and your application
inside it, like zope, instead you are running your
application alone.
INTERNET
WSGI + MIDDLEWARE
BFG ROUTER
YOUR APPLICATION
MODELS VIEWS TEMPLATES
10. ZOPE COMPONENT ARHITECTURE
The Zope Component Architecture is a system for
runtime indirection ("pluggability"). Used only to
construct BFG.
BFG application developers don't need to
understand the Zope CA. It's a framework
implementation detail.
12. MODELS
“content” objects. for Zope people, think of it as things we
store in ZODB
ZODB not required for repoze.bfg applications: filesystem
directories, XML documents, RDF graphs, SQL databases, etc.
can be the source of model data
from zope.interface import implements
from zope.interface import Interface
class IMyModel(Interface):
pass
class MyModel(object):
implements(IMyModel)
def __init__(self, name):
self.name = name
13. VIEWS
Views are functions which accept a "context" (a
model object) and a "request".
Views must return a response. Unlike Zope.
The view may use a template to generate the
response body, or not.
from repoze.bfg.chameleon_zpt
import render_template_to_response
def hello_world(context, request):
render_template_to_response(
'templates/hello.pt',
context=context, myname='chris')
15. VIEW REGISTRATION via DECORATORS
from webob import Response
from repoze.bfg.convention import bfg_view
from repoze.bfg.chameleon_zpt
import render_template_to_response
@bfg_view(name='hello.html')
def hello_world(context, request):
render_template_to_response(
'templates/hello.pt',
context=context, myname='chris')
16. TEMPLATE
Default templating engine: chalmeleon by Malthe
Borch. ZPT or Genshi syntax. ~10X - 15X faster
than zope.pagetemplate.
Included: XSLT.
Add-on: jinja2 (Django-style, via repoze.bfg.jinja2)
Any other you'd like to use; bindings are simple to
create (see the jinja2 bindings).
19. FUTURE
Vudo CMS (http://docs.vudo.me) to be
implemented using repoze.bfg, hopefully. Work
towards this: repoze.bfg.skins, repoze.bfg.layout,
repoze.bitblt, repoze.squeeze.
BFG will stay minimal. Add-ons and
superframeworks like vudo and repoze.lemonade
will provide functionality.