定形ラベル(xxhoge .html など)以外へのアクセス許可。
ex, hoge.swfに、ブラウザから直接アクセスさせたい。
su -
[root@hogeserver]# chcon -t httpd_sys_content_t /var/www/html/hoge.swf
[root@hogeserver]# restorecon -R /var/www/html
2009年2月1日日曜日
2009年1月30日金曜日
python の文字ばけ防止 utf8
パイソンの、デフォルトの文字コードを調べる
>>> import sys
>>> sys.getdefaultencoding()
'ascii'
/usr/lib/python2.4/site-packages/ に、
sitecustomize.py という名前で、下の2行を書き込んだファイルをつくる。
import sys
sys.setdefaultencoding('utf-8')
確認する。
>>> import sys
>>> sys.getdefaultencoding()
'utf-8'
これで、CGIの文字化けも直った。
詳しくは、http://d.hatena.ne.jp/SumiTomohiko/20070120/1169300624
>>> import sys
>>> sys.getdefaultencoding()
'ascii'
/usr/lib/python2.4/site-packages/ に、
sitecustomize.py という名前で、下の2行を書き込んだファイルをつくる。
import sys
sys.setdefaultencoding('utf-8')
確認する。
>>> import sys
>>> sys.getdefaultencoding()
'utf-8'
これで、CGIの文字化けも直った。
詳しくは、http://d.hatena.ne.jp/SumiTomohiko/20070120/1169300624
2009年1月11日日曜日
ブログつーるテスト1
ぱらぱら漫画風に、写真がいれかわるビューワーをつくってみた。
http://nori103.web.fc2.com/index.html
苦労した。
FLEXは、ひとつのmxmlが、ひとつのクラスとなっているようだ。
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="init()"
backgroundAlpha="1" backgroundColor="#ff4500">
このMLの、CreationComlete="init()" が、クラス名と、初期化する関数名になる。
クラスをわける、または、class hogehoge とやると、クラスがネストになってますと、コンパイル時に警告される。(このあたりが苦労する)
http://nori103.web.fc2.com/index.html
苦労した。
FLEXは、ひとつのmxmlが、ひとつのクラスとなっているようだ。
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="init()"
backgroundAlpha="1" backgroundColor="#ff4500">
このMLの、CreationComlete="init()" が、クラス名と、初期化する関数名になる。
クラスをわける、または、class hogehoge とやると、クラスがネストになってますと、コンパイル時に警告される。(このあたりが苦労する)
2008年12月29日月曜日
MY SQL 雑記
UTF-8を MySQLdbで、Insert などした際に、文字化ける。 utf8ではなく、 charset = 'latin1' でかえってくる。
rikiroku氏が、「強引に直し」ている例があるが、再コンパイルが必要らしく、今回パス。
http://rikima.dip.jp:8081/rikima/rikima-blog/categories/python/cbcategory_view?b_start:int=16
ちなみに、cursor.pyを探すのに苦労したので、メモは残そう。
MySQLdbは、YUMを使ったりした標準的?なインストールでは以下にある。(CenOS5)
"/usr/lib/python2.4/site-packages/MySQLdb/cursors.py
cursor.pyのなかで、たくさん関数があるうちの、この関数
def callproc(self, procname, args=()):
長い英文の説明書きがある・・・・
from types import UnicodeType
db = self._get_db()
元々→ #charset = db.character_set_name()
charset = 'utf-8'
↑↑↑ この個所を変えるらしい。
めんどくさいので、従来方式にする。なんで、pythonとmysqlの両方がutf-8仕様なのにと思うが・・・
python2.5では、これも直っているらしいとも聞くが、2.5入れるのもメンドイので、今回はこれで。
↓このブログが詳しい。
http://blog.livedoor.jp/alisue_seiga/archives/74330.html
my.ini
[mysqld] default-character-set=utf8 character_set_server=utf8 skip-character-set-client-handshake
スクリプトの中
connection = MySQLdb.connect(host=,port=,user=,passwd=,db=,use_unicode=True,charset="utf8")
変数をutf-8でとるようにした
hensu = unicode(hensu, 'utf-8', 'ignore')
SQL文をunicode指定してもよいらしい。(メンドイのでしてないが、変数をutf-8にしてあるのでちゃんと動いた。スクリプトファイル自体も -*= coding: utf-8 -*- にしてある)
cursor.execute(u"INSERT INTO person (name,age) VALUES ('例文',10);")
rikiroku氏が、「強引に直し」ている例があるが、再コンパイルが必要らしく、今回パス。
http://rikima.dip.jp:8081/rikima/rikima-blog/categories/python/cbcategory_view?b_start:int=16
ちなみに、cursor.pyを探すのに苦労したので、メモは残そう。
MySQLdbは、YUMを使ったりした標準的?なインストールでは以下にある。(CenOS5)
"/usr/lib/python2.4/site-packages/MySQLdb/cursors.py
cursor.pyのなかで、たくさん関数があるうちの、この関数
def callproc(self, procname, args=()):
長い英文の説明書きがある・・・・
from types import UnicodeType
db = self._get_db()
元々→ #charset = db.character_set_name()
charset = 'utf-8'
↑↑↑ この個所を変えるらしい。
めんどくさいので、従来方式にする。なんで、pythonとmysqlの両方がutf-8仕様なのにと思うが・・・
python2.5では、これも直っているらしいとも聞くが、2.5入れるのもメンドイので、今回はこれで。
↓このブログが詳しい。
http://blog.livedoor.jp/alisue_seiga/archives/74330.html
my.ini
[mysqld] default-character-set=utf8 character_set_server=utf8 skip-character-set-client-handshake
スクリプトの中
connection = MySQLdb.connect(host=,port=,user=,passwd=,db=,use_unicode=True,charset="utf8")
変数をutf-8でとるようにした
hensu = unicode(hensu, 'utf-8', 'ignore')
SQL文をunicode指定してもよいらしい。(メンドイのでしてないが、変数をutf-8にしてあるのでちゃんと動いた。スクリプトファイル自体も -*= coding: utf-8 -*- にしてある)
cursor.execute(u"INSERT INTO person (name,age) VALUES ('例文',10);")
登録:
投稿 (Atom)

