1 """overrides some base views for cubicweb on google appengine |
1 """overrides some base views for cubicweb on google appengine |
2 |
2 |
3 :organization: Logilab |
3 :organization: Logilab |
4 :copyright: 2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
4 :copyright: 2008-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 """ |
6 """ |
7 __docformat__ = "restructuredtext en" |
7 __docformat__ = "restructuredtext en" |
8 |
8 |
9 from os.path import join |
|
10 |
|
11 from logilab.mtconverter import html_escape |
9 from logilab.mtconverter import html_escape |
12 from logilab.common.decorators import cached |
|
13 |
10 |
14 from cubicweb import typed_eid |
11 from cubicweb import typed_eid |
|
12 from cubicweb.selectors import one_line_rset, match_search_state, accept |
15 from cubicweb.schema import display_name |
13 from cubicweb.schema import display_name |
16 from cubicweb.common.view import StartupView, EntityView |
14 from cubicweb.common.view import StartupView, EntityView |
17 from cubicweb.common.selectors import (one_line_rset, match_search_state, |
|
18 accept) |
|
19 from cubicweb.web import Redirect |
15 from cubicweb.web import Redirect |
20 from cubicweb.web.views import vid_from_rset |
16 from cubicweb.web.views import vid_from_rset |
21 from cubicweb.goa.db import rset_from_objs |
|
22 |
17 |
23 from google.appengine.api import datastore, mail |
18 from google.appengine.api import mail |
24 |
|
25 from main import APPLROOT |
|
26 |
19 |
27 |
20 |
28 class SearchForAssociationView(EntityView): |
21 class SearchForAssociationView(EntityView): |
29 """view called by the edition view when the user asks |
22 """view called by the edition view when the user asks |
30 to search for something to link to the edited eid |
23 to search for something to link to the edited eid |
31 """ |
24 """ |
32 id = 'search-associate' |
25 id = 'search-associate' |
33 |
26 |
34 __selectors__ = (one_line_rset, match_search_state, accept) |
27 __select__ = one_line_rset() & match_search_state('linksearch') & accept |
35 accepts = ('Any',) |
|
36 search_states = ('linksearch',) |
|
37 |
28 |
38 def cell_call(self, row, col): |
29 def cell_call(self, row, col): |
39 entity = self.entity(0, 0) |
30 entity = self.entity(0, 0) |
40 role, eid, rtype, etype = self.req.search_state[1] |
31 role, eid, rtype, etype = self.req.search_state[1] |
41 assert entity.eid == typed_eid(eid) |
32 assert entity.eid == typed_eid(eid) |
50 class SchemaImageView(StartupView): |
41 class SchemaImageView(StartupView): |
51 id = 'schemagraph' |
42 id = 'schemagraph' |
52 binary = True |
43 binary = True |
53 content_type = 'image/png' |
44 content_type = 'image/png' |
54 def call(self): |
45 def call(self): |
55 """display global schema information""" |
46 """display global schema information""" |
56 skipmeta = not int(self.req.form.get('withmeta', 0)) |
47 skipmeta = not int(self.req.form.get('withmeta', 0)) |
57 if skipmeta: |
48 if skipmeta: |
58 url = self.build_url('data/schema.png') |
49 url = self.build_url('data/schema.png') |
59 else: |
50 else: |
60 url = self.build_url('data/metaschema.png') |
51 url = self.build_url('data/metaschema.png') |