[web2py] Re: Solidform: key-error

2011-12-20 Thread kenji4569
Thanks for your feedback. I'm relieved:)

On 12月20日, 午後5:15, Johann Spies  wrote:
> Dear Kenji,
>
> The form is working now without the previous problems.  Thank you very much
> for making life easier for us!
>
> Regards
> Johann
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)


Re: [web2py] Re: Solidform: key-error

2011-12-20 Thread Johann Spies
Dear Kenji,

The form is working now without the previous problems.  Thank you very much
for making life easier for us!

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


Re: [web2py] Re: Solidform: key-error

2011-12-19 Thread Johann Spies
Thanks.  I will try it out and let you know.
Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


[web2py] Re: Solidform: key-error

2011-12-19 Thread kenji4569
Thanks for your details.

I found a bug in the plugin, which occurs when using fields with hide
properties such as readonly. Then I fixed the bug. Could you test the
new version of the plugin?: http://dev.s-cubism.com/plugin_solidform

Regards,
Kenji

On 12月19日, 午後5:51, Johann Spies  wrote:
> Dear Kenji,
>
> Apologies for the late reply.  I was away for a few days.
>
> Do you use virtual fields for computing the article_eq and ltitle?
>
> No.
>
> Here is my model:
>
> akb_signature_uuid = db.Table(db, 'akb_signature_uuid',
>                      Field('uuid', length = 64, default =
> lambda:str(uuid.uuid4()),
>                            notnull = True, writable = False, readable =
> False,
>                            unique = True, ondelete = 'CASCADE'),
>                      Field('created_on', 'datetime', default = request.now,
>                            readable = False, writable = False),
>                      Field('created_by', db.auth_user, default =
> auth.user_id,
>                            readable = False, writable = False),
>                      Field('updated_on', 'datetime', default = request.now,
>                            readable = False, writable = False),
>                      Field('updated_by', db.auth_user, update =
> auth.user_id,
>                            readable = False, writable = False)
>
> ## The following two functions are used to calculate article_eq:
>
> def au_cleanup(au):
>     au1 = re.sub(',', '', au.strip())
>     au2 = re.sub('[ ]+', ' ', au1)
>     return au2.upper()
>
> def art_ekw(art):
>     skrywers = set ([])
>     if art.primaryauthor:
>         skrywers.add (au_cleanup(art.primaryauthor))
>     if art.authors:
>         for au in art.authors.split(';'):
>             skrywers.add(au_cleanup(au))
>     if len(skrywers):
>         ekw = 1.0 / len(skrywers)
>     else:
>         ekw = 0
>     return ekw
>
> db.define_table('akb_articles',
>                 Field('title'),
>                 Field('primaryauthor'),
>                 Field('authors', 'text'),
>                 Field('rp_author', length = 64,
>                        requires = IS_EMPTY_OR(IS_IN_DB(db,
> 'akb_reprint.uuid', '%(rp_author)s'))),
>                 Field('journal',
>                       requires = IS_IN_DB(db, 'akb_journal.uuid',
> '%(title)s')),
>                 Field('bib_id'),
>                 Field('bib_pages'),
>                 Field('doctype'),
>                 Field('language'),
>                 Field('abstract', 'text'),
>                 Field('bib_vol'),
>                 Field('bib_date'),
>                 Field('url'),
>                 Field('pubyear', compute = lambda x: x['bib_date'][-4:]),
>                 Field('ut', # isi-unieke rekordnommer
>                       requires = IS_EMPTY_OR(IS_NOT_IN_DB(db,
> 'akb_articles.ut'))),
>                 Field('scopus_id', requires = IS_EMPTY_OR(IS_NOT_IN_DB(db,
> 'akb_articles.scopus_id'))),
>                 Field('sabinet_id', requires = IS_EMPTY_OR(IS_NOT_IN_DB(db,
> 'akb_articles.sabinet_id'))),
>                 Field('isap_id', requires = IS_EMPTY_OR(IS_NOT_IN_DB(db,
> 'akb_articles.isap_id'))),
>                 Field('ltitle', compute = lambda x:
> re.sub('<[iI]>|<[/][iI]>|<[sS][uU][pbBP]>||\W',
>                                                            '',
> x['title'].lower())),
>                 Field('article_eq', 'double' , compute = lambda x:
> art_ekw(x)),
>                 akb_signature_uuid,
>                 format = '%(title)s'
>                 )
>
> If it didn't work, please let me know more details.
>
>
>
> As I am not using virtualfields, I did not try your suggestion.
>
> Thanks for your attention.
>
> Regards
> Johann
>
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)

