Re: [web2py] Change the case in auth.navbar?

2012-01-25 Thread Nik Go
Hmm ... if one is gonna be anal about this, I think lost should be used
instead. Some users never really know their passwords or usernames, they
are either recorded somewhere or recorded automatically (autofill?), and in
case they loose this, then they never really forgot since they never
remembered it in the first place. Either way, they're still lost.

Sorry, I'm still waiting for the caffeeine to kick in and get my head
working right. :D

On Thursday, January 26, 2012, Anthony wrote:

 I thought his point was why use forgot for one and lost for the other?
 Why not forgot in both cases?

 On Wednesday, January 25, 2012 7:03:18 PM UTC-5, naveed wrote:

 It's forgot USERNAME vs forgot PASSWORD.




[web2py] processing blob fields containing xml

2012-01-11 Thread Nik Go
I access a legacy table that contains a number of fields:

db.define_table(source
,Field('sourceID', 'id')
,Field('name', 'string')
,Field('refNumber', 'string')
,Field('actualText', 'text')
,Field('remarks', 'text')
,Field('fields', 'blob'))

The fields field contains an XML description of fields, containing stuff
like this:

?xml version=1.0 encoding=UTF-8?
RootFieldsFieldNameOwner/NameValueSanta Cruz
Main/Value/FieldFieldNameLocation/NameValueSanta Cruz
District/Value/FieldFieldNameRegisterName/NameValueRegister/Value/FieldFieldNameVolume/NameValueXXIV/Value/FieldFieldNameArchRegNo/NameValueCR/Value/FieldFieldNameRepository/NameValueArchives/Value/FieldFieldNameRepositoryLoc/NameValue//Field/Fields/Root

How I can process the contents of the blob field using the advantages of
web2py forms and validators?


Re: [web2py] web2py wins an InfoWorld 2012 Technology of the Year Award

2012-01-09 Thread Nik Go
congratulations Massimo!

kudos, too, to everyone who makes this mailing list an excellent
peer-to-peer support site.  (That goes for you, Anthony.) ;-)

On Monday, January 9, 2012, Anthony wrote:


 http://www.infoworld.com/slideshow/24605/infoworlds-2012-technology-the-year-award-winners-183313#slide23

 http://www.infoworld.com/t/application-development/picking-the-top-technologies-in-wild-year-183463

 Other winners include Amazon Web Services, Heroku, Node.js, Apple iOS 5,
 iPad 2, and other well-known brands/technologies -- pretty good company.

 Anthony



Re: [web2py] Python for Android (any takers to run web2py)

2012-01-09 Thread Nik Go
Offhand, I could think of a custom app for that itch you want to scratch ..

On Tuesday, January 10, 2012, Plumo wrote:

 what is the use case for running a web framework on your Android phone?


Re: [web2py] How to do that: Verifying email account ownership

2012-01-05 Thread Nik Go
Do you mean a registered user's email address? It's included in web2py,
just enable it. Check out
http://web2py.com/book/default/chapter/09#Mail-and-Auth



On Friday, January 6, 2012, thstart wrote:

 Verifying email account ownership - I am brainstorming for the best way to
 know email address is owned by an user.

 Something like that - a user enters email address, my app
 generates a code and sends an email message with a link with this
 code, the user clicks and comes to my app which thus verifies he
 is the owner of the email account.

 Similar to reset password.

 How is the easiest wat to do that with web2py?



Re: [web2py] Happy new year

2012-01-01 Thread Nik Go
malipayong bag-ong tuig!

On Sunday, January 1, 2012, Massimo Di Pierro wrote:

 Happy new year everybody!


[web2py] grid's showbuttontext

2011-12-29 Thread Nik Go
I've set showbuttontext=False but all i get are tiny buttons without any of
the default icons. Did I miss anything during the upgrade?


[web2py] db.tablename and reference tablename multiple databases

2011-12-26 Thread Nik Go
The book states:
In fact db.tablename and reference tablename are equivalent field types.

But this seems to be true only if you are using a single database.  I had a
second database, db2 and defined a reference field to it as:
Field('myfield', db2.country)

and Web2Py created the field type: 'reference country' and assumed
db.country exists. complaining that 'country' doesnt exist. Of course,
there's no db.country, only db2.country. As a work around, I defined it as
an integer
Field('myfield', 'integer', requires=IS_IN_DB(db2, 'country.id',
db2.country._format)

It works for me and noticed that in appadmin, web2py no longer sense the
links between those tables if they are defined like the latter. Will this
cause me any problem in the future?


[web2py] new style virtual fields and autocomplete

2011-12-24 Thread Nik Go
Thanks to Anthony for correcting my  virtual field definition from
 geo.ad1.vname=Field.Virtual(lambda r: %s, %s % (r.name,
geo.country(r.id_un).iso3_0))
to:
 geo.ad1.vname=Field.Virtual(lambda r: %s, %s % (r.ad1.name,
geo.country(r.ad1.id_un).iso3_0)) #table name specified

 However, it seems that virtual fields don't work with the autocomplete
widget and i get a keyerror 'vname'.
db.address.state.widget=SQLFORM.widgets.autocomplete(request,
geo.ad2.vname, limitby=(0,10), min_length=2)

Perhaps it's only my mistake, but could someone confirm that autocomplete
don't work with virtual fields ?


Re: [web2py] Merry christmas

2011-12-24 Thread Nik Go
Malipayong Pasko!

On Sunday, December 25, 2011, Richard Vézina wrote:

 :)

 Richard

 PS.: Thank you all for helps, particularly Anthony, Massimo...



[web2py] virtual field question

2011-12-23 Thread Nik Go
When I try to access the  ad1 table from appadmin, a message is displayed
Invalid Query 'name' and the table isn't displayed. No exceptions or
tickets are generated. If I comment out the virtual field, it works fine.

What is wrong in my virtual field definition below?

geo.define_table('country'
  ,Field('id_un', 'id')
  ,Field('iso2_0', 'string', length=2)
  ,Field('iso3_0', 'string', length=3)
  ,Field('name', 'string', length=50)
  ,migrate=False
  ,format='%(name)s')
geo.define_table('ad1'
  ,Field('id_un', geo.country, writable=False)
  ,Field('id_1', 'id')
  ,Field('name', 'string', length=50)
  ,Field('iso_1', 'string', length=3)
  ,migrate=False)
geo.ad1.vname=Field.Virtual(lambda r: %s, %s % (r.name,
geo.country(r.id_un).iso3_0))


[web2py] virtual field question

2011-12-23 Thread Nik Go
When I try to access the  ad1 table from appadmin, a message is displayed
Invalid Query 'name' and the table isn't displayed. No exceptions or
tickets are generated. If I comment out the virtual field, it works fine.

What is wrong in my virtual field definition below?

geo.define_table('country'
  ,Field('id_un', 'id')
  ,Field('iso2_0', 'string', length=2)
  ,Field('iso3_0', 'string', length=3)
  ,Field('name', 'string', length=50)
  ,migrate=False
  ,format='%(name)s')
geo.define_table('ad1'
  ,Field('id_un', geo.country, writable=False)
  ,Field('id_1', 'id')
  ,Field('name', 'string', length=50)
  ,Field('iso_1', 'string', length=3)
  ,migrate=False)
geo.ad1.vname=Field.Virtual(lambda r: %s, %s % (r.name,
geo.country(r.id_un).iso3_0))


[web2py] virtual field question

2011-12-23 Thread Nik Go
When I try to access the  ad1 table from appadmin, a message is displayed
Invalid Query 'name' and the table isn't displayed. No exceptions or
tickets are generated. If I comment out the virtual field, it works fine.

What is wrong in my virtual field definition below?

geo.define_table('country'
  ,Field('id_un', 'id')
  ,Field('iso2_0', 'string', length=2)
  ,Field('iso3_0', 'string', length=3)
  ,Field('name', 'string', length=50)
  ,migrate=False
  ,format='%(name)s')
geo.define_table('ad1'
  ,Field('id_un', geo.country, writable=False)
  ,Field('id_1', 'id')
  ,Field('name', 'string', length=50)
  ,Field('iso_1', 'string', length=3)
  ,migrate=False)
geo.ad1.vname=Field.Virtual(lambda r: %s, %s % (r.name,
geo.country(r.id_un).iso3_0))


Re: [web2py] Bugtracker for web2py?

2011-12-21 Thread Nik Go
http://code.google.com/p/web2py/issues/entry

On Wednesday, December 21, 2011, greenguerilla wrote:

 Hi guys,

 I found a small error in the documentation and was looking for a
 bugtracker where I could log this.

 Can someone please pass me the url?

 Thanks,

 John


Re: [web2py] Combine SQLFORM and SQLFORM.grid?

2011-12-20 Thread Nik Go
Martin,

I have a feeling that what you're looking is multi-form updates (try to
search for that term) where a parent record (your person) and child
record (your cvrows) are updated simultaneously.

On Wednesday, December 21, 2011, Jim Steil wrote:

  have you looked at SQLFORM.smartgrid?

 -Jim

 On 12/20/2011 1:39 PM, Martin Weissenboeck wrote:

 Thanks for all hints, I have found some new ideas and I will try a ot of
 new things.

 But -may I describe my problem in detail?
 There should be a website for persons  who want to apply for a job.

 My present solution:
 Table person contains name, date of birth, phone number and so on.
 Table cv (curriculum vitae) contains for each person zero or more rows.
 Each row consists of the dates of the start and the end of the occupation
 and some details about the occupation.

 Page one is a SQLFORM of table person with a submit button. If the form
 is filled without errors the user is redirected to the second page. There
 is a SQLFORM.grid of table cv on this page. Of course person.id from
 page one is used on page two. Page two has it's own submit button.

 My question:
 It would be nice to have both forms (the form for the person and the form
 for some rows of cv) on one page with only one submit button. Is there any
 way to concatanate these two forms?

  2011/12/19 Cliff cjk...@gmail.com javascript:_e({}, 'cvml',
 'cjk...@gmail.com');

 Martin,
 There has been discussion about manipulating grid.  Search for threads
 containing form.create()

 Also perhaps Anthony will chime in.  He knows this stuff pretty well.

 apple,
  Surely the grid is just a grid and does not have a submit button?

  SQLFORM.grid is much more than that.


 http://web2py.com/books/default/chapter/29/7#SQLFORM.grid-and-SQLFORM.smartgrid-(experimental)

 On Dec 19, 9:48 am, apple simo...@gmail.com javascript:_e({}, 'cvml',
 'simo...@gmail.com'); wrote:
  Surely the grid is just a grid and does not have a submit button?
 
  Do you mean that you have a grid linked to a form and you want to
  refresh it when the form is submitted?
 
  On Dec 18, 9:10 pm, Martin Weissenboeck 
  mweis...@gmail.comjavascript:_e({}, 'cvml', 'mweis...@gmail.com');
 wrote:
 
 
 
 
 
 
 
   Hi,
   I have one form created with SQLFORM and another form created with
   SQLFORM.grid. Each form has its own submit-button.
   Is there a simple way to concatanate these forms to one form, which
 could
   be sent with one submit-button?
 
   Regards, Martin






[web2py] computed field or is_in_db(query...

2011-12-19 Thread Nik Go
commas at the beginning of a line is not a common practice, but not
necessarily a bad one.  I use it myself, having been bitten by too many
missing commas too often. ;)

