実現したいのは「名前かメール欄か署名の部分に入力がある」のに「本文も添付ファイルもない」状態を阻止すること。(
条件式を日本語で書くと
if (名前欄!="" or メール欄!="" or 署名!="") and (本文=="" or 添付ファイル==None):
投稿拒否
こんな感じ(合ってるかな?)
キャッシュ消して、スパムフィルタをちょこっと追加してみたら
このスレが見えなくなった。moonlightをオンにしたら治った。
Exception happened during processing of request from ('127.0.0.1', 60650)
Traceback (most recent call last):
File "/usr/lib/python2.6/SocketServer.py", line 560, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python2.6/SocketServer.py", line 322, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.6/SocketServer.py", line 617, in __init__
self.handle()
File "/usr/lib/python2.6/BaseHTTPServer.py", line 329, in handle
self.handle_one_request()
File "/usr/lib/python2.6/BaseHTTPServer.py", line 323, in handle_one_request
method()
File "/usr/lib/python2.6/SimpleHTTPServer.py", line 43, in do_GET
f = self.send_head()
File "/home/shigemichik/saku/shingetsu/LightCGIHTTPServer.py", line 115, in send_head
return CGIHTTPServer.CGIHTTPRequestHandler.send_head(self)
File "/usr/lib/python2.6/CGIHTTPServer.py", line 68, in send_head
return self.run_cgi()
File "/home/shigemichik/saku/shingetsu/LightCGIHTTPServer.py", line 234, in run_cgi
cgiobj.start()
File "/home/shigemichik/saku/shingetsu/basecgi.py", line 101, in start
self.run()
File "/home/shigemichik/saku/shingetsu/thread_cgi.py", line 68, in run
self.print_thread(path)
File "/home/shigemichik/saku/shingetsu/thread_cgi.py", line 221, in print_thread
self.print_record(cache, rec, path, str_path)
File "/home/shigemichik/saku/shingetsu/thread_cgi.py", line 253, in print_record
if attachutil.is_valid_image(type, attach_file):
File "/home/shigemichik/saku/shingetsu/attachutil.py", line 44, in is_valid_image
path_suffix = _imghdr.what(path)
File "/usr/lib/python2.6/imghdr.py", line 15, in what
location = file.tell()
AttributeError: 'NoneType' object has no attribute 'tell'
#!/usr/bin/python
# coding:utf-8
''' shinGETsu sign generator'''
from __future__ import print_function
import sys
import getpass
try:
import apollo
except ImportError:
print('This script needed to run as same directory as apollo.py and compatible.py.')
sys.exit(-2)
def main():
print('This script will generate your shinGETsu signature.', end='\n\n')
print('Please enter password that you want to use in shinGETsu.')
print('''Attention: You must not type non-ASCII charactor,
then you cannot get correct sign!''')
while True:
try:
sgpasswd = getpass.getpass()
except EOFError:
print('\nquit')
return 1
sgpasswd = sgpasswd.strip('\n')
if sgpasswd:
break
print('You must enter some charactors.')
>>c9a9298c
pep8コマンドでチェックしたら
$ pep8 gensgsign.py
gensgsign.py:10:80: E501 line too long (88 characters)
gensgsign.py:39:12: E225 missing whitespace around operator
gensgsign.py:41:1: W391 blank line at end of file
だそうなので気になる方は直してください。