Re: [web2py] Re: Solidform: key-error

2011-12-19 Thread Johann Spies
Dear Kenji,

Apologies for the late reply.  I was away for a few days.

Do you use virtual fields for computing the article_eq and ltitle?
>
>
No.

Here is my model:


akb_signature_uuid = db.Table(db, 'akb_signature_uuid',
 Field('uuid', length = 64, default =
lambda:str(uuid.uuid4()),
   notnull = True, writable = False, readable =
False,
   unique = True, ondelete = 'CASCADE'),
 Field('created_on', 'datetime', default = request.now,
   readable = False, writable = False),
 Field('created_by', db.auth_user, default =
auth.user_id,
   readable = False, writable = False),
 Field('updated_on', 'datetime', default = request.now,
   readable = False, writable = False),
 Field('updated_by', db.auth_user, update =
auth.user_id,
   readable = False, writable = False)

## The following two functions are used to calculate article_eq:

def au_cleanup(au):
au1 = re.sub(',', '', au.strip())
au2 = re.sub('[ ]+', ' ', au1)
return au2.upper()

def art_ekw(art):
skrywers = set ([])
if art.primaryauthor:
skrywers.add (au_cleanup(art.primaryauthor))
if art.authors:
for au in art.authors.split(';'):
skrywers.add(au_cleanup(au))
if len(skrywers):
ekw = 1.0 / len(skrywers)
else:
ekw = 0
return ekw

db.define_table('akb_articles',
Field('title'),
Field('primaryauthor'),
Field('authors', 'text'),
Field('rp_author', length = 64,
   requires = IS_EMPTY_OR(IS_IN_DB(db,
'akb_reprint.uuid', '%(rp_author)s'))),
Field('journal',
  requires = IS_IN_DB(db, 'akb_journal.uuid',
'%(title)s')),
Field('bib_id'),
Field('bib_pages'),
Field('doctype'),
Field('language'),
Field('abstract', 'text'),
Field('bib_vol'),
Field('bib_date'),
Field('url'),
Field('pubyear', compute = lambda x: x['bib_date'][-4:]),
Field('ut', # isi-unieke rekordnommer
  requires = IS_EMPTY_OR(IS_NOT_IN_DB(db,
'akb_articles.ut'))),
Field('scopus_id', requires = IS_EMPTY_OR(IS_NOT_IN_DB(db,
'akb_articles.scopus_id'))),
Field('sabinet_id', requires = IS_EMPTY_OR(IS_NOT_IN_DB(db,
'akb_articles.sabinet_id'))),
Field('isap_id', requires = IS_EMPTY_OR(IS_NOT_IN_DB(db,
'akb_articles.isap_id'))),
Field('ltitle', compute = lambda x:
re.sub('<[iI]>|<[/][iI]>|<[sS][uU][pbBP]>||\W',
   '',
x['title'].lower())),
Field('article_eq', 'double' , compute = lambda x:
art_ekw(x)),
akb_signature_uuid,
format = '%(title)s'
)



If it didn't work, please let me know more details.
>

As I am not using virtualfields, I did not try your suggestion.

Thanks for your attention.

Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


[web2py] Re: Solidform: key-error

2011-12-17 Thread kenji4569
Hi Johann,
I've just investigated the problem.

Do you use virtual fields for computing the article_eq and ltitle?

If so, SOLIDFORM as well as SQLFORM need to know the filed properties
of the virtual fields, such as labels and representation. Then, one
solution would be to define a "virtual table" in which the "Fields" of
the virtual fields are defined, and pass it to the SOLIDFORM as
follows:

form = SOLIDFORM(
DAL(None).define_table('no_table',
db.akb_articles,
*[Field('article_eq', label='xxx'),
  Field('ltitle', represent=yyy)]),
record=rekord,
fields=fields_read,
showid=False,
readonly=True)

If it didn't work, please let me know more details.

Regards,
Kenji

On 12月16日, 午後9:46, luismurciano  wrote:
> may be you should as Hosoda Kenji himself, he's a kind guy, and solve
> a bug i found in just few days. you can ask him in the comments
> section in the plugin page.
>
> On 15 dic, 11:17, Johann Spies  wrote:
>
>
>
>
>
>
>
> > I get
>
> >   table = self.createform(xfields)
> >   File "applications/init/modules/plugin_solidform.py", line 96, in 
> > createform
> >     n = len(self.flat_fields)
> > KeyError: 'article_eq'
>
> > when I use the following code:
>
> > fields = ['id',
> >               'title',
> >               'primaryauthor',
> >               'authors',
> >               'rp_author',
> >               'journal',
> >               'bib_id',
> >               'bib_pages',
> >               'doctype',
> >               'language',
> >               'abstract',
> >               'bib_vol',
> >               'bib_date',
> >               'url',
> >               'pubyear',
> >               'ut',
> >               'scopus_id',
> >               'sabinet_id',
> >               'isap_id',
> >               'ltitle',
> >               'article_eq',
> >               'uuid',
> >               'created_on',
> >               'created_by',
> >               'updated_on',
> >               'updated_by']
>
> >     fields_read = [['id', None],
> >                    'title',
> >                    ['primaryauthor', None],
> >                    'authors',
> >                    ['rp_author', 'journal'],
> >                    ['bib_id', 'bib_pages' ],
> >                    ['doctype', 'language' ],
> >                    'abstract',
> >                    ['bib_vol', 'bib_date'],
> >                    'url',
> >                    ['pubyear', 'ut' ],
> >                    ['scopus_id', 'sabinet_id', 'isap_id' ],
> >                    'ltitle',
> >                    ['article_eq', 'uuid' ] ,
> >                    ['created_on', 'created_by'],
> >                    ['updated_on', 'updated_by']
> >                    ]
>
> >       form = SOLIDFORM(db.akb_articles, rekord, fields = fields, showid =
> > False, readonly = True)
>
> > The error occurs when I use fields = fields as well as the original one I
> > have tried: fields = fields_read.
>
> > The list as in 'fields'  is the result of db[table].fields().  So the
> > fieldnames are correct.
>
> > The following fields are computed fields: article_eq and ltitle.
>
> > Any idea what is causing the key-error?
>
> > The version of solidtable is one I downloaded today 
> > fromhttp://dev.s-cubism.com/web2py_plugins/pack_plugin/solidform
>
> > Regards
> > Johann
> > --
> > Because experiencing your loyal love is better than life itself,
> > my lips will praise you.  (Psalm 63:3)

[web2py] Re: Solidform: key-error

2011-12-16 Thread luismurciano
may be you should as Hosoda Kenji himself, he's a kind guy, and solve
a bug i found in just few days. you can ask him in the comments
section in the plugin page.

On 15 dic, 11:17, Johann Spies  wrote:
> I get
>
>   table = self.createform(xfields)
>   File "applications/init/modules/plugin_solidform.py", line 96, in createform
>     n = len(self.flat_fields)
> KeyError: 'article_eq'
>
> when I use the following code:
>
> fields = ['id',
>               'title',
>               'primaryauthor',
>               'authors',
>               'rp_author',
>               'journal',
>               'bib_id',
>               'bib_pages',
>               'doctype',
>               'language',
>               'abstract',
>               'bib_vol',
>               'bib_date',
>               'url',
>               'pubyear',
>               'ut',
>               'scopus_id',
>               'sabinet_id',
>               'isap_id',
>               'ltitle',
>               'article_eq',
>               'uuid',
>               'created_on',
>               'created_by',
>               'updated_on',
>               'updated_by']
>
>     fields_read = [['id', None],
>                    'title',
>                    ['primaryauthor', None],
>                    'authors',
>                    ['rp_author', 'journal'],
>                    ['bib_id', 'bib_pages' ],
>                    ['doctype', 'language' ],
>                    'abstract',
>                    ['bib_vol', 'bib_date'],
>                    'url',
>                    ['pubyear', 'ut' ],
>                    ['scopus_id', 'sabinet_id', 'isap_id' ],
>                    'ltitle',
>                    ['article_eq', 'uuid' ] ,
>                    ['created_on', 'created_by'],
>                    ['updated_on', 'updated_by']
>                    ]
>
>       form = SOLIDFORM(db.akb_articles, rekord, fields = fields, showid =
> False, readonly = True)
>
> The error occurs when I use fields = fields as well as the original one I
> have tried: fields = fields_read.
>
> The list as in 'fields'  is the result of db[table].fields().  So the
> fieldnames are correct.
>
> The following fields are computed fields: article_eq and ltitle.
>
> Any idea what is causing the key-error?
>
> The version of solidtable is one I downloaded today 
> fromhttp://dev.s-cubism.com/web2py_plugins/pack_plugin/solidform
>
> Regards
> Johann
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)