On Tuesday, December 20, 2011, Richard Vézina wrote:

 I have difficulty to understand your models because they are not in
 english (sorry about that)... I will try to help anyway...

 By the way you should put , at the end of your lines like this :

 Field('CD_CIDADAO',type='**string',notnull=True,label='**Matrícula')*,*

 instead of :

 *,*Field('CD_CIDADAO',type='**string',notnull=True,label='**Matrícula')

 Because python will not understand, maybe web2py does, but it is not a
 good pratice...

 You use format =... But you don't use web2py fk fearture so format= can't
 manage your reprensentation...

 For example :

 representante table field : CD_CIDADAO field definition should be :


 Field('CD_CIDADAO',db.cidadao)

  So CD_CIDADAO will be of type integer and store the id of the cidadao
 table... That way web2py should generate a dropbox and use format=
 of cidadao table to  avoid displaying the id of the field that has no
 meaning for end user... Then you will have to use represente=
 for CD_CIDADAO field to make sure that on retreiving of the result you not
 having the id instead of what you want the user to see...


 db.representante.CD_CIDADAO.represent=lambda id, row:
 db.cidadao(id).NM_CIDADAO


 Hope it helps

 Richard


 On Mon, Dec 19, 2011 at 10:10 AM, Jose Carlos Junior 
 josec...@gmail.comwrote:

 Please...I have some dificult in do this in web2py...as follow

 db.define_table(cidadao
 ,Field('CD_CIDADAO',type='id',
 **label='Cidadão(PK)')
 ,Field('CD_MATRICULA',type='**integer',notnull=True,label='**
 Matrícula')
 ,Field('NM_CIDADAO',type='**string',notnull=True,label='**Nome')
 ,format = '%(NM_CIDADAO)s'
 ,singular = 'cidadao'
 ,plural = 'cidadaos'
 ,migrate=False)


 db.define_table(**representante
 ,Field('ID_REPRESENTANTE',**type='id',readable=False)
 ,Field('ID_CARGOS',type='**integer',notnull=True,label='**Cargo')
 ,Field('CD_CIDADAO',type='**string',notnull=True,label='**Matrícula')
 ,Field('DT_INCLUSAO',type='**datetime',notnull=True,label='**
 Inclusão')
 ,Field('DT_EXCLUSAO',type='**datetime',notnull=False,label=**
 'Exclusão')
 ,Field('CD_TELEFONE',type='**string',notnull=True,label='**Telefone')
 ,Field('CD_EMAIL',type='**string',notnull=True,label='**Email')
 ,Field('CD_CELULAR',type='**string',notnull=False,label='**Celular')
 ,migrate=False)

 db.representante.CD_CIDADAO.**requires = IS_IN_DB(db,
 'cidadao.CD_CIDADAO', '%(CD_MATRICULA)s - %(NM_CIDADAO)s')
 db.representante.ID_CARGOS.**requires = IS_IN_DB(db, 'cargos.ID_CARGOS',
 '%(NOME)s')

 db.define_table(gtils_**representante
 ,Field('ID',type='id',**readable=False)
 ,Field('ID_GTIL',readable=**True,label='GTIL')
 ,Field('ID_REPRESENTANTE',**readable=True,label='**Representante')
 ,Field('DT_INICIO',type='**datetime',notnull=True,label='**Início')
 ,Field('DT_TERMINO',type='**datetime',notnull=False,label=**
 'Término')
 ,migrate=False)

 db.gtils_representante.ID_**GTIL.requires = IS_IN_DB(db,
 'gtils.ID_GTIL', '%(NOME)s')

 How can i fill  ID_REPRESENTANTE but show NM_CIDADAO (table cidadao) once
 i don't have this field in representante table...??  or how can i put a
 computed field in 'representant' table filled with the result  choice of
 the CD_CIDADAO. Thanks alot





Re: [web2py] email/password login only: How to change email to lower case at the register page and store as a lower case to the database.

2011-12-18 Thread Nik Go
Couldn't you just add something like this?
#in your db.py, after auth.define_tables()
db.auth_user.email.requires=(IS_LOWER(),IS_EMAIL(),IS_NOT_IN_DB(db,'auth_user.email'))

Or if you use customize your auth tables ...:
Field('email', length=512,default='',comment='*'

 ,requires=(IS_LOWER(),IS_EMAIL(),IS_NOT_IN_DB(db,'auth_user.email')))


On Friday, December 16, 2011, Anthony wrote:

 def user():
 if request.args(0) == 'register':
 db.auth_user.email.requires.insert(0, IS_LOWER())
 [rest of code]

 Note, the above assumes there is already at least one validator defined
 for the email field (which there should be by default) -- otherwise, just
 do requires=...

 Anthony

 On Thursday, December 15, 2011 5:09:37 PM UTC-5, thstart wrote:

 could you please post a code how to that for register especially?




Re: [web2py] How to change the message 'value already in database or empty' in Register?

2011-12-18 Thread Nik Go
IS_IN_DB(db(db.mytable.id0), 'mytable.id', db.mytable._format

,error_message=T(Sorry chap, that doesn't exist))


You may specify your own error_message for any built-in validator.


On Sunday, December 11, 2011, Constantine Vasil wrote:

 How to change the message 'value already in database or empty' in Register?

 Thanks,

 Regards,
 --Constantine



[web2py] Re: list:reference validation

2011-12-18 Thread Nik Go
Anthony, could you elaborate a bit on that notation?
multiple=(0,3)

I wanted a maximum of two items and yet I need to write 3. In the book,
I've seen something similar with the limitby argument for DAL select:
for row in db().select(db.person.ALL, limitby=(0, 2)): print row.name

which fetches the first two, starting at zero records.


On Friday, December 16, 2011, Anthony wrote:

 Shhh! It's a secret.

 Actually, it has been added to the new 4th edition, which should be
 available online soon.

 Anthony

 On Thursday, December 15, 2011 7:06:21 PM UTC-5, ニコノコ wrote:

 Thanks Anthony. I don't think I've seen that in the docs.

 On Thursday, December 15, 2011, Anthony wrote:

 Try

 IS_IN_DB(..., multiple=(0, 3))

 The multiple argument to IS_IN_SET and IS_IN_DB can be a list or tuple
 specifying a minimum and maximum number of items to be selected (strictly
 less than on the max, so set the max to 3 to make sure there are no more
 than 2).

 Anthony

 On Wednesday, December 14, 2011 11:19:40 PM UTC-5, ニコノコ wrote:

 I have a list:reference field and would like a user to select none or
 up to two values from the list

 I could validate by calling onvalidation but I'm wondering if there's
 any built-in validator that should work? I've tried the following,
 none of which worked for me:

- IS_LENGTH(minsize=0,maxsize=2)
- IS_EXPR('len(value)=2')






[web2py] Re: grid search exceptions

2011-12-18 Thread Nik Go
please check:
http://code.google.com/p/web2py/issues/detail?id=572

Thanks

On Friday, December 16, 2011, Massimo Di Pierro wrote:

 Can you please open a ticket about this?

 On Dec 16, 12:10 am, Nik Go nikolai...@gmail.com javascript:; wrote:
  A grid search causes an exception when a user enters an unexpected field
  type.
 
  I have this field:
 
  Field('gender', 'integer', default=0,
  requires=IS_IN_SET([(0,'Unknown'), (1, 'Male'), (2, 'Female')])
 
  Since they are represented as a string (ie Male) on screen, the user may
  attempt a search like *gender is 'Male'* (whereas the correct but
  counter-intuitive term is *gender is 1*) which results in an error:
 
  ValueError: invalid literal for int() with base 10: 'Male'
 
  Perhaps there's a better way for grid search to handle exceptions like
  these? Or maybe the query popup should list the options provided for by
 the
  field's default validator?



[web2py] Re: list:reference validation

2011-12-15 Thread Nik Go
Thanks Anthony. I don't think I've seen that in the docs.

On Thursday, December 15, 2011, Anthony wrote:

 Try

 IS_IN_DB(..., multiple=(0, 3))

 The multiple argument to IS_IN_SET and IS_IN_DB can be a list or tuple
 specifying a minimum and maximum number of items to be selected (strictly
 less than on the max, so set the max to 3 to make sure there are no more
 than 2).

 Anthony

 On Wednesday, December 14, 2011 11:19:40 PM UTC-5, ニコノコ wrote:

 I have a list:reference field and would like a user to select none or up
 to two values from the list

 I could validate by calling onvalidation but I'm wondering if there's any
 built-in validator that should work? I've tried the following, none of
 which worked for me:

- IS_LENGTH(minsize=0,maxsize=2)
- IS_EXPR('len(value)=2')






[web2py] Re: weird database behavior

2011-12-15 Thread Nik Go
Isn't that the default behavior? I mean, after registration a user is
automatically logged in.

Anyway, what I did was when a currently logged-in and unverified user's
account is verified or updated by the admin, his status will be updated
when he checks his profile (or logs out and logs in again.)

On Thursday, December 15, 2011, Cliff wrote:

 After the user registers, you should probably redirect him to a login
 page that politely says something like:

 Thank you for registering.  Log in now to get access to the all the
 features of our fantastic site.



 On Dec 14, 11:37 pm, Anthony abasta...@gmail.com javascript:; wrote:
  On Wednesday, December 14, 2011 11:24:20 PM UTC-5, ニコノコ wrote:
 
   hmm ... I tried auth.user.account_status=db.auth_user[auth.user.id
   ].account_status
 
   , but I get an error:
   AttributeError: 'NoneType' object has no attribute 'account_status'
 
  It will only work when there is actually a logged in user, so start with:
 
  if auth.user:
  etc.



Re: [web2py] smartgrid - still not resolving a problem

2011-12-15 Thread Nik Go
Try this:
db.po_sku.default=lambda v,r: db.sku[r.sku_id].cpu

On Friday, December 16, 2011, Adi wrote:

 I'm still trying to resolve my problem, and desperately need someone's
 help :)

 When I try to add a new sku to a purchase order, I would like to
 prepopulate CPU field with the value from db.sku.cpu (determined by a
 dropdown).

 http://127.0.0.1:8000/test/default/list_purchase_orders/purchase_order/po_sku.po_id/1/new/po_sku

 Is it possible to do this through smartgrid, and how would I do it? Bellow
 is a short version of my code for this... I'm stuck... :(

 #db.py
 db.define_table('sku',
 Field('sku_number', 'string', label=T('SKU #')),
 Field('description', 'string', label=T('Description')),
 Field('cpu', 'double'),
 Field('note', 'text'),
 format='%(sku_number)s - %(description)s',
 )

 db.define_table('purchase_order',
 Field('po_number', 'string'),
 )

 db.define_table('po_sku',
 Field('sku_id', db.sku, label=T('SKU #')),
 Field('po_id', db.purchase_order, label=T('Purchase Order
 #')),
 Field('qty', 'integer'),
 Field('cpu', 'double'),
 )

 # default.py
 def list_purchase_orders():
 db.purchase_order.id.readable = False

 db.purchase_order['_plural'] = 'Purchase Orders'

 grid=SQLFORM.smartgrid(db.purchase_order, details=True,
 links_in_grid=True,
 maxtextlengths={'purchase_order.po_number':15},
 maxtextlength=20,
 paginate=20,
 csv=False,
 ui='jquery-ui',
 user_signature=False, oncreate = auth.archive,
 onupdate=auth.archive)
 return dict(grid=grid)




[web2py] Re: grid question - specifying initial fields

2011-12-15 Thread Nik Go
Great! Thanks Cliff

On Thursday, December 15, 2011, Cliff wrote:

 You can differentiate based on the request, like this:

 if len(request.args)  2 and request.args[-3] == 'edit':
  fields = [] # what you want to show for editing
 else:
  fields = [] # what you want to show on the initial grid

 form=SQLFORM.grid(blah, ... fields=fields ...)

 This is handy for lots of things.  Beware of this, though:

 if len(request.args)  1 and request.args[-2]=='new':

 Anyway, you get the picture.

 On Dec 14, 11:19 pm, Nik Go nikolai...@gmail.com javascript:; wrote:
  Is there a parameter to specify initial fields to display in a grid and
  still display the rest of the viewable fields only when the record is
  accessed?
 
  For example, I would like the grid to initially show: field1, field2,
  field3,field4 but when the view button is clicked it will display all
  viewable fields field5, field6, field7, fieldetc.
 
  Tried the fields parameter, but after hitting the view button it only
  displays the specified fields.



Re: [web2py] smartgrid - still not resolving a problem

2011-12-15 Thread Nik Go
Ah .. so you want it processed as soon as the drop-down is selected? That
would need some Ajax magic.

On Friday, December 16, 2011, Adi wrote:

 i put it as suggested, but it didn't work...

 another problem is onchange', when a different value gets selected in
 dropdown how to pass the accompanying db.sku.cpu to db.po_sku.cpu field.



Re: [web2py] remove references problem

2011-12-15 Thread Nik Go
Yes. Because your first statement only declares a default value for a field
type 'string', the default field type.

The second statement, redefines the field as a reference field which by
default deletes all references if the parent record is deleted.

Check out
ondelete='CASCADE' #this is the default action for any field unless it's
set to 'NO ACTION'

in the book.

On Thursday, December 15, 2011, thodoris wrote:

 Well i guess that doing

 db.define_table('cat',
 Field('name'),
 Field('owner',db.person,default=db.**person.id http://db.person.id/))
 db.cat.owner.requires = IS_IN_DB(db, db.person.id)

 does the job.



Re: [web2py] referenced auth.user_id type string

2011-12-15 Thread Nik Go
Hmm.. I've actually declared fields of type 'integer', then declare a
validator  field much later in the code. Often in a custom auth_user fields
that needs to refer to tables which will be defined much later. Kinda makes
it like a pseudo-reference field.

Field('account_status', 'integer')# custom auth_user field

db.define('some_table', Field('name'))
db.auth_user.account_status.requires=IS_IN_DB(db, 'some_table.id', '%name')

Hmm.. come to think of it maybe this is possible...
db.auth_user.account_status.type='reference some_table'


On Friday, December 16, 2011, Anthony wrote:

 On Thursday, December 15, 2011 11:42:42 AM UTC-5, thodoris wrote:

 This is a solution but look at the following, if i declare


 db.define_table('person',
 Field('name'),)

 db.define_table('cat',
 Field('name'),
 Field('owner',integer,db.**person,default=db.person.id))
 db.cat.owner.requires = IS_IN_DB(db, db.person.id)
 the reference is broken. Is there another solution?


 If you want 'owner' to reference the 'person' table, then make it a
 'reference' field type, not 'integer':

 Field('owner', db.person)

 or

 Field('owner', 'reference person')

 Note, you can't set the default to db.person.id because that refers to
 the 'id' field of the 'person' table, not a specific value for a given
 person.

 Anthony



Re: [web2py] ldap failed Version 1.99.4

2011-12-15 Thread Nik Go
Everytime a *new* stable version is out, I come to expect minor releases
happening in the next several days and try to hold off my own upgrade for
as long as possible. :P

On Friday, December 16, 2011, Massimo Di Pierro wrote:

 Looks like we need  a 1.99.5 thanks Omi

 On Dec 15, 9:43 am, Omi Chiba ochib...@gmail.com javascript:; wrote:
  Nico,
 
  Yes, it works !
  Actually the code is there for the error check reason so instead of
 comment
  out, I moved the line 92 - 94  after line 105 where result variables is
  declared.
 
  The attached file is the modified ldap_auth.py and I will send the
 patch
  to Massimo shortly.
 
  Looks like this:
  ---
  result = con.search_ext_s(
  ldap_basedn, ldap.SCOPE_SUBTREE,
  ((sAMAccountName=%s)(%s)) % (username_bare,
  filterstr), [sAMAccountName])[0][1]
  if not isinstance(result, dict):
  # result should be a dict in the form
  {'sAMAccountName': [username_bare]}
  return False
 
   ldap_auth.py
  7KViewDownload



[web2py] grid search exceptions

2011-12-15 Thread Nik Go
A grid search causes an exception when a user enters an unexpected field
type.

I have this field:

Field('gender', 'integer', default=0,
requires=IS_IN_SET([(0,'Unknown'), (1, 'Male'), (2, 'Female')])

Since they are represented as a string (ie Male) on screen, the user may
attempt a search like *gender is 'Male'* (whereas the correct but
counter-intuitive term is *gender is 1*) which results in an error:

ValueError: invalid literal for int() with base 10: 'Male'

Perhaps there's a better way for grid search to handle exceptions like
these? Or maybe the query popup should list the options provided for by the
field's default validator?


[web2py] Re: weird database behavior

2011-12-14 Thread Nik Go
I finally wrapped my head around this. (Yay!)  My custom auth_user field
account_status is set by default to unverified until an administrator
verifies the account. If the user is logged-in while the admin makes the
update, the session cached value will remain unverified until the user
logs off, even if the value in the database has been updated. On the user's
next login, everything will be okay.

As the book states (emphasis, mine) about difference between
auth.user.account_status vs db.auth_user[auth.user_id].account_status :
auth.user *contains a copy *of the db.auth_user records for the current logged
in user or None otherwise. There is also also a auth.user_id which is
auth.user_id auth.user the same as auth.user.id (i.e. the id of the current
logger in user) or None.

And because I'm trying to use an auth decorator
(auth.requires_membership(current), the currently logged-in user can not
access the function because his session is using the cached copy.

Just adding details to this post in case a fellow newbie find themselves in
the same situation.

In my design case registration doesn't require approval, but access to most
features are disabled until approved.  I suppose, had I realized this, my
question should be, and is now:* is there a way to update a currently
logged-in user's status to reflect the latest value in the db other than
asking the user to log-off first?*

/r

On Tuesday, December 13, 2011, Nik Go wrote:

 I'm still stuck with this :(

 I've already deleted my database to start from scratch but I am
 encountering the same issue. For example, i deleted a record from
 auth_account (in this case record #3) but when the I run the app and run a
 trace with ipdb, my functions still return a row id 3, as if it wasn't
 deleted. But verifying with the admin app, and checking the sqlite
 database, there's no more id 3 (as to be expected). It's supposed to be
 deleted and yet the function still return the old data!

 db.define_table('see'
 ,Field('name',length=128)
 ,Field('classification', 'integer')
 ,Field('jurisdiction', 'reference see')
 ,Field('affinity', 'integer'))
 db.define_table('auth_account'
 ,Field('subdomain', 'string')
 ,Field('see', 'reference see')
 ,Field('status',
 'integer',requires=IS_IN_SET(settings.account_status,zero=None))
 ,Field('manager', 'integer', default=2))


 In a function, I have this to check the value of a database
 if not session.auth_account:
 subdomain=request.env.http_host
 session.auth_account=db((db.auth_account.subdomain==subdomain)\
 (db.auth_account.status==4)(db.
 auth_account.is_active==True))\
 .select(db.auth_account.id, db.
 auth_account.see, db.auth_account.status).first()

 and it returns: *Row {'status': 4, 'see': 11, 'id': 3}*

 That is not correct since record id 3 has been deleted (from the admin
 interface, confirmed by checking the sqlite table). And if I add a new
 record (to replace id 3), the new record isn't found by the function. I
 have restarted web2py, deleted the databases, restarted the browser,
 changed browser but I get the same thing.

 Under what conditions would this thing happen: a function returning a row
 that doesn't exist?  What are the other things I should check?

 On Monday, December 12, 2011, Nik Go wrote:

 And the other fields are still set to none, while their true values are
 otherwise.

 On Monday, December 12, 2011, Nik Go wrote:


 Here's a screenshot. Noticed that i edited the name toGJonathan but
 the response.flash  retrieves it as Jonathan

 On Monday, December 12, 2011, Nik Go wrote:

 I have a custom auth_user field that I could edit from admin (and I can
 verify that changes are actually written in the sqlite table) but every
 time I check the data from a view, the field value is always set to the
 initial default values, and not whatever's actually stored in the table.
 It's like the data is being retrieved from some cache I don't know about.

 I'm stumped. Has anyone experienced anything similar? This is the first
 time I encountered this. What gives?





[web2py] Re: weird database behavior

2011-12-14 Thread Nik Go
I finally wrapped my head around this. (Yay!)  My custom auth_user field
account_status is set by default to unverified until an administrator
verifies the account. If the user is logged-in while the admin makes the
update, the session cached value will remain unverified until the user
logs off, even if the value in the database has been updated. On the user's
next login, everything will be okay.

As the book states (emphasis, mine) about difference between
auth.user.account_status vs db.auth_user[auth.user_id].account_status :
auth.user *contains a copy *of the db.auth_user records for the current logged
in user or None otherwise. There is also also a auth.user_id which is
auth.user_id auth.user the same as auth.user.id (i.e. the id of the current
logger in user) or None.

And because I'm trying to use an auth decorator
(auth.requires_membership(current), the currently logged-in user can not
access the function because his session is using the cached copy.

Just adding details to this post in case a fellow newbie find themselves in
the same situation.

In my design case registration doesn't require approval, but access to most
features are disabled until approved.  I suppose, had I realized this, my
question should be, and is now:* is there a way to update a currently
logged-in user's status to reflect the latest value in the db other than
asking the user to log-off first?*

/r

On Tuesday, December 13, 2011, Nik Go wrote:

 I'm still stuck with this :(

 I've already deleted my database to start from scratch but I am
 encountering the same issue. For example, i deleted a record from
 auth_account (in this case record #3) but when the I run the app and run a
 trace with ipdb, my functions still return a row id 3, as if it wasn't
 deleted. But verifying with the admin app, and checking the sqlite
 database, there's no more id 3 (as to be expected). It's supposed to be
 deleted and yet the function still return the old data!

 db.define_table('see'
 ,Field('name',length=128)
 ,Field('classification', 'integer')
 ,Field('jurisdiction', 'reference see')
 ,Field('affinity', 'integer'))
 db.define_table('auth_account'
 ,Field('subdomain', 'string')
 ,Field('see', 'reference see')
 ,Field('status',
 'integer',requires=IS_IN_SET(settings.account_status,zero=None))
 ,Field('manager', 'integer', default=2))


 In a function, I have this to check the value of a database
 if not session.auth_account:
 subdomain=request.env.http_host
 session.auth_account=db((db.auth_account.subdomain==subdomain)\
 (db.auth_account.status==4)(db.
 auth_account.is_active==True))\
 .select(db.auth_account.id, db.
 auth_account.see, db.auth_account.status).first()

 and it returns: *Row {'status': 4, 'see': 11, 'id': 3}*

 That is not correct since record id 3 has been deleted (from the admin
 interface, confirmed by checking the sqlite table). And if I add a new
 record (to replace id 3), the new record isn't found by the function. I
 have restarted web2py, deleted the databases, restarted the browser,
 changed browser but I get the same thing.

 Under what conditions would this thing happen: a function returning a row
 that doesn't exist?  What are the other things I should check?

 On Monday, December 12, 2011, Nik Go wrote:

 And the other fields are still set to none, while their true values are
 otherwise.

 On Monday, December 12, 2011, Nik Go wrote:


 Here's a screenshot. Noticed that i edited the name toGJonathan but
 the response.flash  retrieves it as Jonathan

 On Monday, December 12, 2011, Nik Go wrote:

 I have a custom auth_user field that I could edit from admin (and I can
 verify that changes are actually written in the sqlite table) but every
 time I check the data from a view, the field value is always set to the
 initial default values, and not whatever's actually stored in the table.
 It's like the data is being retrieved from some cache I don't know about.

 I'm stumped. Has anyone experienced anything similar? This is the first
 time I encountered this. What gives?





[web2py] 1.99.4 grid icons and showbuttontext

2011-12-14 Thread Nik Go
If
showbuttontext=False

I couldn't see the default icons anymore. (i.e the magnifying glass for the
view button)


[web2py] grid question - specifying initial fields

2011-12-14 Thread Nik Go
Is there a parameter to specify initial fields to display in a grid and
still display the rest of the viewable fields only when the record is
accessed?

For example, I would like the grid to initially show: field1, field2,
field3,field4 but when the view button is clicked it will display all
viewable fields field5, field6, field7, fieldetc.

Tried the fields parameter, but after hitting the view button it only
displays the specified fields.


[web2py] list:reference validation

2011-12-14 Thread Nik Go
I have a list:reference field and would like a user to select none or up to
two values from the list

I could validate by calling onvalidation but I'm wondering if there's any
built-in validator that should work? I've tried the following, none of
which worked for me:

   - IS_LENGTH(minsize=0,maxsize=2)
   - IS_EXPR('len(value)=2')


[web2py] Re: weird database behavior

2011-12-14 Thread Nik Go
hmm ... I tried auth.user.account_status=db.auth_user[auth.user.id
].account_status

, but I get an error:
AttributeError: 'NoneType' object has no attribute 'account_status'


On Wednesday, December 14, 2011, Anthony wrote:

 In my design case registration doesn't require approval, but access to
 most features are disabled until approved.  I suppose, had I realized
 this, my question should be, and is now:* is there a way to update a
 currently logged-in user's status to reflect the latest value in the db
 other than asking the user to log-off firs*t?


 You might try directly updating auth.user.

 Anthony



Re: [web2py] Two questions: 1. empty SQLFORM.grid 2. Represent question

2011-12-14 Thread Nik Go
columns support has been dropped, right?

On Thursday, December 15, 2011, Cliff wrote:

 On 1.99.2, grid will display a row for each row returned by the query,
 but won't show any data from the secondary table.

 Unless I'm missing a step.  Actually I would be happy if that were the
 case, as I have one situation where it would be very helpful to show
 data from the foreign table.

 Insert an owner in this table:
 db.define_table('owners',
Field('name', length=32),
format = '%(name)s',
   )

 Insert two dogs in this table.  Point owner_id to the owner inserted
 above.
 db.define_table('dogs',
Field('owner_id', 'reference owners'),
Field('name', length=32),
format = '%(name)s',
   )

 This grid will show two rows, reflecting the left join, but it won't
 show
 either dog's name or id.

 def index():
columns = ('owners.name',  'dogs.id', 'dogs.name')
query = db.owners.id  0
form = SQLFORM.grid(
query,
left = db.dogs.on(
db.dogs.owner_id == db.owners.id
),
columns=columns
)
return dict(form=form

 On Dec 14, 11:14 am, Massimo Di Pierro 
 massimo.dipie...@gmail.comjavascript:;
 
 wrote:
  Can you provide an example of grid usage that ignores left joins?
 
  On Dec 14, 8:00 am, Johann Spies johann.sp...@gmail.com javascript:;
 wrote:
 
 
 
 
 
 
 
   On 14 December 2011 14:07, Cliff cjk...@gmail.com javascript:;
 wrote:
 
 It is not possible with that query. It is the essence of the query.
 
I don't think grid processes left joins.
 
You might try smartgrid.  It knows about left joins and gives you a
link to the foreign table, but it doesn't display any information
 from
specific rows in that table.
 
   Thanks for your attention.  I have worked around this problem.  I was
 just
   curious why the grid would count the correct number of records but not
   display them.
 
   Regards
   Johann
   --
   Because experiencing your loyal love is better than life itself,
   my lips will praise you.  (Psalm 63:3)



[web2py] error downloading 1.99.3

2011-12-13 Thread Nik Go
I'm not sure if it's my crappy mobile Internet connection or something else
but I couldn't seem to download a good copy of the version 1.99.3.

When testing the zip file, I get this error: error:  invalid compressed
data to inflate web2py/applications/examples/static/artwork.tar.gz. I
already tried this three times today, without any success, and the same
error.


[web2py] Re: error downloading 1.99.3

2011-12-13 Thread Nik Go
Yeah, probably. I just ignored the file, and it seems to be working.

On Wednesday, December 14, 2011, kasapo wrote:

 I downloaded the 1.99.3 source today and unzipped it with no issues.
 Maybe it was the crappy mobile connection or just some hiccup in the
 interwebs. I'd try again from another connection or just clear your
 cache and try downloading again... or use wget

 On Dec 13, 6:04 am, Nik Go nikolai...@gmail.com javascript:; wrote:
  I'm not sure if it's my crappy mobile Internet connection or something
 else
  but I couldn't seem to download a good copy of the version 1.99.3.
 
  When testing the zip file, I get this error: error:  invalid compressed
  data to inflate web2py/applications/examples/static/artwork.tar.gz. I
  already tried this three times today, without any success, and the same
  error.



[web2py] Re: error downloading 1.99.3

2011-12-13 Thread Nik Go
P.S.
I downloaded using aria2 and wget. Same result.

On Wednesday, December 14, 2011, Nik Go wrote:

 Yeah, probably. I just ignored the file, and it seems to be working.

 On Wednesday, December 14, 2011, kasapo wrote:

 I downloaded the 1.99.3 source today and unzipped it with no issues.
 Maybe it was the crappy mobile connection or just some hiccup in the
 interwebs. I'd try again from another connection or just clear your
 cache and try downloading again... or use wget

 On Dec 13, 6:04 am, Nik Go nikolai...@gmail.com wrote:
  I'm not sure if it's my crappy mobile Internet connection or something
 else
  but I couldn't seem to download a good copy of the version 1.99.3.
 
  When testing the zip file, I get this error: error:  invalid compressed
  data to inflate web2py/applications/examples/static/artwork.tar.gz. I
  already tried this three times today, without any success, and the same
  error.




[web2py] Re: weird database behavior

2011-12-12 Thread Nik Go
I'm still stuck with this :(

I've already deleted my database to start from scratch but I am
encountering the same issue. For example, i deleted a record from
auth_account (in this case record #3) but when the I run the app and run a
trace with ipdb, my functions still return a row id 3, as if it wasn't
deleted. But verifying with the admin app, and checking the sqlite
database, there's no more id 3 (as to be expected). It's supposed to be
deleted and yet the function still return the old data!

db.define_table('see'
,Field('name',length=128)
,Field('classification', 'integer')
,Field('jurisdiction', 'reference see')
,Field('affinity', 'integer'))
db.define_table('auth_account'
,Field('subdomain', 'string')
,Field('see', 'reference see')
,Field('status',
'integer',requires=IS_IN_SET(settings.account_status,zero=None))
,Field('manager', 'integer', default=2))


In a function, I have this to check the value of a database
if not session.auth_account:
subdomain=request.env.http_host
session.auth_account=db((db.auth_account.subdomain==subdomain)\
(db.auth_account.status==4)(db.
auth_account.is_active==True))\
.select(db.auth_account.id,
db.auth_account.see,
db.auth_account.status).first()

and it returns: *Row {'status': 4, 'see': 11, 'id': 3}*

That is not correct since record id 3 has been deleted (from the admin
interface, confirmed by checking the sqlite table). And if I add a new
record (to replace id 3), the new record isn't found by the function. I
have restarted web2py, deleted the databases, restarted the browser,
changed browser but I get the same thing.

Under what conditions would this thing happen: a function returning a row
that doesn't exist?  What are the other things I should check?

On Monday, December 12, 2011, Nik Go wrote:

 And the other fields are still set to none, while their true values are
 otherwise.

 On Monday, December 12, 2011, Nik Go wrote:


 Here's a screenshot. Noticed that i edited the name toGJonathan but the
 response.flash  retrieves it as Jonathan

 On Monday, December 12, 2011, Nik Go wrote:

 I have a custom auth_user field that I could edit from admin (and I can
 verify that changes are actually written in the sqlite table) but every
 time I check the data from a view, the field value is always set to the
 initial default values, and not whatever's actually stored in the table.
 It's like the data is being retrieved from some cache I don't know about.

 I'm stumped. Has anyone experienced anything similar? This is the first
 time I encountered this. What gives?





[web2py] weird database behavior

2011-12-11 Thread Nik Go
I have a custom auth_user field that I could edit from admin (and I can
verify that changes are actually written in the sqlite table) but every
time I check the data from a view, the field value is always set to the
initial default values, and not whatever's actually stored in the table.
It's like the data is being retrieved from some cache I don't know about.

I'm stumped. Has anyone experienced anything similar? This is the first
time I encountered this. What gives?


[web2py] Re: weird database behavior

2011-12-11 Thread Nik Go
And the other fields are still set to none, while their true values are
otherwise.

On Monday, December 12, 2011, Nik Go wrote:


 Here's a screenshot. Noticed that i edited the name toGJonathan but the
 response.flash  retrieves it as Jonathan

 On Monday, December 12, 2011, Nik Go wrote:

 I have a custom auth_user field that I could edit from admin (and I can
 verify that changes are actually written in the sqlite table) but every
 time I check the data from a view, the field value is always set to the
 initial default values, and not whatever's actually stored in the table.
 It's like the data is being retrieved from some cache I don't know about.

 I'm stumped. Has anyone experienced anything similar? This is the first
 time I encountered this. What gives?





Re: [web2py] Getting table a to use as default string from field in table b

2011-12-11 Thread Nik Go
db.table_settings.default_value.requires = IS_IN_SET(['a','b'])
db.table_settings['parent_table'].default_value*.default*

I think this is what you want, but make sure that you assign your
validators first in your table_settings, because otherwise they're empty
(or properly, None)


On Monday, December 12, 2011, tsvim wrote:

 db.define_table('table_settings',
 Field('name','string'),
 Field('default_value','string'))

 db.define_table('data',

 Field('parent_table',db.table_settings,writable=False,readable=False),
 Field('datetime','datetime',default=request.now),
 Field('title','string'),
 Field('value','string'))

 db.data.value.default = db.table_settings['parent_table'].default_value
 db.table_settings.default_value.requires = IS_IN_SET(['a','b'])




[web2py] user profile - adding a button

2011-12-10 Thread Nik Go
How do I add a new button in a user's profile page that redirects to
another view?


Re: [web2py] Submit gutton in fields

2011-12-03 Thread Nik Go
My own workaround for this issue is to to declare it as string and regexp
,Field('actual_date', 'string', length=10
  #  or -MM or -MM-DD
  ,requires=IS_EMPTY_OR(IS_MATCH('^(\d{4})$|^(\d{4})[-
/.]((0[1-9])|(1[0-2]))$|^(\d{4})[- /.]((0[1-9])|(1[0-2]))[-
/.]((0[1-9])|[12][0-9]|3[01])$',error_message='must be  or -MM or
-MM-DD')))


On Friday, December 2, 2011, Anthony wrote:

 The calendar picker is handled entirely via JS on the client side. This
 code (
 http://code.google.com/p/web2py/source/browse/applications/welcome/static/js/web2py.js#32)
 in web2py_ajax.js adds the datepicker to date, datetime, and time fields.
 If you don't want it, you can edit that code or simply delete/rename
 calendar.js (or anytime.js, depending on which version of web2py you have).

 Anthony

 On Thursday, December 1, 2011 6:45:18 PM UTC-5, Rick wrote:

 Now I've a similar problem. How to make a button that shows a calendar
 when you click on it? The reason why I want to do that kind of button
 is that each time I try to write a date in the field the calendar pops
 up, even though I don't need it. Here is my code again:

 dayform = SQLFORM.factory(
 Field('thedate', 'date', label=T(''),
 widget=SQLFORM.widgets.date.**widget),
  submit_button='Some text')

 Thanks in advance for help

 On Dec 1, 10:37 pm, Rick sababa...@gmail.com wrote:
  Thanks! This is the final code:
  dayform = SQLFORM.factory(
  Field('thedate', 'date', label=T(''),
  widget=SQLFORM.widgets.date.**widget),
   submit_button='Some text')
 
  On Dec 1, 10:12 pm, Anthony abas...@gmail.com wrote:
 
 
 
 
 
 
 
   Submit buttons are not in fields, they are added as an input element
 to an
   entire form. Where is that Field definition -- in a table definition
 or
   SQLFORM.factory? Anyway, SQLFORM takes a 'submit_button' argument,
 which is
   the text for the submit button.
 
   Anthony
 
   On Thursday, December 1, 2011 3:57:30 PM UTC-5, Rick wrote:
 
Hi,
How to change the text on the submit button in fields? Here'sthe
 code:
 
Field('thedate', 'date', label=T(''),
widget=SQLFORM.widgets.date.**widget))
 
I tried with this, but i didn't work:
Field('thedate', 'date', label=T(''),
submit=INPUT(_type='submit'('**Some text')),
widget=SQLFORM.widgets.date.**widget))
 
Thanks in advance for help!




[web2py] Re: message application is compiled and cannot be installed

2011-12-01 Thread Nik Go
Yes! Really weird.

I created a ticket: http://code.google.com/p/web2py/issues/detail?id=544

On Thursday, December 1, 2011, Massimo Di Pierro wrote:

 It gets compiled without you clicking the button?

 On Nov 30, 8:44 pm, Nik Go nikolai...@gmail.com javascript:; wrote:
  This is a trifle behavior that I experience every time I create a new
  simple application from the admin interface.  For some reason, the new
  app gets compiled. I'm running Ubuntu 10.04 and running web2py from
 source.
 
  I need to press the remove compiled to proceed with editing the new
 app. I've
  had this behavior prior to 1.99 but ignored it since I use Komodo as
 editor
  anyway.
 
  How do I fix this?



Re: [web2py] How disable date widget?

2011-12-01 Thread Nik Go
You can do it here: http://code.google.com/p/web2py/issues/entry

On Thursday, December 1, 2011, Vinicius Assef wrote:

 Where do I open it?


 On Thu, Dec 1, 2011 at 2:57 AM, Massimo Di Pierro
 massimo.dipie...@gmail.com javascript:; wrote:
  I would consider this an improvement. Please open a ticket.
 
  On Nov 30, 9:46 am, Vinicius Assef vinicius...@gmail.com javascript:;
 wrote:
  On Tue, Nov 29, 2011 at 1:39 PM, Massimo Di Pierro
 
  massimo.dipie...@gmail.com javascript:; wrote:
   sorry it took me a while
 
   SQLFORM.widgets.string.widget and SQLFORM.widgets.date.widget
   are the same.
 
  I couldn't find anything in the docs about it. Reading there, we are
  lead to face them as different widgets.
 
   what you want is to eliminate the datepicker popup. Technically that
   is not part of the widget but handled by the JS in the page.
 
   try this, immediately after you insert the form or field:
 
   script
   jQuery('#table_field').removeClass('date'); // or datetime
   /script
 
  It worked. Thank you. :-D
  I'm not so good in Javascript. Not even in jQuery, yet.
 
  Talking about this case, I understand technically it's not inside the
  widget. But, think with me: if I have a date field with a string
  widget, couldn't web2py generate this field with another class?
  Something like date without_picker (or something better. rsrs) Or,
  the opposite, generate date date_picker in case of using this
  picker. And just date if not using it.
 
  Could we consider it a problem to be fixed?
 
  --
  Vinicius Assef.
 



Re: [web2py] Doubt about multi-tenancy

2011-12-01 Thread Nik Go
look for roles, groups and memberships in the book

On Thursday, December 1, 2011, Vinicius Assef wrote:

 I think I'll use web2py multi-tenancy, but I have some doubts:

 I have different user profiles in my app:
 a) customer: can view/edit only it's own data.
 b) seller: can view/edit its own data and his customers' data, too.
 c) back-office: can view/edit all sellers' data and any customer's
 data, but not financial data.
 d) financial-user: can view/edit anybody's financial data.
 e) super-user: can view/edit anything, anytime. This is the allmighty
 person.


 If I use the multi-tenancy feature, how can I implement profiles c, d and
 e?
 As I read in the book, multi-tenancy web2py implements is just
 filtering data by request_tenant.default field.

 --
 Vinicius Assef.



Re: [web2py] Doubt about multi-tenancy

2011-12-01 Thread Nik Go
request_tenant wouldn't fulfill all your requirements, it should work in
conjuntion with permissions.

On Thursday, December 1, 2011, Vinicius Assef wrote:

 I've looked for it and I'm using them.

 My doubt is about multi-tenancy, but I think it won't help me in this
 case, because I have users with full access, who don't can count on
 filtered accesses.

 --
 Vinicius Assef.


 On Thu, Dec 1, 2011 at 12:44 PM, Nik Go nikolai...@gmail.comjavascript:;
 wrote:
  look for roles, groups and memberships in the book
 
  On Thursday, December 1, 2011, Vinicius Assef wrote:
 
  I think I'll use web2py multi-tenancy, but I have some doubts:
 
  I have different user profiles in my app:
  a) customer: can view/edit only it's own data.
  b) seller: can view/edit its own data and his customers' data, too.
  c) back-office: can view/edit all sellers' data and any customer's
  data, but not financial data.
  d) financial-user: can view/edit anybody's financial data.
  e) super-user: can view/edit anything, anytime. This is the allmighty
  person.
 
 
  If I use the multi-tenancy feature, how can I implement profiles c, d
 and
  e?
  As I read in the book, multi-tenancy web2py implements is just
  filtering data by request_tenant.default field.
 
  --
  Vinicius Assef.
 



Re: [web2py] How to use SQLFORM.factory to define a check box field with a list of values?

2011-12-01 Thread Nik Go
IS_IN_DB(db, 'field.id', db.table._format, *multiple=True*)

process the selection with onvalidation

On Friday, December 2, 2011, Constantine Vasil wrote:

 I want to use SQLFORM.factory to define a check box field with a list of
 email addresses.
 When the user checks several, then to send an email to the selected.

 How to do that?



Re: [web2py] [flashback] web2py logo and layout has changed one year ago...

2011-12-01 Thread Nik Go
+1. The name isn't so bad. We could all probably name other projects with
worse names.

The packaging, if that is really important to the community would help
improve the image. Django's packaging is not suprising since it was
originally developed internally in a news company - the media is probably
second to none with smokes and mirrors. :)

On Thursday, December 1, 2011, Alan Etkin wrote:

 I am not sure of the benefits of changing the brand image identity
 with much frequence. I think that part of the sucess of a framework
 like django (meaning that it is so popular) is that graphically it
 has a real fine work and It has preserved a very strong image identity
 (color, tipography).
 The brand design of web2py should be enhanced but keeping a brand
 style. There is a lot of experts in visual design who could help if
 there were some cooperation mechanism suitable for this project (is
 there?). Think of schools of design for example (Buenos Aires is
 overstocked with designers).

 On Dec 1, 7:42 am, Martín Mulone mulone.mar...@gmail.com javascript:;
 wrote:
  Another logo contest is comming?... :)
 
  2011/12/1 Massimo Di Pierro massimo.dipie...@gmail.com javascript:;
 
 
 
   I do not like names that have google search conflicts. Others like
   that because their search results go up.
   We had a different name and I was threatened to be sued. I spend $500
   to trademark web2py.
 
   Can anybody find a better name that has no search conflicts, is not
   trademarked, and is willing to donate $500?
 
   It does take time and effort in building a brand and we are succeeded.
   We should not start again. We can give animal names to various stable
   version if you like.
 
   Massimo
 
   On Nov 30, 9:46 am, Omi Chiba ochib...@gmail.com javascript:;
 wrote:
I love the framework but hate the name Web2py
 
Honestly, I agree. Django sounds cool but not web2py. I like gluon
better :)
 
On Nov 30, 9:16 am, António Ramos ramstei...@gmail.comjavascript:;
 wrote:
 
 I love the framework but hate the name Web2py
 Everyone uses names related to animals, objects,etc. At least it
 gives
   a
 better change for a nice logo.
 
 Best regards
 
 2011/11/30 stefaan stefaan.hi...@gmail.com javascript:;
 
  Web2py default layouts certainly have come a long way since the
   (IMHO,
  quite awful :p )  fluorescent orange and black-green looks.
 
  I do seem to miss some best-practices documentation about how
 to
  effectively apply themes to a web2py application. The
 downloadable
  themes do not always properly display the newer widgets (like
  sqlform.grid), leaving me (as a css nitwit) not much option but
 to
   use
  the default layout. Unlike web2py functionality, the css classes
 do
  not seem to be kept backward compatible (your layout won't be
  overwritten if you upgrade to a newer web2py, but if you want the
  newer features to render properly you may have to manually merge
 old
  layouts with newer layouts)
 
  handwaving
  I'm wondering if there aren't any WYSIWYM web layout solutions
 (what-
  you-see-is-what-you-mean, a web equivalent to LaTeX macros for
  printable documents), e.g. providing standardized css classes
 that
   all
  scaffolding applications/widgets/user views ought to restrict
  themselves to. Themes would also have to be implemented in terms
 of
  those standardized css classes, hopefully leading to a smoother
  theming experience. Approaches like the ui argument in
 sqlform.grid
  do not seem ideal to me.
  /handwaving
 
  --
   http://martin.tecnodoc.com.ar



[web2py] [flashback] web2py logo and layout has changed one year ago...

2011-12-01 Thread Nik Go
+1. The name isn't so bad. We could all probably name other projects with
worse names.

The packaging, if that is really important to the community would help
improve the image. Django's packaging is not suprising since it was
originally developed internally in a news company - who knows more stuff
about smokes and mirrors

On Thursday, December 1, 2011, Alan Etkin wrote:

 I am not sure of the benefits of changing the brand image identity
 with much frequence. I think that part of the sucess of a framework
 like django (meaning that it is so popular) is that graphically it
 has a real fine work and It has preserved a very strong image identity
 (color, tipography).
 The brand design of web2py should be enhanced but keeping a brand
 style. There is a lot of experts in visual design who could help if
 there were some cooperation mechanism suitable for this project (is
 there?). Think of schools of design for example (Buenos Aires is
 overstocked with designers).

 On Dec 1, 7:42 am, Martín Mulone mulone.mar...@gmail.com wrote:
  Another logo contest is comming?... :)
 
  2011/12/1 Massimo Di Pierro massimo.dipie...@gmail.com
 
 
 
   I do not like names that have google search conflicts. Others like
   that because their search results go up.
   We had a different name and I was threatened to be sued. I spend $500
   to trademark web2py.
 
   Can anybody find a better name that has no search conflicts, is not
   trademarked, and is willing to donate $500?
 
   It does take time and effort in building a brand and we are succeeded.
   We should not start again. We can give animal names to various stable
   version if you like.
 
   Massimo
 
   On Nov 30, 9:46 am, Omi Chiba ochib...@gmail.com wrote:
I love the framework but hate the name Web2py
 
Honestly, I agree. Django sounds cool but not web2py. I like gluon
better :)
 
