OSDN Git Service

Reduce submit window using bbs type.
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Sat, 9 Sep 2006 09:15:30 +0000 (18:15 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Sat, 9 Sep 2006 09:15:30 +0000 (18:15 +0900)
src/FukuiNoNamari/BbsType/bbs_type_base.py
src/FukuiNoNamari/submit_window.py

index 36fe32f..2b135a3 100644 (file)
@@ -17,6 +17,7 @@
 
 import re
 import copy
+import time
 
 from bbs_type_exception import BbsTypeError
 
@@ -89,6 +90,21 @@ class BaseType:
         return "http://" + self.host + "/test/read.cgi/" + \
                   self.board + "/" + self.thread + "/"
 
+    def get_post_uri(self):
+        return "http://" + self.host + "/test/bbs.cgi"
+
+    def build_post_dict(self, name, mail, msg):
+        post_dict = {}
+        post_dict["bbs"] = self.board
+        post_dict["key"] = self.thread
+        post_dict["time"] = str(int(time.time()))
+        post_dict["submit"] = u"\u66f8\u304d\u8fbc\u3080".encode(
+            "cp932", "replace")
+        post_dict["FROM"] = name.encode("cp932", "replace")
+        post_dict["mail"] = mail.encode("cp932", "replace")
+        post_dict["MESSAGE"] = msg.encode("cp932", "replace")
+        return post_dict
+
     def set_extra_post(self, post_dict):
         return post_dict
 
index f64426f..fa06afa 100644 (file)
@@ -25,7 +25,6 @@ import urllib
 import urllib2
 import cookielib
 import os.path
-import time
 
 from BbsType import bbs_type_judge_uri
 from BbsType import bbs_type_exception
@@ -109,13 +108,6 @@ class WinWrap:
         self.entry_mail = self.widget_tree.get_widget("entry_mail")
         self.textbuffer = self.widget_tree.get_widget("textview").get_buffer()
 
-        self.post_dict = {}
-        self.post_dict["bbs"] = self.bbs_type.board
-        self.post_dict["key"] = self.bbs_type.thread
-        self.post_dict["time"] = str(int(time.time()))
-        self.post_dict["submit"] = u"\u66f8\u304d\u8fbc\u3080".encode(
-            "cp932", "replace")
-
         sigdic = {"on_submit_activate": self.on_submit_activate,
                   "on_close_activate": self.on_close_activate}
 
@@ -134,10 +126,7 @@ class WinWrap:
         msg = self.textbuffer.get_text(
             self.textbuffer.get_start_iter(), self.textbuffer.get_end_iter())
 
-        self.post_dict["FROM"] = name.encode("cp932", "replace")
-        self.post_dict["mail"] = mail.encode("cp932", "replace")
-        self.post_dict["MESSAGE"] = msg.encode("cp932", "replace")
-
+        self.post_dict = self.bbs_type.build_post_dict(name, mail, msg)
         self.post_dict = self.bbs_type.set_extra_post(self.post_dict)
 
         self.do_submit()
@@ -146,8 +135,7 @@ class WinWrap:
         post_encoded = urllib.urlencode(self.post_dict)
         print post_encoded
 
-        req = urllib2.Request("http://" + self.bbs_type.host + "/test/bbs.cgi",
-                              post_encoded)
+        req = urllib2.Request(self.bbs_type.get_post_uri(), post_encoded)
         req.add_header("Referer", self.uri)
 
         res = opener.open(req)