On Thursday, 28 June 2012 16:19:34 UTC+2, Anthony wrote:
>
> Hmm, this is a bit hard to follow, and I don't readily see the problem.
> Somewhere, though, on the initial load, it is creating the form twice but
> displaying the first version in the view (so the _formkey in the view is
> outdated). Looks like the reload also creates the form twice, but it is the
> second one that gets displayed, so the _formkey remains valid. From the
> code you've shown, I don't quite see how that is happening. Also, where is
> gekose_skrywers() called -- don't see any reference to it in the early code
> posted?
>
>
> Apologies. I see I have left out two controllers which are used as
components in the check_authors_for_article view:
d
ef list_chosen_authors():
lys = session.skrywers
if request.vars and not request.vars.records:
if request.vars.aksie == 'remove':
session.skrywers.remove(db.akb_authors[request.vars.auid].uuid)
del request.vars.aksie
del request.vars.auid
# sien
https://groups.google.com/forum/?fromgroups#!topic/web2py/7lYV8ckfvlc
if request.vars.aksie == 'add_similar':
soortgelyk = authid(db.akb_authors[request.vars.auid].surname,
db.akb_authors[request.vars.auid].firstname
)
uuids = [x.uuid for x in db(db.akb_authors.auth_id.startswith(
soortgelyk)).select(db.akb_authors.uuid)]
for item in uuids:
lys.add(item)
del request.vars.aksie
del request.vars.auid
if lys:
links = [lambda row: A(B(T('Remove')),
_href = URL(r = request, c = 'authors',
f = 'list_chosen_authors',
vars = dict(aksie= 'remove',auid
= str(row[db.akb_articles.id]))),
cid = request.cid),
lambda row: A(B(T('Add similar')),
_href = URL(r = request, c = 'authors',
f = 'list_chosen_authors',
vars = dict(aksie =
'add_similar',auid= str(row[db.akb_articles.id]))),
cid = request.cid)]
query = (db.akb_authors.uuid.belongs(lys))
id_lname = db(query).select(db.akb_authors.id, db.akb_authors.
auth_id)
session.ids = [x.id for x in id_lname]
session.lname = set([x.auth_id for x in id_lname])
fields = [db.akb_authors.id, db.akb_authors.surname, db.akb_authors.
firstname,
db.akb_authors.name, db.akb_authors.birthdate, db.
akb_authors.race,
db.akb_authors.gender, db.akb_authors.address]
wys = SQLFORM.grid(query, fields = fields, editable = False,deletable
= False,
selectable = lambda ids: gekose_skrywers(db, ids
),
links = links, create = False,
paginate = 100,
maxtextlength = 90, orderby = db.akb_authors.
surname| db.akb_authors.firstname)
# Sien
https://groups.google.com/forum/?fromgroups#!topic/web2py/93M1WEdtdOI vir
onderstaande
#wys.element('.web2py_table input[type=submit]:last')['_onclick'] =
"window.location = '/init/articles/add_article'"
else:
wys = ''
return dict(wys=wys)
def publikasievelde():
opskrif = H3(T("Authors and areas of publishing"))
if session.ids:
ids = session.ids
q2 = ((db.akb_authors.id.belongs(ids))&
(db.akb_authors_article_link.author == db.akb_authors.uuid)&
(db.akb_authors_article_link.article == db.akb_articles.uuid)&
(db.akb_journal.uuid == db.akb_articles.journal))
publikasies = SQLTABLE(db(q2).select(db.akb_authors.id, db.
akb_journal.title,
db.akb_journal.subject,
groupby = db.akb_authors.id|db.
akb_journal.title|db.akb_journal.subject,
orderby = db.akb_authors.id|db.
akb_journal.title|db.akb_journal.subject),
truncate = 130)
return dict(opskrif = opskrif, publikasies = publikasies)
else:
return
The logic runs as follows:
>From the menu 'addarticle' :
'kryskrywers' -> check_authors_for_article (which creates session
variables for 'list_chosen_authors'
The component 'publikasievelde' is just used to provide more information to
the user to make an informed decision in the selectable grid in
list_chosen_authors. The selection is then passed to the module
'gekose_skrywers' which redirects to add_article.
Regards
Johann