Still having trouble with format / foreign keys

45 views
Skip to first unread message

Jim S

unread,
Apr 20, 2015, 3:46:58 PM4/20/15
to web...@googlegroups.com
I posted in this thread https://groups.google.com/forum/#!topic/web2py/2i9zfAzG2s8 but posted after it was closed.  Evidently, this is fixed but I'm still not seeing my 'formats' for foreign keys.  Here are the details:

I have this in my db.py:

db.define_table('customer',
Field('customerId', 'id', readable=True, writable=False, label='Customer #'),
Field('name', length=30, required=True, writable=False,
 requires=IS_NOT_EMPTY()),
Field('city', length=30, writable=False),
Field('state', length=2, writable=False),
format='%(customerId)s - %(name)s - %(city)s, %(state)s')

db.define_table('equip_order',
Field('id', 'id', readable=False, label='Order #'),
Field('order_type', 'reference orderType', label='Order Type', ondelete='RESTRICT',
  requires = IS_IN_DB(db(db.orderType.equipment==True),
  'orderType.id', '%(name)s', zero='..')),
Field('status', length=10, default='New',
  requires=IS_IN_SET(('New', 'Submitted', 'Invoiced'))),
Field('customer', 'reference customer', label='Customer', ondelete='RESTRICT'))

When I display (VIEW MODE) the customer field in the equip_order table in a custom SQLFORM.grid form using:

{{=form.custom.widget.customer}}

...it displays the id of the customer, not the name.

I thought the 'format' on the customer table definition would control this. I know I can fix it by changing the definition of the customer field in the equip_order table to:

Field('customer', 'reference customer', label='Customer', ondelete='RESTRICT',
  represent=lambda x, r: '%s - %s - %s, %s' % (db.customer(x).customerId
db.customer(x).name,
db.customer(x).city,
db.customer(x).state) if x else ''),

Should I have to do that, or should the 'format' on customer take care of it?

-Jim

Niphlod

unread,
Apr 20, 2015, 5:55:26 PM4/20/15
to web...@googlegroups.com
we're waiting for 2.10.4 including https://github.com/web2py/pydal/issues/135

Jim Steil

unread,
Apr 20, 2015, 5:58:04 PM4/20/15
to web...@googlegroups.com
So this fix isn't in the web2py 2.10.4 beta that was built on 4/18?

-Jim

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/j4MhaEfBNuQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Massimo Di Pierro

unread,
Apr 20, 2015, 7:03:03 PM4/20/15
to web...@googlegroups.com
re-pushing. Check the nightly built in 20 minutes.
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.

Jim S

unread,
Apr 20, 2015, 7:31:36 PM4/20/15
to web...@googlegroups.com
I just grabbed the latest, timestamp looks like this:

Version 2.10.4-beta+timestamp.2015.04.20.18.00.31

and still having the same issue.

-Jim
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

Jim S

unread,
Apr 20, 2015, 8:49:36 PM4/20/15
to web...@googlegroups.com
Ok, finally figured out my problem.

Back when pydal was first announced, I did a pip install of pydal.  Subsequently, I did a clean install of web2py using git clone.  Must have gotten my pydal stuff out of sync, or didn't update it.

I used pip to uninstall pydal and then ran 

git submodule update --init --recursive 

...in my web2py directory.

Now it all works.  So, I had some modules out of sync between pydal and web2py.

What is the proper way to handle these dependencies/requirements when upgrading with git?

-Jim
Reply all
Reply to author
Forward
0 new messages