move captcha view to a place where it will be loaded by the registry...
--- a/web/captcha.py Thu Feb 18 07:29:13 2010 +0100
+++ b/web/captcha.py Thu Feb 18 08:39:30 2010 +0100
@@ -17,8 +17,7 @@
from time import time
from cubicweb import tags
-from cubicweb.view import StartupView
-from cubicweb.web import httpcache, formwidgets as fw, formfields as ff
+from cubicweb.web import formwidgets as fw
def pil_captcha(text, fontfile, fontsize):
@@ -61,21 +60,6 @@
return text, out
-class CaptchaView(StartupView):
- __regid__ = 'captcha'
-
- http_cache_manager = httpcache.NoHTTPCacheManager
- binary = True
- templatable = False
- content_type = 'image/jpg'
-
- def call(self):
- text, data = captcha.captcha(self._cw.vreg.config['captcha-font-file'],
- self._cw.vreg.config['captcha-font-size'])
- self._cw.set_session_data('captcha', text)
- self.w(data.read())
-
-
class CaptchaWidget(fw.TextInput):
def render(self, form, field, renderer=None):
# t=int(time()*100) to make sure img is not cached
--- a/web/views/editviews.py Thu Feb 18 07:29:13 2010 +0100
+++ b/web/views/editviews.py Thu Feb 18 08:39:30 2010 +0100
@@ -12,9 +12,10 @@
from logilab.mtconverter import xml_escape
from cubicweb import typed_eid
-from cubicweb.view import EntityView
+from cubicweb.view import EntityView, StartupView
from cubicweb.selectors import (one_line_rset, non_final_entity,
match_search_state)
+from cubicweb.web import httpcache, captcha
from cubicweb.web.views import baseviews, linksearch_select_url
@@ -93,3 +94,18 @@
self.w(entity.view('reledit', rtype=rtype))
else:
super(EditableFinalView, self).cell_call(row, col, props)
+
+
+class CaptchaView(StartupView):
+ __regid__ = 'captcha'
+
+ http_cache_manager = httpcache.NoHTTPCacheManager
+ binary = True
+ templatable = False
+ content_type = 'image/jpg'
+
+ def call(self):
+ text, data = captcha.captcha(self._cw.vreg.config['captcha-font-file'],
+ self._cw.vreg.config['captcha-font-size'])
+ self._cw.set_session_data('captcha', text)
+ self.w(data.read())