Continuous Assessment Test 2
Continuous Assessment Test 2
Part- A [2 Marks]
Themes
A theme is a complete design package , controls the overall look and feel of a website.
It includes elements like colors, fonts, layouts, and styles
Examples: Astra, Divi, GeneratePress.
Templates
A template is a single layout used for a specific page or post within a website.
It defines how content is displayed on a particular section of the site.
Examples: Custom templates for landing pages, blog posts, or archives.
Python frameworks are pre-built collections of modules and libraries that provide a
structured foundation for developing applications efficiently. They automate repetitive tasks
and offer built-in functionalities, allowing developers to focus on application logic rather than
low-level details.
Django
TurboGears
1999 – The term "Web 2.0" was first coined by Darcy DiNucci in an article titled
Fragmented Future.
Early 2000s – The concept gained popularity as websites became more interactive,
allowing users to contribute content.
2004 – Tim O'Reilly and Dale Dougherty popularized the term at the first Web 2.0
Conference.
Present – Web 2.0 continues to evolve, paving the way for Web 3.0, which focuses on
decentralization and AI-driven interactions
5. Compare WEB 2.0 & Python Frameworks.
8.
List the Main Turbo Gears Components & Alternate
Components.
1. SQLAlchemy
2. Kajiki
3. ToscaWidgets
4. Repoze.who
Alternate Components :
ORM Alternative
Templating Alternative
UI Widgets Alternative
Authentication Alternative
Enterprise Applications
Data-Driven Applications.
Custom Web Services.
Scientific & Research Platforms
Uses function scope with var Uses block scope with let
Scope Handling and const
Exceptions are errors or unexpected events that occur during program execution, disrupting
the normal flow of an application. They need to be handled properly to prevent crashes and
ensure smooth execution. Exception handling involves using try, catch, and finally blocks
to manage errors effectively.
Logging is the process of recording events, errors, or warnings in a system to help developers
debug and monitor application behavior. It allows tracking issues over time and provides
insights into application performance.
Key Differences:
Exceptions halt execution until handled, while logging records errors without
stopping the program.
Logging helps track issues over time, while exceptions require immediate attention.
Python
import logging
logging.basicConfig(filename="app.log", level=logging.ERROR)
try:
result = a / b
print(f"Result: {result}")
except ZeroDivisionError as e:
divide_numbers(10, 2)
DOM (Document Object Model) represents the structure of an HTML document, allowing
JavaScript to manipulate elements dynamically. It provides methods to access and modify
elements, attributes, and styles.
CSS (Cascading Style Sheets) is used to style HTML elements, controlling layout, colors,
fonts, and animations. It enhances the visual appeal of web pages.
JavaScript can modify CSS properties via the DOM, enabling dynamic styling.
Javascript :
<html>
<head>
<style>
#box {
width: 100px;
height: 100px;
background-color: blue;
</style>
</head>
<body>
<div id="box"></div>
<script>
function changeColor() {
document.getElementById("box").style.backgroundColor = "red";
}
</script>
</body>
</html>
Themes define the overall design of a website, including colors, fonts, and layouts. They
provide global customization options, ensuring consistency across all pages.
Templates are pre-designed page structures used for specific sections, such as landing pages
or blog posts. They define how content is displayed on a particular section of the site.
Key Differences:
Themes apply globally across a website, while templates control individual page
layouts.
Example: A WordPress theme sets the entire site’s appearance, while a template
defines how a blog post looks.
Html :
<html>
<head>
</head>
<body>
<h1>Welcome to My Website</h1>
<section>
</section>
</body>
</html>
12 a) Explicate the Role of AJAX in WEB 2.0.
Introduction:
The concept of Web 2.0 refers to the second generation of the web, where websites became
more interactive, user-driven, and collaborative. AJAX played a pivotal role in enabling
these features, becoming a cornerstone technology behind the success of Web 2.0
applications.
Before AJAX, any interaction requiring server communication (e.g., submitting a form or
loading new content) required a full page reload. This process was slow and disrupted the
user experience. AJAX allows for asynchronous communication with the server, meaning
that data can be fetched or sent in the background without disturbing the current page view.
Example: Google Maps allows users to drag the map and load new tiles instantly,
without refreshing the page.
Result: Users enjoy a smoother, faster, and more seamless experience.
AJAX enables the updating of specific elements of a webpage (such as a table or a div)
without reloading the entire document. This reduces loading times and makes the interface
feel faster and more responsive.
Example: In webmail clients like Gmail or Outlook Web App, reading, sending, or
organizing emails does not require full page reloads.
3. Real-Time Features:
AJAX enables real-time communication between the browser and server, which is critical for
real-time applications.
Examples:
o Live chat systems
o Notifications on social media platforms (e.g., new likes or messages)
o Real-time collaboration tools (e.g., Google Docs, Trello)
Web 2.0 marked the transition from static web pages to rich, interactive applications that
mimic the experience of desktop applications. AJAX allowed developers to build such RIAs
that dynamically interact with data and provide a rich user interface.
AJAX reduces server bandwidth usage because only required data is sent back and forth
between the client and the server. This has multiple benefits:
This became increasingly important as Web 2.0 platforms started scaling globally with
millions of users.
Web 2.0 is characterized by the rise of user-generated content and social networking.
AJAX made these platforms dynamic and interactive by allowing seamless interactions.
Example: Facebook uses AJAX to let users post comments, like content, and receive
updates in real-time.
Similarly, platforms like Twitter load new tweets automatically without reloading the
page.
AJAX is a foundational technology behind Single Page Applications (SPAs), where all
necessary code is loaded once, and content is dynamically updated as the user interacts.
Frameworks like React.js, Angular, and Vue.js rely heavily on AJAX (or newer
variants like Fetch API) to update content dynamically.
SPAs provide faster transitions and feel more like native apps.
AJAX promotes a modular architecture, where different parts of the application can work
independently. This helps in building scalable and maintainable applications.
Developers can update parts of the UI, fetch data, or post updates asynchronously
without affecting other parts of the system.
AJAX is widely used for integrating web frontends with RESTful APIs. These APIs
typically return data in JSON format, which AJAX can easily parse and inject into the DOM.
Example: E-commerce sites use AJAX to filter products, check availability, or update
shopping carts in real-time.
AJAX encouraged the growth of many other technologies and development patterns, such as:
Conclusion:
In conclusion, AJAX was one of the defining technologies of Web 2.0. It enabled the
development of faster, more interactive, and user-friendly web applications. By allowing
asynchronous communication and partial page updates, it transformed the web from static
document delivery to dynamic application platforms. Whether in social media, productivity
tools, or online marketplaces, AJAX has been essential in shaping the modern web
experience.
12 b) Classify about the MVC in Web Application Frameworks.
Introduction:
Many modern web frameworks (like Django, Laravel, ASP.NET MVC, Ruby on Rails,
Angular) use the MVC pattern or a variation of it.
Responsibility: Displays data to the user and sends user interactions to the Controller.
Characteristics:
o Generates the user interface (UI)
o Renders HTML, CSS, or other formats
o Should not contain business logic
Example: A webpage that shows a list of blog posts, or a form to submit a new one.
Separation of Concerns: Keeps logic, data, and presentation separate for better
maintainability.
Reusability: Components can be reused independently.
Testability: Easier to test each component in isolation (e.g., unit testing of Models).
Scalability: Facilitates larger applications by organizing code in a modular fashion.
Collaboration: Designers can work on Views while developers handle Controllers
and Models.
Variations of MVC:
Conclusion:
Web 2.0 is not a specific technology, but a shift in how web applications are
built and experienced. It emphasizes:
1. Django
Example: A social media site built with Django supports user uploads, likes,
comments—all Web 2.0 features.
2. Flask
3. Pyramid
Pyramid is known for its flexibility and scalability, suitable for both simple and
complex applications.
Purpose: Interacts with the database using Python (or other language) objects
instead of raw SQL.
8. Middleware Support
(a) TurboGears
🔑 Key Features:
TurboGears is built upon a set of powerful and modular components. The main
ones include:
1. Model (M)
Responsibilities:
Base = declarative_base()
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
name = Column(String)
email = Column(String)
2. View (V)
Responsibilities:
3. Controller (C)
Purpose: Handles user input and updates Model and View accordingly.
In TurboGears: Controllers are Python classes with methods mapped to
specific routes.
Responsibilities:
Example:
python
CopyEdit
from tg import expose, TGController
class RootController(TGController):
@expose('myapp.templates.index')
def index(self):
user = {'name': 'Alice'}
return dict(user=user)
In this example:
MVC Django
Term Equivalent
Model Model
View Template
Controller View (in Django)
In Django, the View functions act as Controllers and the Template is what the
user actually sees.
Definition: In Django, the "View" refers to the Python function or class that
receives a request and returns a response. This is technically the Controller in
MVC terminology.
Responsibilities:
def article_list(request):
articles = Article.objects.all()
return render(request, 'blog/article_list.html', {'articles': articles})
Example (Class-Based View):
python
CopyEdit
from django.views.generic import ListView
from .models import Article
class ArticleListView(ListView):
model = Article
template_name = 'blog/article_list.html'
Definition: In Django, the Template is the HTML file that displays the data.
This is what MVC calls the View.
Responsibilities:
Example:
html
CopyEdit
<h1>Articles</h1>
<ul>
{% for article in articles %}
<li>{{ article.title }}</li>
{% endfor %}
</ul>
2. Django Components
Component Role
Model Data representation (uses ORM)
View (Python Function) Processes request and returns response
Template HTML structure to render dynamic content
URL Dispatcher Maps URLs to views using urls.py
Forms Form rendering and validation
Authentication System Manages users, groups, permissions
Auto-generated backend for managing
Admin Interface
models
Middleware Hooks into request/response processing
Sessions and Messages Tracks users and system notifications
REST Framework API development (Django REST
(optional) Framework)
In Django:
1. Model (M)
● Located in models.py
● Defines the database schema using Python classes.
● Uses Django's built-in ORM to interact with the database.
Example:
python
CopyEdit
from django.db import models
class Student(models.Model):
name = models.CharField(max_length=100)
roll_no = models.IntegerField()
● Located in views.py
● Contains logic to handle HTTP requests.
● Retrieves data from models and sends it to templates.
python
CopyEdit
from django.shortcuts import render
from .models import Student
def show_students(request):
students = Student.objects.all()
return render(request, 'students_list.html', {'students': students})
python
CopyEdit
from django.views.generic import ListView
from .models import Student
class StudentListView(ListView):
model = Student
template_name = 'students_list.html'
Example:
html
CopyEdit
<h1>Students</h1>
<ul>
{% for student in students %}
<li>{{ student.name }} - {{ student.roll_no }}</li>
{% endfor %}
</ul>
6. Middleware Support
9. Security Features
TurboGears Core provides foundational tools and architecture required for web
app development. Here's how it supports the Course Management System:
B. SQLAlchemy ORM
● Built-in integration with repoze.who and repoze.what for login, roles, and
permissions.
● Admins, students, and professors can be assigned specific roles with
different access levels.
F. Templating Engine
● Supports templating with Genshi, Jinja2, Mako for rendering dynamic UI.