author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Thu, 10 Jun 2010 16:25:15 +0200 | |
changeset 5716 | 0e2af244dea5 |
parent 5556 | 9ab2b4c74baf |
child 6041 | 31776723c0c5 |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
0 | 18 |
"""overrides some base views for cubicweb on google appengine |
19 |
||
20 |
""" |
|
21 |
__docformat__ = "restructuredtext en" |
|
22 |
||
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
23 |
from logilab.mtconverter import xml_escape |
0 | 24 |
|
25 |
from cubicweb import typed_eid |
|
692
800592b8d39b
replace deprecated cubicweb.common.selectors by its new module path (cubicweb.selectors)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
431
diff
changeset
|
26 |
from cubicweb.selectors import one_line_rset, match_search_state, accept |
0 | 27 |
from cubicweb.schema import display_name |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3720
diff
changeset
|
28 |
from cubicweb.view import StartupView, EntityView |
0 | 29 |
from cubicweb.web import Redirect |
30 |
from cubicweb.web.views import vid_from_rset |
|
31 |
||
1131
544609e83317
pylint cleanup, no more need for mx datetime conversion
sylvain.thenault@logilab.fr
parents:
731
diff
changeset
|
32 |
from google.appengine.api import mail |
0 | 33 |
|
34 |
||
35 |
class SearchForAssociationView(EntityView): |
|
36 |
"""view called by the edition view when the user asks |
|
37 |
to search for something to link to the edited eid |
|
38 |
""" |
|
39 |
id = 'search-associate' |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
40 |
|
731
ac4a94e50b60
some more s/__selectors__/__select__ but still more to come
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
692
diff
changeset
|
41 |
__select__ = one_line_rset() & match_search_state('linksearch') & accept |
0 | 42 |
|
43 |
def cell_call(self, row, col): |
|
2789
39712da6f397
R propagate deprecation of AppObject.entity()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2381
diff
changeset
|
44 |
entity = self.rset.get_entity(0, 0) |
0 | 45 |
role, eid, rtype, etype = self.req.search_state[1] |
46 |
assert entity.eid == typed_eid(eid) |
|
47 |
rset = entity.unrelated(rtype, etype, role, ordermethod='fetch_order') |
|
48 |
vid = vid_from_rset(self.req, rset, self.schema) |
|
49 |
self.w(u'<div id="search-associate-content">') |
|
50 |
self.pagination(self.req, rset, w=self.w) |
|
51 |
self.wview(vid, rset) |
|
52 |
self.w(u'</div>') |
|
53 |
||
54 |
||
55 |
class SchemaImageView(StartupView): |
|
56 |
id = 'schemagraph' |
|
57 |
binary = True |
|
58 |
content_type = 'image/png' |
|
59 |
def call(self): |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
60 |
"""display global schema information""" |
2181
94ca417b9b07
backport stable branch, make schema-security consistent with other schema views changes, uniformize skipmeta/withmeta
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
61 |
skipmeta = int(self.req.form.get('skipmeta', 1)) |
0 | 62 |
if skipmeta: |
63 |
url = self.build_url('data/schema.png') |
|
64 |
else: |
|
65 |
url = self.build_url('data/metaschema.png') |
|
66 |
raise Redirect(url) |
|
67 |
||
68 |
||
69 |
from cubicweb.web.views.baseviews import MetaDataView |
|
70 |
||
71 |
class GAEMetaDataView(MetaDataView): |
|
72 |
show_eid = False |
|
73 |
||
74 |
||
75 |
from cubicweb.web.views.startup import ManageView |
|
76 |
||
77 |
def entity_types_no_count(self, eschemas): |
|
78 |
"""return a list of formatted links to get a list of entities of |
|
79 |
a each entity's types |
|
80 |
""" |
|
81 |
req = self.req |
|
82 |
for eschema in eschemas: |
|
3689
deb13e88e037
follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
83 |
if eschema.final or not (eschema.has_perm(req, 'read') or |
0 | 84 |
eschema.has_local_role('read')): |
85 |
continue |
|
86 |
etype = eschema.type |
|
87 |
label = display_name(req, etype, 'plural') |
|
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
88 |
view = self.vreg.select('views', 'list', req, req.etype_rset(etype)) |
0 | 89 |
url = view.url() |
2996
866a2c135c33
B #345282 xhtml requires to use   instead of
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2381
diff
changeset
|
90 |
etypelink = u' <a href="%s">%s</a>' % (xml_escape(url), label) |
0 | 91 |
yield (label, etypelink, self.add_entity_link(eschema, req)) |
92 |
||
93 |
ManageView.entity_types = entity_types_no_count |
|
94 |
||
95 |
||
96 |
from cubicweb.web.views.basecontrollers import SendMailController |
|
97 |
||
98 |
def sendmail(self, recipient, subject, body): |
|
99 |
sender = '%s <%s>' % ( |
|
100 |
self.req.user.dc_title() or self.config['sender-name'], |
|
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
101 |
self.req.user.cw_adapt_to('IEmailable').get_email() or self.config['sender-addr']) |
0 | 102 |
mail.send_mail(sender=sender, to=recipient, |
103 |
subject=subject, body=body) |
|
104 |
||
105 |
SendMailController.sendmail = sendmail |