On Nov 30, 9:16 am, António Ramos ramstei...@gmail.com wrote:
 
 I love the framework but hate the name Web2py
 Everyone uses names related to animals, objects,etc. At least it
 gives
   a
 better change for a nice logo.
 
 Best regards
 
 2011/11/30 stefaan stefaan.hi...@gmail.com
 
  Web2py default layouts certainly have come a long way since the
   (IMHO,
  quite awful :p )  fluorescent orange and black-green looks.
 
  I do seem to miss some best-practices documentation about how
 to
  effectively apply themes to a web2py application. The
 downloadable
  themes do not always properly display the newer widgets (like
  sqlform.grid), leaving me (as a css nitwit) not much option but
 to
   use
  the default layout. Unlike web2py functionality, the css classes
 do
  not seem to be kept backward compatible (your layout won't be
  overwritten if you upgrade to a newer web2py, but if you want the
  newer features to render properly you may have to manually merge
 old
  layouts with newer layouts)
 
  handwaving
  I'm wondering if there aren't any WYSIWYM web layout solutions
 (what-
  you-see-is-what-you-mean, a web equivalent to LaTeX macros for
  printable documents), e.g. providing standardized css classes
 that
   all
  scaffolding applications/widgets/user views ought to restrict
  themselves to. Themes would also have to be implemented in terms
 of
  those standardized css classes, hopefully leading to a smoother
  theming experience. Approaches like the ui argument in
 sqlform.grid
  do not seem ideal to me.
  /handwaving
 
  --
   http://martin.tecnodoc.com.ar



