资源简介
Django是一个开放源代码的Web应用框架,由Python写成。采用了MVC的软件设计模式,即模型M,视图V和控制器C。Django 框架的核心组件有: 1. 用于创建模型的对象关系映射 2. 为最终用户设计的完美管理界面 3. 一流的 URL 设计 4. 设计者友好的模板语言 5. 缓存系统。 在Django中,控制器接受用户输入的部分由框架自行处理,所以 Django 里更关注的是模型(Model)、模板(Template)和视图(Views),称为 MTV模式。它们
各自的职责如下,Django 视图不处理用户输入,而仅仅决定要展现哪些数据给用户,而Django 模板 仅仅决定如何展现Django视图指定的数据。或者说, Django将MVC中的视图进一步分解为 Django视图 和 Django模板两个部分,分别决定 “展现哪些数据” 和 “如何展现”,使得Django的模板可以根据需要随时替换,而不仅仅限制于内置的模板。 至于MVC控制器部分,由Django框架的URLconf来实现。URLconf机制是使用正则表达式匹配URL,然后调用合适的Python函数。框架把控制层给封装了,无非与数据交互这层都是数据库表的读,写,删除,更新的操作

代码片段和文件信息
#!/usr/bin/env python
# encoding: utf-8
“““
datastore_cache.py
Created by Alkis Evlogimenos on 2009-04-19.
“““
import itertools
import logging
import threading
from google.appengine.api import memcache
from google.appengine.api import apiproxy_stub_map
from google.appengine.datastore import datastore_pb
“““Provides a shim that caches datastore Get calls.
Example code:
import datastore_cache
datastore_cache.DatastoreCachingShim.Install()
# ...
def main(args):
util.run_wsgi_app(application)
datastore_cache.DatastoreCachingShim.ResetCache()
“““
class APIProxyShim(object):
“““A generic shim class with methods to install/uninstall it.
Subclasses of this class can be used to replace the real stub for a service
intercepting and possibly passing on calls to the original stub.
“““
SERVICE_NAME = None # To be overridden by subclasses
_instance = None
def __init__(self wrapped_stub):
“““Constructor. Internal use only - see Install().“““
self._wrapped_stub = wrapped_stub
def CallWrappedStub(self call request response):
“““Allows subclasses to call the wrapped stub.“““
self._wrapped_stub.MakeSyncCall(self.SERVICE_NAME call request response)
def MakeSyncCall(self service call request response):
assert (service == self.SERVICE_NAME
‘Got service name “%s“ expected “%s“‘
% (service self.SERVICE_NAME))
messages = []
assert request.IsInitialized(messages) messages
method = getattr(self ‘_Dynamic_‘ + call None)
if method:
method(request response)
else:
self.CallWrappedStub(call request response)
assert response.IsInitialized(messages) messages
def __getattr__(self name):
“““Pass-through to the wrapped stub.“““
return getattr(self._wrapped_stub name)
@classmethod
def Install(cls):
“““Installs the shim. Only needs to be run once at import time.
Note that this accesses internal members of APIProxyStubMap so may break
in future.
“““
if not cls._instance:
wrapped_stub = apiproxy_stub_map.apiproxy.GetStub(cls.SERVICE_NAME)
assert wrapped_stub “No service ‘%s‘ found to wrap.“ % cls.SERVICE_NAME
cls._instance = cls(wrapped_stub)
stub_dict = apiproxy_stub_map.apiproxy._APIProxyStubMap__stub_map
stub_dict[cls.SERVICE_NAME] = cls._instance
@classmethod
def Uninstall(cls):
“““Uninstalls the shim.
Note that there‘s no need to uninstall a shim after each request. You can
install it once at import time and leave it there between requests.
“““
if cls._instance:
stub_dict = apiproxy_stub_map.apiproxy._APIProxyStubMap__stub_map
stub_dict[cls.SERVICE_NAME] = cls._instance._wrapped_stub
cls._instance = None
class DatastoreCachingShim(APIProxyShim):
SERVICE_NAME = ‘datastore_v3‘
def __init__(self default_stub):
super(DatastoreCachingShim self).__init__(default_stub)
self.local = threading.local()
self.local.to_delete = d
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-08-24 17:27 pLite\
目录 0 2017-08-24 17:27 pLite\.hg\
文件 57 2010-02-03 21:48 pLite\.hg\00changelog.i
文件 9896 2010-02-03 22:36 pLite\.hg\dirstate
文件 23 2010-02-03 21:48 pLite\.hg\requires
目录 0 2017-08-24 17:27 pLite\.hg\store\
文件 1169 2010-02-03 22:36 pLite\.hg\store\00changelog.i
文件 6645 2010-02-03 22:36 pLite\.hg\store\00manifest.i
目录 0 2017-08-24 17:27 pLite\.hg\store\data\
文件 278 2010-02-03 22:36 pLite\.hg\store\data\app.yaml.i
目录 0 2017-08-24 17:27 pLite\.hg\store\data\appengine__django\
文件 7359 2010-02-03 22:36 pLite\.hg\store\data\appengine__django\____init____.py.i
文件 8866 2010-02-03 22:36 pLite\.hg\store\data\appengine__django\____init____.pyc.i
目录 0 2017-08-24 17:27 pLite\.hg\store\data\appengine__django\auth\
文件 580 2010-02-03 22:36 pLite\.hg\store\data\appengine__django\auth\____init____.py.i
文件 664 2010-02-03 22:36 pLite\.hg\store\data\appengine__django\auth\decorators.py.i
文件 682 2010-02-03 22:36 pLite\.hg\store\data\appengine__django\auth\middleware.py.i
文件 1938 2010-02-03 22:36 pLite\.hg\store\data\appengine__django\auth\models.py.i
文件 974 2010-02-03 22:36 pLite\.hg\store\data\appengine__django\auth\templatetags.py.i
文件 718 2010-02-03 22:36 pLite\.hg\store\data\appengine__django\auth\tests.py.i
目录 0 2017-08-24 17:27 pLite\.hg\store\data\appengine__django\conf\
目录 0 2017-08-24 17:27 pLite\.hg\store\data\appengine__django\conf\app__template\
文件 64 2010-02-03 22:36 pLite\.hg\store\data\appengine__django\conf\app__template\____init____.py.i
文件 156 2010-02-03 22:36 pLite\.hg\store\data\appengine__django\conf\app__template\models.py.i
文件 91 2010-02-03 22:36 pLite\.hg\store\data\appengine__django\conf\app__template\views.py.i
目录 0 2017-08-24 17:27 pLite\.hg\store\data\appengine__django\db\
文件 572 2010-02-03 22:36 pLite\.hg\store\data\appengine__django\db\____init____.py.i
文件 209 2010-02-03 22:36 pLite\.hg\store\data\appengine__django\db\____init____.pyc.i
文件 1782 2010-02-03 22:36 pLite\.hg\store\data\appengine__django\db\ba
文件 2353 2010-02-03 22:36 pLite\.hg\store\data\appengine__django\db\ba
文件 734 2010-02-03 22:36 pLite\.hg\store\data\appengine__django\db\creation.py.i
............此处省略421个文件信息
相关资源
- Instant Pygame for Python Game Development How
- Biopython Tutorial
- Think Python 2nd
- 一个小小的表白程序(python)
- Python课堂笔记(高淇400集第一季)
- 二级考试python试题12套(包括选择题和
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
评论
共有 条评论