django.contrib.markup で使えるmarkup
hdknr@deblen:~/.ve/djtweet/src/djcube/www/website$ grep def ../../../../lib/python2.5/site-packages/django/contrib/markup/templatetags/marku
def textile(value):
def markdown(value, arg=”):
def restructuredtext(value): 使えるマークアップ確認
»> import markdown
Traceback (most recent call last):
File “<input>”, line 1, in <module>
ImportError: No module named markdown
»> import textile
Traceback (most recent call last):
File “<input>”, line 1, in <module>
ImportError: No module named textile
»> from docutils.core import publish_parts
»>
»> このvirtualenvではReSTのみ。
settings.pyに設定
INSTALLED_APPS = (
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.sites’,
‘django.contrib.admin’, #HDKNR
‘django.contrib.markup’, #HDKNR 試しにファイルを用意する
Sequence
======== 1. (Guest) Submit form on a landing page.
————————————————————- Browser post(get) form to following URL ::
http://{{cname}}/{{app}}/promocode/{{promotion_name}}/?code={{promotion_code}} 2. (Promo) Process the request
———————————————-
2.1. Search djcube.models.Promotion with {{promotion_name}} => `pr`.
2.2. Search djcube.models.PromotionCode with `pr` and {{promotion_code}}.
2.3. Insert a djcube.models.PromotionEntry. 2.3.1. md5 for UserAgent should be set to `ua`
2.3.2. Insert djcube.models.UserAgent with `ua` if not exists.
2.4. Update jcube.models.PromotionCode with incremented `current`.
2.4. Set-Cookie ‘p’ : djcube.models.Promotion.digest
‘e’ : djcube.models.PromotionEntry.digest
2.5. Execute {{ djcube.models.Promotion.ptype }}.py main() 2.5.1. finally return 302 and proper URL
testビューを用意
views.pyと同じディレクトリにreadme.rst を用意 from django.conf.urls.defaults import *
from django import template
from django.http import HttpResponse
import os def test(request):
page = “”” {% load markup %}
<html>
<body>
{{ readme|
restructuredtext}}
</body>
</html>
“”“
ctx = {
‘readme’: open(os.path.join( os.path.dirname(os.path.abspath(__file__)),’readme.rst’)).read(),
}
return HttpResponse( template.Template( page ).render( template.Context(ctx)))
表示
Posted via email from hdknr’s posterous | Comment »