Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!
-
最近の投稿
アーカイブ
カテゴリー
メタ情報
Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!
圧縮したりとかが多くそのままでは読みづらいので整形したほうがよいですね。
http://github.com/einars/js-beautify をつかってみます。
(myrpx)hdknr@deblen2010:~$ apt-cache search rhino
libbsf-java – Bean Scripting Framework to support scripting languages in Java
rhino-doc – Documentation for rhino Java Script Engine
grhino – オセロ/リバーシ
rhino – Java で書かれた JavaScript エンジン
rhinote – デスクトップ向けの仮想的な付箋紙
(myrpx)hdknr@deblen2010:~$ sudo aptitude install rhino
パッケージリストを読み込んでいます… 完了
依存関係ツリーを作成しています
状態情報を読み取っています… 完了
拡張状態情報を読み込んでいます
パッケージの状態を初期化しています… 完了
タスクの記述を読み込んでいます… 完了
以下の新規パッケージがインストールされます:
rhino
更新: 0 個、新規インストール: 1 個、削除: 0 個、保留: 0 個。
635kB のアーカイブを取得する必要があります。展開後に 750kB のディスク領域が新たに消費されます。
拡張状態情報を書き込んでいます… 完了
取得:1 http://ftp.jp.debian.org lenny/main rhino 1.7R1-2 [635kB]
635kB を 14s 秒でダウンロードしました (44.1kB/s)
未選択パッケージ rhino を選択しています。
(データベースを読み込んでいます … 現在 47495 個のファイルとディレクトリがインストールされています。)
(…/archives/rhino_1.7R1-2_all.deb から) rhino を展開しています…
man-db のトリガを処理しています …
rhino (1.7R1-2) を設定しています …
パッケージリストを読み込んでいます… 完了
依存関係ツリーを作成しています
状態情報を読み取っています… 完了
拡張状態情報を読み込んでいます
パッケージの状態を初期化しています… 完了
拡張状態情報を書き込んでいます… 完了
タスクの記述を読み込んでいます… 完了
(myrpx)hdknr@deblen2010:~$ git clone git://github.com/einars/js-beautify.git
Initialized empty Git repository in /home/hdknr/js-beautify/.git/
remote: Counting objects: 616, done.
remote: Compressing objects: 100% (305/305), done.
remote: Total 616 (delta 359), reused 532 (delta 306)
Receiving objects: 100% (616/616), 169.29 KiB | 15 KiB/s, done.
Resolving deltas: 100% (359/359), done.
(myrpx)hdknr@deblen2010:~$ rhino js-beautify/beautify-cl.js rpx.js
js: Couldn’t open file "beautify.js".
js: Couldn’t open file "beautify-html.js".
js: uncaught JavaScript runtime exception: ReferenceError: "js_beautify" is not defined.
(myrpx)hdknr@deblen2010:~$ cd js-beautify/
(myrpx)hdknr@deblen2010:~/js-beautify$ rhino beautify-cl.js ../rpx.js > ../rpx-b.js
DjangoはINSTALLED_APPSのモデルのERを解析するので、Foreign Keyで参照しているモデルのエンティティを逆(“reverse”)参照してくれます。
(myrpx)hdknr@deblen2010:~/.ve/myrpx/src/test$ ~/bin/MySQL/createdb.sh hoge
Distribution is Debian.
Apache is apache2.
SERVER=localhost DATABASE=hoge DBUSER=hoge DBPWD=hoge
hoge
(myrpx)hdknr@deblen2010:~/.ve/myrpx/src/test$ django-admin.py startproject hogesite
(myrpx)hdknr@deblen2010:~/.ve/myrpx/src/test$ cd hogesite/
(myrpx)hdknr@deblen2010:~/.ve/myrpx/src/test/hogesite$ python manage.py startapp hoge
(myrpx)hdknr@deblen2010:~/.ve/myrpx/src/test/hogesite$ grep hoge settings.py
# Django settings for hogesite project.
DATABASE_NAME = ‘hoge’ # Or path to database file if using sqlite3.
DATABASE_USER = ‘hoge’ # Not used with sqlite3.
DATABASE_PASSWORD = ‘hoge’ # Not used with sqlite3.
ROOT_URLCONF = ‘hogesite.urls’
(myrpx)hdknr@deblen2010:~/.ve/myrpx/src/test/hogesite$ python manage.py syncdb
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
You just installed Django’s auth system, which means you don’t have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (Leave blank to use ‘hdknr’):
E-mail address: hdknr@hdknr.deb
Password:
Password (again):
Error: Your passwords didn’t match.
Password:
Password (again):
Superuser created successfully.
Installing index for auth.Permission model
Installing index for auth.Message model
(myrpx)hdknr@deblen2010:~/.ve/myrpx/src/test/hogesite$ python manage.py shell
imported django settings
Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.contrib.auth.models import User
>>> u=User.objects.get(id=1)
>>> dir(u)
['DoesNotExist', 'MultipleObjectsReturned', '__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__getattribute__', '__hash__', '__init__', '__metaclass__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__unicode__', '__weakref__', '_base_manager', '_collect_sub_objects', '_default_manager', '_deferred', '_get_FIELD_display', '_get_next_or_previous_by_FIELD', '_get_next_or_previous_in_order', '_get_pk_val', '_meta', '_set_pk_val', 'check_password', 'date_joined', 'delete', 'email', 'email_user', 'first_name', 'get_absolute_url', 'get_all_permissions', 'get_and_delete_messages', 'get_full_name', 'get_group_permissions', 'get_next_by_date_joined', 'get_next_by_last_login', 'get_previous_by_date_joined', 'get_previous_by_last_login', 'get_profile', 'groups', 'has_module_perms', 'has_perm', 'has_perms', 'has_usable_password', 'id', 'is_active', 'is_anonymous', 'is_authenticated', 'is_staff', 'is_superuser', 'last_login', 'last_name', 'message_set', 'objects', 'password', 'pk', 'prepare_database_save', 'save', 'save_base', 'serializable_value', 'set_password', 'set_unusable_password', 'user_permissions', 'username']
>>>
(myrpx)hdknr@deblen2010:~/.ve/myrpx/src/test/hogesite$ vi hoge/models.py
from django.db import models
from django.contrib.auth import models as auth_models
class Blog(models.Model):
author = models.ForeignKey(auth_models.User)
title = models.CharField(max_length=100)
text = models.TextField()
(myrpx)hdknr@deblen2010:~/.ve/myrpx/src/test/hogesite$ vi settings.py
INSTALLED_APPS = (
‘hoge’,
)
(myrpx)hdknr@deblen2010:~/.ve/myrpx/src/test/hogesite$ python manage.py syncdb
Creating table hoge_blog
Installing index for hoge.Blog model
(myrpx)hdknr@deblen2010:~/.ve/myrpx/src/test/hogesite$ python manage.py shell
imported django settings
Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.contrib.auth.models import User
>>> u=User.objects.get(id=1)
>>> dir(u)
['DoesNotExist', 'MultipleObjectsReturned', '__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__getattribute__', '__hash__', '__init__', '__metaclass__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__unicode__', '__weakref__', '_base_manager', '_collect_sub_objects', '_default_manager', '_deferred', '_get_FIELD_display', '_get_next_or_previous_by_FIELD', '_get_next_or_previous_in_order', '_get_pk_val', '_meta', '_set_pk_val', 'blog_set', 'check_password', 'date_joined', 'delete', 'email', 'email_user', 'first_name', 'get_absolute_url', 'get_all_permissions', 'get_and_delete_messages', 'get_full_name', 'get_group_permissions', 'get_next_by_date_joined', 'get_next_by_last_login', 'get_previous_by_date_joined', 'get_previous_by_last_login', 'get_profile', 'groups', 'has_module_perms', 'has_perm', 'has_perms', 'has_usable_password', 'id', 'is_active', 'is_anonymous', 'is_authenticated', 'is_staff', 'is_superuser', 'last_login', 'last_name', 'message_set', 'objects', 'password', 'pk', 'prepare_database_save', 'save', 'save_base', 'serializable_value', 'set_password', 'set_unusable_password', 'user_permissions', 'username']
(myrpx)hdknr@deblen2010:~/.ve/myrpx/src/test/hogesite$ vi hoge/models.py
class Profile(models.Model):
user = models.OneToOneField(auth_models.User)
mobile_email = models.CharField(max_length=100)
twitter = models.CharField(max_length=100)
(myrpx)hdknr@deblen2010:~/.ve/myrpx/src/test/hogesite$ python manage.py syncdb
Creating table hoge_profile
(myrpx)hdknr@deblen2010:~/.ve/myrpx/src/test/hogesite$ python manage.py shell
imported django settings
Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.contrib.auth.models import User
>>> u=User.objects.get(id=1)
>>> dir(u)
['DoesNotExist', 'MultipleObjectsReturned', '__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__getattribute__', '__hash__', '__init__', '__metaclass__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__unicode__', '__weakref__', '_base_manager', '_collect_sub_objects', '_default_manager', '_deferred', '_get_FIELD_display', '_get_next_or_previous_by_FIELD', '_get_next_or_previous_in_order', '_get_pk_val', '_meta', '_set_pk_val', 'blog_set', 'check_password', 'date_joined', 'delete', 'email', 'email_user', 'first_name', 'get_absolute_url', 'get_all_permissions', 'get_and_delete_messages', 'get_full_name', 'get_group_permissions', 'get_next_by_date_joined', 'get_next_by_last_login', 'get_previous_by_date_joined', 'get_previous_by_last_login', 'get_profile', 'groups', 'has_module_perms', 'has_perm', 'has_perms', 'has_usable_password', 'id', 'is_active', 'is_anonymous', 'is_authenticated', 'is_staff', 'is_superuser', 'last_login', 'last_name', 'message_set', 'objects', 'password', 'pk', 'prepare_database_save', 'profile', 'save', 'save_base', 'serializable_value', 'set_password', 'set_unusable_password', 'user_permissions', 'username']
(rpx)hdknr@deblen2010:~/.ve/rpx/src/myrpx$ yolk -S name=pastedeploy
PasteDeploy (1.3.3):
Load, configure, and compose WSGI applications and servers
(rpx)hdknr@deblen2010:~/.ve/rpx/src/myrpx$ pip install PasteDeploy
Downloading/unpacking PasteDeploy
Downloading PasteDeploy-1.3.3.tar.gz
Running setup.py egg_info for package PasteDeploy
warning: no files found matching ‘docs/*.html’
warning: no previously-included files found matching ‘docs/rebuild’
Installing collected packages: PasteDeploy
Running setup.py install for PasteDeploy
warning: no files found matching ‘docs/*.html’
warning: no previously-included files found matching ‘docs/rebuild’
Skipping installation of /home/hdknr/.ve/rpx/lib/python2.5/site-packages/paste/__init__.py (namespace package)
Installing /home/hdknr/.ve/rpx/lib/python2.5/site-packages/PasteDeploy-1.3.3-py2.5-nspkg.pth
Successfully installed PasteDeploy
(rpx)hdknr@deblen2010:~/.ve/rpx/src/myrpx$ pip install twod.wsgi
Downloading/unpacking twod.wsgi
Downloading twod.wsgi-1.0a3.tar.gz
Running setup.py egg_info for package twod.wsgi
warning: no previously-included files matching ‘*’ found under directory ‘tests/’
warning: no previously-included files matching ‘*’ found under directory ‘docs/’
Requirement already satisfied (use –upgrade to upgrade): Django>=1.1 in /home/hdknr/.ve/rpx/lib/python2.5/site-packages (from twod.wsgi)
Downloading/unpacking WebOb>=0.9.7 (from twod.wsgi)
Downloading WebOb-0.9.8.tar.gz (204Kb): 204Kb downloaded
Running setup.py egg_info for package WebOb
warning: no previously-included files matching ‘*’ found under directory ‘docs/_build/_sources’
Requirement already satisfied (use –upgrade to upgrade): PasteDeploy>=1.3.3 in /home/hdknr/.ve/rpx/lib/python2.5/site-packages (from twod.wsgi)
Requirement already satisfied (use –upgrade to upgrade): setuptools in /home/hdknr/.ve/rpx/lib/python2.5/site-packages/setuptools-0.6c11-py2.5.egg (from twod.wsgi)
Downloading/unpacking nose (from twod.wsgi)
Downloading nose-0.11.3.tar.gz (256Kb): 256Kb downloaded
Running setup.py egg_info for package nose
no previously-included directories found matching ‘doc/.build’
Installing collected packages: nose, twod.wsgi, WebOb
Running setup.py install for nose
no previously-included directories found matching ‘doc/.build’
Installing nosetests script to /home/hdknr/.ve/rpx/bin
Installing nosetests-2.5 script to /home/hdknr/.ve/rpx/bin
Running setup.py install for twod.wsgi
Skipping installation of /home/hdknr/.ve/rpx/lib/python2.5/site-packages/twod/__init__.py (namespace package)
warning: no previously-included files matching ‘*’ found under directory ‘tests/’
warning: no previously-included files matching ‘*’ found under directory ‘docs/’
Installing /home/hdknr/.ve/rpx/lib/python2.5/site-packages/twod.wsgi-1.0a3-py2.5-nspkg.pth
Running setup.py install for WebOb
warning: no previously-included files matching ‘*’ found under directory ‘docs/_build/_sources’
Successfully installed nose twod.wsgi WebOb
(rpx)hdknr@deblen2010:~/.ve/rpx/src/myrpx$ pip install -e svn+http://svn.pythonpaste.org/Paste/wphp/trunk/#egg=Paste
Obtaining Paste from svn+http://svn.pythonpaste.org/Paste/wphp/trunk/#egg=Paste
Checking out http://svn.pythonpaste.org/Paste/wphp/trunk/ to /home/hdknr/.ve/rpx/src/paste
Running setup.py egg_info for package Paste
Downloading/unpacking flup (from Paste)
Downloading flup-1.0.3.dev-20100221.tar.gz (57Kb): 57Kb downloaded
Running setup.py egg_info for package flup
Installing collected packages: flup, Paste
Running setup.py install for flup
Running setup.py develop for Paste
Creating /home/hdknr/.ve/rpx/lib/python2.5/site-packages/wphp.egg-link (link to .)
Adding wphp 0.1dev-r8085 to easy-install.pth file
Installed /home/hdknr/.ve/rpx/src/paste
Successfully installed flup Paste
(rpx)hdknr@deblen2010:~/.ve/rpx/src/myrpx$ python
Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
imported django settings
>>> from wphp import PHPApp
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/hdknr/.ve/rpx/src/paste/wphp/__init__.py", line 13, in <module>
from paste import fileapp
ImportError: No module named paste
(rpx)hdknr@deblen2010:~/.ve/rpx/src/myrpx$ tree ../paste/
../paste/
|– README-moved.txt
|– docs
| |– conf.py
| |– index.txt
| |– license.txt
| |– modules
| | `– wphp.txt
| `– news.txt
|– regen-docs
|– setup.cfg
|– setup.py
|– tests
| |– conftest.py
| |– php-files
| | |– test.php
| | `– test2.php
| `– test_php.py
|– wphp
| |– __init__.py
| |– __init__.pyc
| |– default-php.ini
| |– fcgi_app.py
| `– php_ini_metadata.py
`– wphp.egg-info
|– PKG-INFO
|– SOURCES.txt
|– dependency_links.txt
|– entry_points.txt
|– not-zip-safe
|– paster_plugins.txt
|– requires.txt
`– top_level.txt
6 directories, 26 files
pasteディレクトリはあるが、インストールはされていな。eggの名前をpasteにしてしまっただけですね。 #egg=wphp するべき。
(rpx)hdknr@deblen2010:~/.ve/rpx/src/myrpx$ pip install Paste
Downloading/unpacking Paste
Downloading Paste-1.7.2.tar.gz (373Kb): 373Kb downloaded
Running setup.py egg_info for package Paste
Installing collected packages: Paste
Running setup.py install for Paste
Skipping installation of /home/hdknr/.ve/rpx/lib/python2.5/site-packages/paste/__init__.py (namespace package)
Installing /home/hdknr/.ve/rpx/lib/python2.5/site-packages/Paste-1.7.2-py2.5-nspkg.pth
Successfully installed Paste
hdknr@deblen2010:~/test$ more ~/test/index.php
<?PHP
echo "hello !\n";
echo date( "Y/m/d (D) H:i:s\n", time() );
?>
hdknr@deblen2010:~/test$ php ~/test/index.php
hello !
2010/03/17 (Wed) 16:56:28
(rpx)hdknr@deblen2010:~/.ve/rpx/src/myrpx$ python
Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
imported django settings
>>> from wphp import PHPApp
>>> myphp = PHPApp(‘/home/hdknr/test’,php_options={’magic_quote_gpc’: ‘Off’} )
>>> from wsgiref.simple_server import make_server
>>> httpd=make_server(”,8000,myphp)
>>> httpd.serve_forever()
hdknr@deblen2010:~/test$ sudo lsof -i:8000
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
python 23894 hdknr 3u IPv4 160912 TCP *:8000 (LISTEN)
hdknr@deblen2010:~/test$
hdknr@deblen2010:~/test$ curl -I http://localhost:8000/
HTTP/1.0 200 OK
Date: Wed, 17 Mar 2010 07:58:43 GMT
Server: WSGIServer/0.1 Python/2.5.2
x-powered-by: PHP/5.2.6-1+lenny6
content-type: text/html
Content-Length: 0
>>> httpd.serve_forever()
localhost – - [17/Mar/2010 16:58:43] "HEAD / HTTP/1.1" 200 0
hdknr@deblen2010:~/test$ sudo lsof -i:8000
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
python 23894 hdknr 3u IPv4 160912 TCP *:8000 (LISTEN)
php-cgi 23897 hdknr 3u IPv4 160912 TCP *:8000 (LISTEN)
php-cgi 23897 hdknr 4u IPv4 160917 TCP localhost:8000->localhost:35084 (CLOSE_WAIT)
php-cgi 23898 hdknr 3u IPv4 160912 TCP *:8000 (LISTEN)
php-cgi 23898 hdknr 4u IPv4 160917 TCP localhost:8000->localhost:35084 (CLOSE_WAIT)
hdknr@deblen2010:~/test$ curl http://localhost:8000/
hello !
2010/03/17 (Wed) 16:59:44
>>> httpd.serve_forever()
localhost – - [17/Mar/2010 16:58:43] "HEAD / HTTP/1.1" 200 0
localhost – - [17/Mar/2010 16:59:44] "GET / HTTP/1.1" 200 34
(rpx)hdknr@deblen2010:~/.ve/rpx/src/myrpx$ tree social/ social/ |-- __init__.py |-- models.py |-- templates | `-- social | `-- login_link.html |-- templatetags | |-- __init__.py | `-- social_tags.py |-- tests.py |-- urls.py `-- views.py
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django_rpx',
'social',
)
import settings
from django import template
from django.template import Context, loader
from django.template.loader import render_to_string
from django.core.urlresolvers import reverse
from django.contrib.sites.models import Site
#
register = template.Library()
@register.inclusion_tag('social/login_link.html', takes_context=True)
def login_link(context, text):
current_site=Site.objects.get_current()
return {
'text': text,
'realm': 'hdknr.com',
'token_url': "http://%s" % (current_site.domain,),
}
<a class="social_link" onclick="return false;"
href="https://{{ realm }}.hdknr.com/openid/v2/signin?token_url={{ token_url }}">
{{ text }}
</a>
rom django import template
from django.http import HttpResponse
def default(request):
ctx={}
return HttpResponse(
template.Template("""
{% load social_tags %}
<html><head><title>Social</title></head>
<body>
<h1> Hello Social </h1>
{% login_link "LOGIN" %}
"""
).render( template.Context() ))
つまり、social_tags.py を テンプレートの中で、{% load social_tags %} すると、ライブラリが読み込まれるので、 {% login_link “LOGIN” %} すると、ライブラリの、login_ling(“LOGIN”) が呼ばれます。
ソース表示。
<html><head><title>Social</title></head>
<body>
<h1> Hello Social </h1>
<a class="social_link" onclick="return false;"
href="https://hdknr.hdknr.com/openid/v2/signin?token_url=http://ec.deb">
LOGIN
</a>