Re: [web2py] How to use SQLFORM.factory to define a check box field with a list of values?

2011-12-01 Thread Nik Go
yourlist = [[u'John Doe', u'john_...@gmail.com'], [u'Mary Doe', u'
mary_...@gmail.com']]

and in your validator
IS_IN_SET(yourlist, *multiple=True*)

multiple to render checkboxes.

On Friday, December 2, 2011, Kenneth Lundström wrote:

  You either have an multi select select item in the form or then you need
 to make as many field as the is e-mail addresses.

 Either:
 form.factory(
 Field('addresses', requires = IS_IN_SET=[[u'John Doe', u'
 john_...@gmail.com javascript:_e({}, 'cvml', 'john_...@gmail.com');'],
 [u'Mary Doe', u'mary_...@gmail.com javascript:_e({}, 'cvml',
 'mary_...@gmail.com');']]))

 form.factory(
 Field('address1',
 Field('address2',
 and so on.


 Kenneth

  My values are not in a database but in a list:

  [[u'John Doe', u'john_...@gmail.com javascript:_e({}, 'cvml',
 'john_...@gmail.com');'], [u'Mary Doe', 
 u'mary_...@gmail.comjavascript:_e({}, 'cvml', 'mary_...@gmail.com');']]


  how to get them from there?

  I want names to show up next to the check boxes, when selected to know
 which email address is corresponding in order to send a message to this
 email address.





Re: [web2py] Submit gutton in fields

2011-12-01 Thread Nik Go
a 'date' field implicitly gets the SQLFORM.widgets.date.widget. of course,
being explicit helps make it clearer.

On Friday, December 2, 2011, Rick wrote:

 Thanks! This is the final code:
 dayform = SQLFORM.factory(
Field('thedate', 'date', label=T(''),
 widget=SQLFORM.widgets.date.widget),
 submit_button='Some text')

 On Dec 1, 10:12 pm, Anthony abasta...@gmail.com javascript:; wrote:
  Submit buttons are not in fields, they are added as an input element to
 an
  entire form. Where is that Field definition -- in a table definition or
  SQLFORM.factory? Anyway, SQLFORM takes a 'submit_button' argument, which
 is
  the text for the submit button.
 
  Anthony
 
 
 
 
 
 
 
  On Thursday, December 1, 2011 3:57:30 PM UTC-5, Rick wrote:
 
   Hi,
   How to change the text on the submit button in fields? Here'sthe code:
 
   Field('thedate', 'date', label=T(''),
   widget=SQLFORM.widgets.date.widget))
 
   I tried with this, but i didn't work:
   Field('thedate', 'date', label=T(''),
   submit=INPUT(_type='submit'('Some text')),
   widget=SQLFORM.widgets.date.widget))
 
   Thanks in advance for help!



Re: [web2py] Using auth.settings.login_onaccept

2011-12-01 Thread Nik Go
auth.settings.login_onaccept=URL('afterlogin') #assuming it's in the
default controller.

does the same.

For reference, the other callsbacks *(before) db io* are:
auth.settings.login_onvalidation = []
auth.settings.register_onvalidation = []
auth.settings.profile_onvalidation = []
auth.settings.retrieve_password_onvalidation = []
auth.settings.reset_password_onvalidation = []

and *after db io*
auth.settings.login_onaccept = []
auth.settings.register_onaccept = []
auth.settings.profile_onaccept = []
auth.settings.verify_email_onaccept = []


On Friday, November 11, 2011, Rahul wrote:

 Hey All,
  I got it working with the below code -

 If you need to redirect to a url - after Auth login -

 In your controller - (default.py) - Just add the below function and
 call it with auth.settings.login_onaccept as shown below.
 #--
 def afterlogin(form):
redirect(http://127.0.0.1:8000/ProjecName/default/main;)

 auth.settings.login_onaccept = lambda form:afterlogin(form)

 def main():
#response.view='default/main.html'
return dict()
 #
 Note:
 1. You should have main.html and its corresponding function in default
 controller. i.e. Where you would like to direct the file
 2. You do not need to add anything for this in db.py Just these 3
 lines should make it work . It works for me.

 Thanks All,

 Cheers, Rahul D
 (www.flockbird.com   - powered by web2py)

 PS: We can close this thread!


 On Nov 11, 4:09 pm, Cahya Dewanta cahya...@gmail.com javascript:;
 wrote:
  1. in your db.py you should define
 
  def go_log(object):
  redirect(URL('default','samples'))  #default is the controller,
  samples is the action.
 
  auth.settings.login_onaccept = go_log
 
  2. in your default.py create a action
 
  def samples():
  return dict()
 
  3. you should have created file samples.html in your views/default dir
 
  tables are models. you create them when you call db.define_table()


Re: [web2py] Best practices: When to use classes

2011-12-01 Thread Nik Go
Interesting.  Do you have any recommended links to know more about this
topic?

On Friday, December 2, 2011, Bruno Rocha wrote:

 I have an opinion about that.

 For me the /models folders should be renamed to /scripts since it has
 scripts that are executed in every request. Going on this approach I am
 only writing model-less (or script-less) apps.

 I am now recommending to all of my students and clients to avoid the use
 of models and go to class based system in modules, now with thread locals
 object and custom_importer it is very easy to create an application without
 using any model file.

 I encourage you to learn more about O.O in Python, then after that you can
 find a better way to create your web2py applications using modules and
 classes.


 --

 Bruno Rocha
 [http://rochacbruno.com.br]




[web2py] message application is compiled and cannot be installed

2011-11-30 Thread Nik Go
This is a trifle behavior that I experience every time I create a new
simple application from the admin interface.  For some reason, the new
app gets compiled. I'm running Ubuntu 10.04 and running web2py from source.

I need to press the remove compiled to proceed with editing the new app. I've
had this behavior prior to 1.99 but ignored it since I use Komodo as editor
anyway.

How do I fix this?


[web2py] Re: cannot login or register, missing links: login|register|lost password

2011-11-30 Thread Nik Go
Arghh... for some reason or another, I lost my:
auth.define_tables()

Thanks for the feedback Massimo.

On Tuesday, November 29, 2011, Nik Go wrote:

 I've been deleting tables and playing around with various settings, so I
 don't know what I've done exactly but now my app lost the links for logging
 in, registering or resetting passwords.

 If I try to access the links manually (i.e.
 http://127.0.0.1:8000/s1/default/user/register) or do the same for
 resetting the password, I get the same error:

 Traceback (most recent call last):

   File /home/n1k/web2py/gluon/restricted.py, line 194, in restricted

 exec ccode in environment

   File /home/n1k/web2py/applications/s1/controllers/default.py, line 243, 
 in module

   File /home/n1k/web2py/gluon/globals.py, line 149, in lambda

 self._caller = lambda f: f()

   File /home/n1k/web2py/applications/s1/controllers/default.py, line 205, 
 in user

 return dict(form=auth())

   File /home/n1k/web2py/gluon/tools.py, line 1126, in __call__

 return getattr(self,args[0])()

   File /home/n1k/web2py/gluon/tools.py, line 1804, in register

 separator=self.settings.label_separator

   File /home/n1k/web2py/gluon/sqlhtml.py, line 735, in __init__

 fields = [f.name for f in table if (ignore_rw or f.writable or 
 f.readable) and not f.compute]
 TypeError: 'NoneType' object is not iterable

 I've deleted my cookies, and tried using another browser with a different 
 profile. But I still get the same thing: no links, no way to register a user.

 Using the admin app, I manually registered a new user. It worked, but I could 
 get login, to.





[web2py] displaying virtualfields in auth_user

2011-11-30 Thread Nik Go
I needed an advanced profile for a registered user with fields coming from
another table. Since I want to keep the same auth_user profile link, I
thought I'd used a virtual field in the auth_user table to display a link
to the other table.

class VFprofile(object):
def advanced_profile(self):
return self.auth_user.id
#append to my auth_user table
db.auth_user.virtualfields.append(VFprofile())
#db.auth_user.advanced_profile.represent=lambda v,r: A('Click
here',_href=URL('my_profile'))

I could check the values of the advanced_profile however the virtual field
wouldn't display when a user clicks his own profile. I commented out the
last line because it generates an error KeyError:advanced_profile, but
without it the advanced_profile virtualfield is generated and accessible.
for i in db(db.auth_user.id0).select():
print i.advanced_profile
   :
   :
1
2

I know that I can customize the auth_table, but I don't want to mess up
that table with optional information. Are virtual fields displayable?
Comments are welcome, or suggestions for the proper of way of doing this.

Nik


Re: [web2py] Error using LOAD in custom module

2011-11-29 Thread Nik Go
Nice! Are you planning to release the plugin?

Let me know if you need any help testing it. :)

On Saturday, November 26, 2011, monotasker wrote:

 I'm adapting the select_or_add widget from web2py slices so that it can be
 packaged as a plugin. In that process I'm moving the business logic from a
 model file into a custom module. But this line is throwing an error that I
 can't fix:

 form_loader_div = DIV(LOAD(c = self.controller, f = self.function, args =
 add_args, ajax = True), _id = my_select_id + _dialog-form, _title =
 self.form_title)

 The error reads: 'NoneType object is not callable'.

 I've tested each of the variables, and all of them have appropriate string
 content. The DIV helper is also working fine. So I think the problem is the
 LOAD helper. I've imported it like this:

 from gluon.rewrite import load
 LOAD = load()

 But the error persists. Am I importing LOAD improperly? Any other ideas?



[web2py] cannot login or register, missing links: login|register|lost password

2011-11-29 Thread Nik Go
I've been deleting tables and playing around with various settings, so I
don't know what I've done exactly but now my app lost the links for logging
in, registering or resetting passwords.

If I try to access the links manually (i.e.
http://127.0.0.1:8000/s1/default/user/register) or do the same for
resetting the password, I get the same error:

Traceback (most recent call last):
  File /home/n1k/web2py/gluon/restricted.py, line 194, in restricted
exec ccode in environment
  File /home/n1k/web2py/applications/s1/controllers/default.py, line
243, in module
  File /home/n1k/web2py/gluon/globals.py, line 149, in lambda
self._caller = lambda f: f()
  File /home/n1k/web2py/applications/s1/controllers/default.py, line
205, in user
return dict(form=auth())
  File /home/n1k/web2py/gluon/tools.py, line 1126, in __call__
return getattr(self,args[0])()
  File /home/n1k/web2py/gluon/tools.py, line 1804, in register
separator=self.settings.label_separator
  File /home/n1k/web2py/gluon/sqlhtml.py, line 735, in __init__
fields = [f.name for f in table if (ignore_rw or f.writable or
f.readable) and not f.compute]
TypeError: 'NoneType' object is not iterable

I've deleted my cookies, and tried using another browser with a
different profile. But I still get the same thing: no links, no way to
register a user.

Using the admin app, I manually registered a new user. It worked, but
I could get login, to.


[web2py] simulate a sub-domain from localhost?

2011-11-28 Thread Nik Go
Is it possible to run something like acme.127.0.0.1:8000?

I've already set the common_field, and I want to do other local tests. I
tried a different IP address, and it works but I lose access to the admin
interface.

This is my routes.py
routers = dict(
BASE = dict(
domains = {
'127.0.0.1:8000' : 'welcome',
'acme.127.0.0.1:8000' : 's1'
}
),
)

What's the proper way of doing this?


[web2py] multi-tenant app tables

2011-11-28 Thread Nik Go
I've already set the request_tenant field and each domain can only see the
data they create.

However, from the localhost, I can only see auth_user data, and data
created from localhost. How do I allow access to all data from the
localhost administrators?

Also, how to I allow tenants to access to common/shared tables between them.


Re: [web2py] Ajax and table rows.

2011-11-24 Thread Nik Go
Cliff, you alluded that this doesn't work, but it's actually a valid
signature and should work:

IS_IN_DB(db(db.categories.parent_table==request.args(0)),'categories.id','
categories.name')

just as valid as the following signatures:
IS_IN_DB(db(db.categories.parent_table==request.args(0)), categories.id,
db.categories._format) #uses the default format of the source table
IS_IN_DB(db(db.categories.parent_table==request.args(0)), categories.id,
%(name)s)
IS_IN_DB(db(db.categories.parent_table==request.args(0)), db.categories.id,
%(name)s)

The OP didn't state what the error was, but there's a typo in his
validator: c ategories.name when it should've been just categories.name.
 Could that be the problem?


On Wednesday, November 23, 2011, Cliff wrote:

 signature from book:
 IS_IN_DB(db, 'person.id', '%(name)s', zero=T('choose one'))

 can also be:
 IS_IN_DB(db(query), 'person.id', '%(name)s', zero=T('choose one'))

 You have:
 IS_IN_DB(db(db.categories.parent_table==request.args(0)),'categories.id
 ','c
 ategories.name')

 Should be:
 IS_IN_DB(db(db.categories.parent_table==request.args(0)),'categories.id
 ','%
 (name)s')




 On Nov 21, 10:17 am, tsvim ttm...@gmail.com javascript:; wrote:
  Ok, now that this works seems I'm still in trouble.
  The page I'm loading is one that has a table that I'm trying to make
  clickable and a form to enter more data.
  Here is the controller:
 
  @auth.requires_login()
  def budget():
  db.expense.parent_table.default = request.args(0)
  db.expense.category.requires =
  IS_IN_DB(db(db.categories.parent_table==request.args(0)),'categories.id','c
 ategories.name')
  form = crud.create(db.expense)
  expenses = db(db.expense.parent_table==request.args(0)).select()
  return dict(user=auth.user.first_name, expenses=expenses, form=form)
 
  def edit_expense():
  return repr(request.vars.id)
 
  My view:
  table
tr
  thDate and Time/th
  thTitle/th
  thCategory/th
  thAmount/th
  thSource/th
/tr
 
{{ for expense in expenses: }}
 
tr class=expenses
id={{=expense.id}}
onmouseover=jQuery(this).attr(style.backgroundColor='lightgrey')
onmouseout=jQuery(this).attr(style.backgroundColor='white')

  td{{=expense.datetime}}/td
  td{{=expense.title}}/td
  td{{=expense.category.name}}/td
  td{{=expense.amount}} {{=expense.denomination}}/td
  td{{=expense.source}}/td
/tr
{{pass}}
  /table
 
  hr /
 
  {{=form}}
 
  script
  $(document).ready(function () {
   $('.expenses').click(function(){
ajax('edit_expense?id=' + $(this).attr('id'), [], '#target')
   });});
 
  /script
 
  div id=target/div
 
  I added the AJAX script to have it return to edit_expense the id of the
 row
  that was clicked but I get an error about the crud.create line in my
  controller.
 
  Thanks again for your help.
 
  Tsvi



[web2py] table inheritance and defined requires

2011-11-23 Thread Nik Go
countries = {'ti': 'Timor Leste', 'vn': 'Vietnam','in': 'India','kr':
'Korea','cn': 'China'}

db.define_table('address', Field('country'), Field('state'),
Field('street_address'))
db.address.country.requires=IS_IN_SET(countries, zero=None)

db.define_table('personal_address', db.person, db.address)
db.define_table('business_address, db.client, db.address)

#must define requires to work:
db.personal_address.country.requires=IS_IN_SET(countries, zero=None)
db.business_address.country.requires=IS_IN_SET(countries, zero=None)

I thought table inheritance would mean 'personal_address' and
'business_address' inherits the requires definition in the address table.
Assigned default values are inherited, widgets are inherited, and so are
labels. Just wondering if the requires definition should also be inherited?


Re: [web2py] SQLForm.grid - How do I use it properly?

2011-11-21 Thread Nik Go
try this :

,links = [lambda row:

 A(

SPAN(_class='icon magnifier')

   ,'View Post'

,_class='button',_title='View Post'

,_href=URL(args=[view, db.person, row.id])

)

]





On Monday, November 21, 2011, Rahul wrote:

 Hi Johann,
  That is correct but I just wanted to know if I can change the
 existing functionality for SQLForm.grid View button. To be precise -
 here is an example of what I am trying to do.

 Example:
 The default builtin View button on SQLForm.grid has label View,
 now how can I change its label to say View Post. Note, here I do not
 intend to over-ride the existing controller(function) that
 SQLForm.grid's View provides but just change its label. How can we
 achieve this? I hope you get what I am doing here :)

 Again - If someone could post the complete syntax for SQLForm.grid(All
 possible parameters ). It would be really helpful. Thanks

 Thanks and Regards, Rahul
 (www.flockbird.com - web2py powered)

 On Nov 19, 2:13 am, Johann Spies johann.sp...@gmail.com javascript:;
 wrote:
  On 18 November 2011 09:00, Rahul rahul.dhak...@gmail.com javascript:;
 wrote:
 
   Hi Johan, All,
  Sorry but I am not able to get it. With your code above I get
   an invalid controller
 
  You are not supposed to use that code exactly as it is.  You must adapt
 it
  for your circumstances:
 
links = [lambda row:
   A('Edit',_href=URL(controller,edit,args=[update, tablename, a.id
 ]))
 
  Replace controller with your controller e.g. 'default'
  Replace 'edit' with your function in the controller referred to.
 
  Regards
  Johann
  --
  Because experiencing your loyal love is better than life itself,
  my lips will praise you.  (Psalm 63:3)



[web2py] partial date values in date fields

2011-11-20 Thread Nik Go
How is it possible to accept the following values in a date field:

   - -MM-DD - no problem
   - -MM (year and month only) - entered manually, accepted by
   IS_DATE(format=T('%Y-%m')) but the actual field contains -MM-*1. *Where
   1 is added automatically by w2p.
   -  (year only) - same as above, w2p adds -*1*-*1*

Or alternatively, where MM or DD is unknown, replace with zero:

   - if , then -0-0
   - if YYY-MM, then -MM-0

Right now, I'm simply using a string field with IS_MATCH, but I'm hoping
it's possible to take advantage of the calendar widget.

Regards,


Re: [web2py] sqlform.grid

2011-11-03 Thread Nik Go
If you wish to use the icons from the CSS templates just add:

SPAN(_class='check icon')


like this custom button:

links = [lambda row: A(SPAN(_class='check icon')

,'Byte Me'

,_class='button'

,_title='Byte Me'

,_href=URL(args=[view, db.person, row.id])

)]


Read the

On Saturday, October 29, 2011, Nik Go wrote:

 That's nice Peter. Good work!

 Thanks for sharing.

 On Wednesday, October 26, 2011, peter wrote:

 I am using and enjoying sqlform.grid. I have the latest version of
 web2py, however, I think that the css files within my application have
 become out of date.

 If I have ten pages, then the page numbers appear vertically rather
 than horizontally at the bottom of the table.

 What css files do I need to copy into my application to keep the css
 up to date for the grid?

 Thanks
 Peter




Re: [web2py] SQLFORM.grid collection of posts

2011-10-28 Thread Nik Go
It mentions: If you use jqueryui then the links are rendered as buttons. 

am still trying to find an answer about how to use icons for your custom
buttons.

On Friday, October 28, 2011, Cliff wrote:

 I'll try to keep an eye on it.

 On Oct 27, 1:47 pm, Massimo Di Pierro 
 massimo.dipie...@gmail.comjavascript:;
 
 wrote:
  Thanks this is useful! Mind that the API may still fluctuate a bit.
 
  On Oct 26, 4:38 pm, Cliff cjk...@gmail.com javascript:; wrote:
 
 
 
 
 
 
 
   You can find a digest of posts about SQLFORM.grid here:
 
  https://docs.google.com/document/d/1p-OXDn75Nt2qmXQ0lvjqr4tYIf2PTIQx6.
 ..
 
   I know it is not complete, but it may help you get started.
 
   Also there is some good information in the source file: gluon/
   sqlhtml,  Just looking at the signature of the grid function is very
   instructive.
 
   If you find something I've missed, just let me know.
 
   Cliff Kachinske


Re: [web2py] sqlform.grid and represent vs. format

2011-10-28 Thread Nik Go
I experience the same unexpected behavior.

On Friday, October 28, 2011, szimszon wrote:

 I have to tables

 db.define_table( 'wdirs',
 Field( 'name', type = 'string',
 requires = IS_NOT_EMPTY()),
 *(a)* *format='%(name)s %(id)s'*
 )

 db.define_table( 'files',
 Field( 'wdirs_id', db.wdirs,
 requires = IS_IN_DB( db, db.wdirs.id, %(name)s
 %(id)s ),
 *(b)* *represent = lambda id, row: row.wdirs_id.name*)
 )

 If I remove *(b)* than the SQLFORM.grid(db.files) displays only the record
 id in wdirs_id column. The wdirs' table format parameter isn't honored. I
 have to make the represent to be able to display the name of the wdir not
 only the record id.

 Am I right or I miss something?



Re: [web2py] SQLFORM.grid awesomeness and some questions

2011-10-28 Thread Nik Go
Johan, we're you able to specify your own icons for your custom buttons? If
so, may I know how you did it?

On Thursday, October 27, 2011, Johann Spies wrote:



 On 26 October 2011 19:15, Cliff cjk...@gmail.com javascript:_e({},
 'cvml', 'cjk...@gmail.com'); wrote:

 So you need a column on the right for an Add to Cart button.



 I have previously asked about custom edit buttons and this was the answer
 (which works):

 *links = [lambda row: A('Edit',_href=URL(controller,edit,
 args=[update, tablename, a.id]))
 and set editable, deletable, details  to False. **

 **If you use jqueryui then the links are rendered as buttons

 *The buttons created this way each appears in an extra column.

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




Re: [web2py] sqlform.grid

2011-10-28 Thread Nik Go
That's nice Peter. Good work!

Thanks for sharing.

On Wednesday, October 26, 2011, peter wrote:

 I am using and enjoying sqlform.grid. I have the latest version of
 web2py, however, I think that the css files within my application have
 become out of date.

 If I have ten pages, then the page numbers appear vertically rather
 than horizontally at the bottom of the table.

 What css files do I need to copy into my application to keep the css
 up to date for the grid?

 Thanks
 Peter


[web2py] Re: grid custom button icons

2011-10-19 Thread Nik Go
*bump*

On Tuesday, October 18, 2011, Nik Go wrote:


 how do I specify the other icons available from the default icon sprite?





[web2py] _href and user signature

2011-10-19 Thread Nik Go
In a smartgrid, I'm trying to generate a clickable link to view another
records. How do I pass the signature?


[web2py] grid custom button icons

2011-10-18 Thread Nik Go
how do I specify the other icons available from the default icon sprite?


[web2py] Re: date picker on v1.99

2011-10-09 Thread Nik Go
manual entry doesn't work on the ff browsers:

- Chromium 15.0.871.0
  - Epiphany/GNOME Web Browser 2.30.2
  - Mozilla Firefox 3.6.22

I'm running ubuntu 10.04


On Friday, October 7, 2011, Massimo Di Pierro wrote:

 Which browser? When I tried it, if I remember, I was able to type.

 On Oct 6, 8:48 pm, niknok nikolai...@gmail.com javascript:; wrote:
  The new date picker looks very good. Is there a way to input dates by
  typing it directly (similar to default behaviour in older versions), in
  addition to selecting dates thru the calendar interface?
 
  /r
  Nik
 
  P.S.
  Though I couldn't type in a date, I could paste one.  (which is a
  behavior I don't expect from users)


[web2py] Re: question about preferred represenation and filtering

2011-10-09 Thread Nik Go
*bump*

any inputs?

On Friday, October 7, 2011, niknok wrote:

 **
 I have a self-referencing table [1] with a defined format for representing
 a record in this fashion: Lastname, Firstname [-mm-dd]. In the father
 field, I expect it to display the drop-down list of persons as defined in
 format, but it doesn't unless I define it explicitly (like in the  mother
 field).

 Second, I tried dbset filter for the selection list of the  father and
 mother  fields but I still get the whole table instead.

 I'm trying this out on v1.99.2. What am I doing wrong here?

 TIA

 [1]
 db.define_table('person'
 ,Field('birth_date', 'date', requires=IS_DATE())
 ,Field('last_name', notnull=True)
 ,Field('given_name', notnull=True)
 ,Field('middle_name', label=Mother's maiden name)
 ,Field('gender', 'integer', 
 requires=IS_IN_SET(settings.gender, zero='pick one'))
 ,Field('father', 'reference person'
,requires=IS_EMPTY_OR(IS_IN_DB(db('person.gender'==1), 
 'person.id'
   ,zero=T('pick one'
 ,Field('mother', 'reference person'
,requires=IS_EMPTY_OR(IS_IN_DB(db('person.gender'==2), 
 'person.id'
   ,'%(last_name)s, %(given_name)s 
 [%(birth_date)s]'
 ,zero=T('pick one'
 ,auth.signature
 ,format='%(last_name)s, %(given_name)s [%(birth_date)s]'
 )








[web2py] Re: looking for suggestions - large number of selections

2011-10-09 Thread Nik Go
Yes,  actually I'm playing with them right now. Thanks.

My kung-fu is not very good, and I couldn't make them work the way I like
it. That's why I'm asking, just in case, there are any other suggestions.

For example, adding new entries on the fly ...

On Monday, October 10, 2011, Bruno Rocha wrote:

 Have you tried one of these plugins ?
 http://dev.s-cubism.com/web2py_plugins

 On Sun, Oct 9, 2011 at 5:39 AM, niknok 
 nikolai...@gmail.comjavascript:_e({}, 'cvml', 'nikolai...@gmail.com');
  wrote:

 **
 I anticipate a huge number of entries in a person table and expect users
 find it difficult to do two things:

- selecting or viewing multiple entries
- adding a new entry on the fly


 The initial person table design used a traditional mother/father set-up
 but same-sex parent concept made this obsolete.

 db.define_table('person'
 ,Field('name')
 ,Field('birth_date')
 ,Field('parent', 'list:reference person'))

 I'm looking for a convenient way to add a person's parent where they can
 select the person's parents (if they're already in the list) or add one if
 they're not.

 The way multiple.widgets is rendered now, the parents are not easily seen
 unless the user scrolls through the list.




 --



 --
 Bruno Rocha
 [ About me: http://zerp.ly/rochacbruno ]
 [ Aprenda a programar: http://CursoDePython.com.br ]
 [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
 [ Consultoria em desenvolvimento web: http://www.blouweb.com ]




[web2py] Re: checkboxes.widget rendering

2011-10-09 Thread Nik Go
Done.

http://code.google.com/p/web2py/issues/detail?id=463

Thanks.

On Monday, October 10, 2011, Massimo Di Pierro wrote:

 Please open a ticket.

 On Oct 9, 3:39 am, niknok nikolai...@gmail.com javascript:; wrote:
  When using checkboxes.widget the expected selection box disappears,
  instead a complete list is shown. I couldn't explain it better, please
  see this screenshot
 
  This happens in all my browsers: Chromium, Epiphany and Firefox.
 
   checkboxes.widget.png
  97KViewDownload
 
   multiple.widget.png
  78KViewDownload


Re: [web2py] Re: Just a typo in change log.

2011-03-06 Thread Nik Go
Here you go ...

On 3/6/11, Massimo Di Pierro massimo.dipie...@gmail.com wrote:
 Can you help us please? Download the README file from web2py/ and
 reorder the items.



 On Mar 5, 2:54 pm, luismurciano luismurci...@gmail.com wrote:
 In the change log pagehttp://www.web2py.com/examples/default/changelog
 the version should be 1.93.1-2 instead 1.63.1-2 i guess.

 btw I think the last changes should be shown first so I dont have to
 scrolldown all the page :P
# Changelog

## 1.93.1-2
support for multiple interfaces, thanks Jonathan
jquery 1.5.1
simplejson 2.1.3
customizable simplejson
leaner app.yaml
css3 buttons in welcome
android support (experimental)
Field(':hidden'), Field('.readonly'), Field('name=value')
combined expressions print db.data.body.len().sum()
wizard can download plugins
better json serilization (object.custom_json)
better xml serialization (object.custom_xml)
better formstyle support
better comet_messaging.py (needs more testing)
many bug fixes

## 1.92.1
much improved routing (thanks Jonathan)
Expression.__mod__ (thanks Denes)
admin has MULTI_USER_MODE (admin/models/0.py)
support for count(distinct=...)
has_permissions(...,group_id)
IS_MATCH(...,strict=True)
URL(...,scheme=,host=,port=), thanks Jonathan
admin in Afrikaans, thanks Caleb
auth.signature (experimental)
many other bug fixes

## 1.91.6
web2py comet via gluon/contrib/comet_messaging.py (html5 websockets) 
experimental
fixed problem with services (broken in 1.91.5), thanks Vollrath
customizable uploadwidget, thanks Fran
fixed problem with mail unicode support, thanks Richard
fixed problem with linkto=None and references fields in SQLTABLE, thanks villas
no more upgrade button on windows since does not work
better remember-me login, thanks Martin Weissenboeck
support for recatcha options
support for GAE namespaces via DAL('gae://namespace')
new rocket (1.2.2), thanks Tim
many other bug fixes and improvements (thanks Jonathan)

## 1.91.2-1.91.5
fixed a problem with deplyment on GAE
other new dal bug fixes

## 1.91.1
LICENSE CHANGE FROM GPLv2 to LGPLv3
URL(...,hash_vars=...) allows to specify which vars need to be signed
fixed bug with aliasing in new DAL

## 1.90.6
fix issue with pickling new dal Row and Rows.

## 1.90.5
set poll = False in rocket because of poll python thread bug often unfixed, 
thanks Jonathan
fixes issue with crud and reCaptcha

## 1.90.2-4
pymysql no longer requires ssl (if not used)
fixed bug with virtualfields
fixed bug in truncate (new dal)
fixed bug in select with alternate primary key (new dal)
fixed bug with IS_IN_DB and self refences (also new dal)

## 1.90.1
new DAL (complete rewrite of the web2py DAL is more modular)
rewrite has fail safe reload, thanks Jonathan
better CAS with v2 support, thanks Olivier ROCH VILATO
better markmin2latex
session.connect(separate=True) to handle many session files, thanks huaiyu wang
changed bahvior of impersonate (more secure, can generate form or used as API)
new rocket, thanks Tim
new pyfpdf
no more old style classes
experimental couchdb support in new dal (only insert, select, update by id)
mysql support out of the box via pymysql
SQLITABLE(...,headers='labels') thanks Bruno
optional: digitally signed URLs, thanks Brian Meredyk
minor bug fixes

## 1.89.1-.5
new admin layout (thanks Branko Vukelic)
new admin search
new admin language selector (thanks Yair)
new Welcome app (thanks Martin Mulone)
better wizard
admin support for DEMO_MODE=True
admin exposes GAE deployment button (always)
MENU support None links (thanks Michael Wolfe)
web2py.py -J for running cron (thanks Jonathan Lundell)
fixed ~db.table.id on GAE (thanks MicLee)
service.jsonrpc supports service.JsonRpcException (thanks Matt)
bug fixes

## 1.88.1-2
better list: string support, thanks Bob
jquery 1.4.3
scripts/autoroutes.py
new admin wizard
added retrieve_username to navbar (if username)
internal rewrite for arbitrary paths (abspath), thanks Jonathan
populate support for list: and decimal, thanks Chirstian
markmin2latex has extra attribute
better mercual admin allows list of files, versions and retrieve
new error report system, thanks Thadeus and Selecta
SQLFORM.accepts(detect_record_change).record_changed
fixed cron for bytecode compiled apps, thanks Álvaro J. Iradier Muro
other bugs fixes and pep8 compliant fixes

## 1.87.3
fixed a major bug introduced in 1.87.1 that prevents appadmin from working for 
new apps created with 1.87.1-2.
upgraded to clockpick 1.28, thanks villas

## 1.87.1-2
new layout for examples, thanks Bruno and Martin
admin allow DEMO_MODE=True and FILTER_APPS=['welcome']
fixed a possible problem with CRON and paths

1.86.3
Error reporting on save, thanks Mariano
recalled

## 1.86.1-1.86.3
markmin2latex
markmin2pdf
fixed some bugs
Storage getfirst, getlast, getall by Kevin and Nathan
db(db.table), db(db.table.id) both suported and equivalent to db(db.table.id0)
postresql ssl support
less un-necessary logging and warnings on GAE
IS_DECIMAL_IN_RANGE and IS_FLOAT_IN_RANGE support dot=, 

[web2py:29861] Re: YAL - yet another logo

2009-09-02 Thread Nik Go
Like Richard's opinion, I like snake #1's expression as well and would vote
to have a new rendering of that snake posing similar to image #4 where it is
intertwining with web and py.

Web2Py is a developer's tool, hence a crazy logo is fine as long as it
represents the ideas the community/developers want to portray. It's the
applications that gets the businessman's nod.


On Wed, Sep 2, 2009 at 12:39 PM, Richard Gordon
richard_gor...@verizon.netwrote:

  Dear web2py community:

 I recognize that this is very late to the web2py logo game and that you may
 be tired of this thread, but I felt strongly enough about it to take some
 action. Being artistically challenged, I asked a dear friend of mine and
 professional animator, Diane Heller (http://www.dianimation.com),  to
 illustrate a web2py logo based on my specs. I submitted her drawings to
 Massimo for his review and he asked that I open them to this forum for your
 further review and comments. So please share your thoughts! To avoid biasing
 the discussion, I will withhold Massimo's feedback.

 I will, however, relate what I wrote to Massimo regarding the thought
 process behind this logo design. Web2py is clearly in the early
 adopter phase and needs to graduate to the crucial early majority phase
 before it can cross the chasm into the mainstream market acceptance. For
 web2py to proliferate, the focus right now must be on reaching early
 adopters and the leading-edge of the early majority.

 I suspect these people are either existing python programmers or
 programmers who have heard good things about python and web2py and are
 willing to switch frameworks and languages. The common draw among them,
 IMHO, is python. To state it differently, if web2py were written in Ruby or
 another language, it's likely most of us wouldn't be here. That is, unless
 we were absolutely desperate for a better framework solution than Ruby or
 Django, which seems unlikely.

 Obviously, a logo won't convince early adopters that web2py is
 enterprise/production worthy. Only apps will do that. But a logo
 can reference other brands (python) while remaining identifiably unique and
 inspiring brand loyalty. The attached drawings are attempts to achieve that
 difficult feat.

 I attach 4 versions of the logo for your consideration (call them 1, 2, 3,
 and 4 in sequence). The last one, #4, of the snake looping through the b and
 wrapping its tail around the p in web and py, respectively, is a draft of my
 preferred choice because it depicts a linkage between the web and python and
 creates a dynamic tension that the others lack. The other logos are
 prototypes from which you should consider competing snake facial expressions
 and body proportions and positions.

 This is still a work in progress, but please know that it is very hard
 work. Unless there is overwhelmingly positive feedback to these prototypes
 and a strong chance of using this logo to represent web2py, I will
 immediately ask Diane to cease and desist from further work. She has a big
 project on her plate and it would be unfair to ask for any more of her time
 than she has already graciously volunteered, unless there was a strong
 interest from this community.

 So ... have at it. Let the comments fly!

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24399] multiple OR conditions in a query

2009-06-17 Thread Nik Go
I was trying to do the following:
for n in g[:]:
query += ' | ' if bool(query) else ''
query += (db.contacts.membership.like('% + n + %'))
rows=db(query).select(db.contacts.number)

but couldn't get it to work so I resorted to executing the query using
SQLexecute instead:

for n in g[:]:
query += ' OR ' if bool(query) else ''
query += membership LIKE \% + n + %\
rows=db.executesql('SELECT number FROM contacts where '+ query +';')

Is this the web2py way?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:22872] Re: One question about version 1.63

2009-05-29 Thread Nik Go
I'm not sure if it's the same error but I got the same problem.

I unpacked the 1.63 to an existing web2py  (v1.62.3) directory.

Once I get to the default index. Clicking on administrative interface
generates an error ticket but clicking on the ticket only causes it to
generate another ticket. ad inifinitum.

No such error from a clean install. Attached is the file genereated in the
error directory


2009/5/29 mdipierro mdipie...@cs.depaul.edu


 Do you get an error report when you click on the error above? If so
 can you post it?

 Massimo

 On May 28, 11:16 pm, plato weier...@gmail.com wrote:
  os is windows
  use source code and for windows
  click on the link is ok success
  but i think maybe some problem in version 1.63
 
  On 5月29日, 上午9时45分, mdipierro mdipie...@cs.depaul.edu wrote:
 
   hmmm... are you upgrading from a previous version? Did you edit the
   welcome app? What OS?
   Did you try click on the link?
 
   Massimo
 
   On May 28, 7:14 pm, weiertzw weier...@gmail.com wrote:
 
download web2py version 1.63
i use it start server
this information

Internal error
 
Ticket issued: welcome/
127.0.0.1.2009-05-29.08-11-39.d409f7b9-5226-42bc-abe2-12e64ad696d9

 
 
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py Web Framework group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



127.0.0.1.2009-05-29.17-19-41.82ec40ce-0f75-418a-8fbb-646bf08a3b3f
Description: Binary data