The document discusses function-based views (FBVs) and class-based views (CBVs) in Django. It recommends using CBVs for new projects and FBVs for existing projects that only need to subclass some views. The document also provides best practices for FBVs, such as keeping business logic out of views and using decorators. It emphasizes loose coupling between URLs and views for better maintainability.
Learn about Eclipse e4 from Lars Vogel at SF-JUGMarakana Inc.
San Francisco Java User Group hosted an event on April 13th, 2010 with Lars Vogel, a committer on the Eclipse e4 project, who gave a talk on the next generation of the Eclipse Platform. We had two speakers that evening, this is the first of the two presentations. This event was hosted by SUPINFO. Sponsored by TEKsystems, Guidewire Software, Sun, O'Reilly, JetBrains, and Marakana. Organized by Marakana. Video by Max Walker. Photography by Aleksandar Gargenta. http://www.sfjava.org/calendar/12296574/
The Odoo Framework is quite expressive, many add-ons can express a lot of business logic just by defining models (in Python) and template/views (in XML). This is fine for most cases, but there is a limit to what you can do. To overcome this limit, you need to extend the Odoo web client in Javascript. Version 12 will feature a new large refactoring of the web client, and this training is a good opportunity to learn where Odoo is going.
Learn about Eclipse e4 from Lars Vogel at SF-JUGMarakana Inc.
San Francisco Java User Group hosted an event on April 13th, 2010 with Lars Vogel, a committer on the Eclipse e4 project, who gave a talk on the next generation of the Eclipse Platform. We had two speakers that evening, this is the first of the two presentations. This event was hosted by SUPINFO. Sponsored by TEKsystems, Guidewire Software, Sun, O'Reilly, JetBrains, and Marakana. Organized by Marakana. Video by Max Walker. Photography by Aleksandar Gargenta. http://www.sfjava.org/calendar/12296574/
The Odoo Framework is quite expressive, many add-ons can express a lot of business logic just by defining models (in Python) and template/views (in XML). This is fine for most cases, but there is a limit to what you can do. To overcome this limit, you need to extend the Odoo web client in Javascript. Version 12 will feature a new large refactoring of the web client, and this training is a good opportunity to learn where Odoo is going.
A Web Framework that shortens the Time it takes to develop software in at least an Order of Magnitude. while also tremendously minimizing Effort Pain, Time waste, Complexity, Cost of change & more
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd Sencha
Learn how to use Ext JS and Cmd to deliver Progressive Web Applications to deliver the best of both web and mobile app experiences. Web apps can be found easily on the internet and every user is guaranteed access to the same and latest version of the application. Plus, mobile app capabilities, such as offline support and optimizing access to the underlying network using service workers, take the user experience to a whole new level.
Efficient Rails Test-Driven Development - Week 6Marakana Inc.
Learn how to apply the test-first approach to all of your Rails projects. In this six class series, experienced Rails engineer and consultant, Wolfram Arnold applies his real-world perspective to teaching you effective patterns for testing.
In this sixth of six classes, Wolf discusses:
- Integration frameworks (Cucumber, Webrat, Capybara, and Selenium)
- Integration testing with Selenium (advantages and problems)
- Page Objects
- Locators (Selenium, CSS and XPath locators
- RSpec Custom Matchers
- Testing for Access Control
** You can get the slides and source code from this presentation at: http://marakana.com/f/215 **
Find more videos, tutorials, and code examples at http://marakana.com/techtv
Sencha Roadshow 2017: Modernizing the Ext JS Class System and ToolingSencha
JavaScript is advancing and ES2015 (formerly ES6) is the foundation of its future. Sencha is committed to delivering cutting-edge technology for your applications, and supporting the evolution of JavaScript is a central part of that commitment. The expansive feature set of ES2015 formally enables coding paradigms: modules to better organize your code, classes to cleanly declare reusable units of functionality, and so much more. In this session, you'll see how Ext JS is embracing these new language and toolset features, and how they will expand your development horizons.
Staying Sane with Drupal (A Develper's Survival Guide)Oscar Merida
Drupal is a powerful content management framework and among the most succesful PHP projects out there. Working with Drupal's modules and theme layer means that for any problem there's more than one way to that that. Picking a good solution, or dealing with the choices of previous developers will make you pull your hair out. I'll look at what you can do to make working with Drupal, shall we say, enjoyable? We'll look at how to evaluate contributed modules, what modules should be in all your installations, examine coding conventions in Drupal, and talk about development best practices for Drupal sites.
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012crokitta
APEX& jQuery Mobile
Binnenkort zal Oracle versie de lang aangekondigde upgrade naar release 4.2 van Oracle Application Express beschikbaar maken. Een van de meest besproken nieuwe features die voor dit nieuwe release zijn aangekondigd is de integratie van het jQuery Mobile framework. Met de integratie van dit framework zal het mogelijk worden om met APEX applicaties te ontwikkelen, die geschikt zijn voor mobiele toestellen.
Wat is en hoe werkt jQuery Mobile en wat betekend dit voor het ontwikkelen in APEX. Dat zijn de onderwerpen die de presentatie aan bod komen. En waarom wachten tot het release van 4.2. Het is namelijk nu al mogelijk om jQuery Mobile in APEX te integreren en gebruiken. Hoe, wordt in een demo getoond. Deze sessie is waarschijnlijk de enige waarin u gevraagd zal worden om uw mobile telefoon aan te laten staan.
A Web Framework that shortens the Time it takes to develop software in at least an Order of Magnitude. while also tremendously minimizing Effort Pain, Time waste, Complexity, Cost of change & more
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd Sencha
Learn how to use Ext JS and Cmd to deliver Progressive Web Applications to deliver the best of both web and mobile app experiences. Web apps can be found easily on the internet and every user is guaranteed access to the same and latest version of the application. Plus, mobile app capabilities, such as offline support and optimizing access to the underlying network using service workers, take the user experience to a whole new level.
Efficient Rails Test-Driven Development - Week 6Marakana Inc.
Learn how to apply the test-first approach to all of your Rails projects. In this six class series, experienced Rails engineer and consultant, Wolfram Arnold applies his real-world perspective to teaching you effective patterns for testing.
In this sixth of six classes, Wolf discusses:
- Integration frameworks (Cucumber, Webrat, Capybara, and Selenium)
- Integration testing with Selenium (advantages and problems)
- Page Objects
- Locators (Selenium, CSS and XPath locators
- RSpec Custom Matchers
- Testing for Access Control
** You can get the slides and source code from this presentation at: http://marakana.com/f/215 **
Find more videos, tutorials, and code examples at http://marakana.com/techtv
Sencha Roadshow 2017: Modernizing the Ext JS Class System and ToolingSencha
JavaScript is advancing and ES2015 (formerly ES6) is the foundation of its future. Sencha is committed to delivering cutting-edge technology for your applications, and supporting the evolution of JavaScript is a central part of that commitment. The expansive feature set of ES2015 formally enables coding paradigms: modules to better organize your code, classes to cleanly declare reusable units of functionality, and so much more. In this session, you'll see how Ext JS is embracing these new language and toolset features, and how they will expand your development horizons.
Staying Sane with Drupal (A Develper's Survival Guide)Oscar Merida
Drupal is a powerful content management framework and among the most succesful PHP projects out there. Working with Drupal's modules and theme layer means that for any problem there's more than one way to that that. Picking a good solution, or dealing with the choices of previous developers will make you pull your hair out. I'll look at what you can do to make working with Drupal, shall we say, enjoyable? We'll look at how to evaluate contributed modules, what modules should be in all your installations, examine coding conventions in Drupal, and talk about development best practices for Drupal sites.
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012crokitta
APEX& jQuery Mobile
Binnenkort zal Oracle versie de lang aangekondigde upgrade naar release 4.2 van Oracle Application Express beschikbaar maken. Een van de meest besproken nieuwe features die voor dit nieuwe release zijn aangekondigd is de integratie van het jQuery Mobile framework. Met de integratie van dit framework zal het mogelijk worden om met APEX applicaties te ontwikkelen, die geschikt zijn voor mobiele toestellen.
Wat is en hoe werkt jQuery Mobile en wat betekend dit voor het ontwikkelen in APEX. Dat zijn de onderwerpen die de presentatie aan bod komen. En waarom wachten tot het release van 4.2. Het is namelijk nu al mogelijk om jQuery Mobile in APEX te integreren en gebruiken. Hoe, wordt in een demo getoond. Deze sessie is waarschijnlijk de enige waarin u gevraagd zal worden om uw mobile telefoon aan te laten staan.
A Minimalist’s Attempt at Building a Distributed ApplicationDavid Hoerster
For a typical .NET developer, building a distributed application of web pages and services involves using IIS. But do you really need a full blown web server like IIS? Building a functional distributed application outside IIS is possible and quite easy. Inspired by lightweight frameworks like Java's Jetty and Python's Bottle, we'll look at creating lightweight sites and services in .NET using Nancy. We'll see how using lightweight frameworks allow you to focus on your business logic without letting heavyweight frameworks and processes get in the way.
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...murtazahaveliwala
Follow up on second day's training with third day, covering Custom Directives, $http, $resource, Setup with Yeoman, Unit Testing & Best practices
Code samples shared at https://github.com/murtazahaveliwala/technext-angularjs-demo/tree/master/demos/static/angular-apps
Rapid web application development using django - Part (1)Nishant Soni
This slide contains deatils about Django Framework which is based in Python. Beginners to this technology can first learn about the technology and its uses and than start building their project. Popular website like Pinterest, Instagram, Nasa are examples of web application built in Django Framework. This is part 1 .
Similar to Two scoops of django 1.6 - Ch7, Ch8 (20)
1. Two Scoops of Django
Ch 7. Function-and Class-Based Views
Ch 8. Best Practices for Function-Based Views
2014/11/04
Michelle Leu @flywindy
2. Agenda
Django Views
FBVs v.s. CBVs
Best practices for FBVs
URL Namespaces
Loose Coupling
Summary
3. Django Views
Django Views are functions
y = f(x) # math
HttpResponse = view(HttpRequest) # FBV
HttpResponse = View.as_view(HttpRequest) # CBV
4. Django Views
keep business logic out of Views
model methods
manger methods
general utility helper function
forms
Business logic is the
part of the program
that encodes the real-world
business rules
that determine how
data can be created,
displayed, stored, and
changed…….
(From wikipedia)
6. CBVs (Class Based Views)
Django 1.7 Tutorial Part 4
# polls/views.py
…
from django.views import generic
from polls.models import Question
class IndexView(generic.ListView):
class DetailView(generic.DetailView):
model = Question
template_name = 'polls/detail.html'
class ResultsView(generic.DetailView):
model = Question
template_name = 'polls/results.html'
template_name = 'polls/index.html'
context_object_name = 'latest_question_list'
def get_queryset(self):
"""Return the last five published questions."""
return Question.objects.order_by('-pub_date')[:5]
8. CBVs v.s. FBVs
For new comer: FBVs
For new project: CBVs
For past project: FBVs for most views, CBVs
only for views that need to be subclassed.
Write custom 403, 404, and 500 error handlers:
FBVs # root URLconf
handler500 = 'mysite.views.my_custom_error_view'
9. Best practices for FBVs
Pass HttpRequest Object
Pass HttpResponse Object
Decorators
11. Decorators
# EXAMPLE 8.6
# sprinkles/decorators.py
from functools import wraps
from . import utils
def check_sprinkles(view_func):
@wraps(view_func)
def new_view_func(request, *args,
**kwargs):
# modify HttpRequest object here
request =
utils.can_sprinkle(request)
# request.can_sprinkle
response = view_func(request,
*args, **kwargs)
# modify HttpResponse object
here
return response
return new_view_func
# EXAMPLE 8.7
# sprinkles/views.py
...
from .decorators import /
check_sprinkles
@check_sprinkles
def sprinkle_detail(request, pk):
sprinkle =
get_object_or_404(Sprinkle, pk=pk)
return render(request,
"sprinkles/sprinkle_detail.html",
{"sprinkle": sprinkle})
12. URL Namespaces
allow you to uniquely reverse named URL patterns even if different
applications use the same URL names.
are specified using the ':' operator. For example, the main index page of the
admin application is referenced using 'admin:index'. This indicates a
namespace of 'admin', and a named URL of ‘index'.
can also be nested.
# EXAMPLE 7.3
# urls.py at root of project
from django.conf.urls import include, url
urlpatterns += patterns('',
url(r'^tastings/', include('tastings.urls', namespace='tastings')),
)
7.4
tastings/views.py snippet
……
class TasteUpdateView(UpdateView):
model = Tasting
def get_success_url(self):
return reverse("tastings:detail", kwargs={"pk": self.object.pk})
14. Why URL Namespaces?
Makes for shorter, more obvious and DRY URL
names
Increases interoperability with Third-party
libraries
Easier searches, upgrades, and refactors
Allow for more app and template reverse tricks
15. Loose Coupling
鬆散耦合
相對於 緊密耦合(tight coupling)
In computing and systems
design a loosely coupled
system is one in which each of
its components has, or makes
use of, little or no knowledge of
the definitions of other separate
components ….…
(From wikipedia)
16. Loose Coupling
# BAD EXAMPLE 7.1
from django.conf.urls import patterns,
url
from django.views.generic import /
DetailView
from tastings.models import Tasting
urlpatterns = patterns('',
url(r'^(?P<pk>d+)/$',
DetailView.as_view(
model=Tasting,
template_name='tastings/
detail.htm'),
name='detail'),
url(r'^(?P<pk>d+)/results/$',
DetailView.as_view(
model=Tasting,
template_name='tastings/
results.html'),
name='results'),
)
authentication︖?
17. Loose Coupling
閃開,讓專業的來!
# EXAMPLE 7.1
# tastings/views.py
from django.views.generic import /
DetailView
from tastings.models import Tasting
class TasteDetailView(DetailView):
model = Tasting
class
TasteResultsView(TasteDetailView):
template_name = 'tastings/
results.html'
# EXAMPLE 7.1
# tastings/urls.py
from django.conf.urls import patterns,
url
from . import views
urlpatterns = patterns('',
url(r'^(?P<pk>d+)/$',
views.TasteDetailView.as_view(),
name='detail'),
url(r'^(?P<pk>d+)/results/$',
views.TasteResultsView.as_view(),
name='results'),
)
<app_label>/<model_name><template_name_suffix>.html -> tastings/tasting_detail.html
18. Summary
Don’t Repeat Yourself. (DRY)
Do one thing and do it well.
Views should handle presentation logic.
Less code is better, and keep it simple.
Complex nested-if blocks are to be avoided.