[web2py] Re: Buttons in forms

2011-01-15 Thread annet
Thanks for your replies and explanations.

I tried:

 {{=INPUT(_type=submit, _value=Update data, _action=URL(r=request,
 f=update_form, args=company[0].id))}}

... this is rendered as:

input action=/mock/crud_company/update_form/2 type=submit
value=Update data

... but doesn't work, whereas this:

button
onclick=window.location='{{=URL(r=request,f='update_form',args=[company[0].id])}}';Update
data/button

... being rendered as:

button onclick=window.location='/mock/crud_company/update_form/
2';Update data/button

... does work.


From your replies and explanations I believe both should work.
Shouldn't they?


Kind regards,

Annet.


Re: [web2py] Re: Integrating web2py and a CMS

2011-01-15 Thread Kenneth Lundström
I was thinking about using web2py as the authentication platform as it 
holds the members database. Or then a LDAP that gets it information from 
members database.


The intranet will hold a lot of information that should be visible on 
the website via the CMS. Either lots of small info (names, telephone 
numbers) or maybe whole pages. Could iframe be a way of displaying data 
from web2y on a webpage?



Kenneth



This kind of information is often stored in a corporate directory 
using something called LDAP. I am not sure of the size of your company 
but it sounds like it is large enough to consider this solution. There 
is OpenLDAP on Linux or Active Directory on Microsoft which perform 
this task as concrete examples of product. The web2py server has a 
contrib module for using LDAP authentication which is documented in 
the manual. Check if your CMS is capable of this as well.


The web2py server has a very diverse set of authentication mechanisms 
such as SMTP server login etc. This would get you username and 
password in one location but not a hierarchy or org chart.


Since the choice of CMS is unknown at this point it is difficult to 
tell if it is open enough to be able to refer to tables in the web2py 
portion of the infrastructure.


A couple of ideas,
Ron




[web2py] Re: Urgent Need@@@@@@QA Tester

2011-01-15 Thread cjrh
On Jan 14, 7:17 pm, sangeetha sangeetha.ksol...@gmail.com wrote:
 *Position : QA Tester

1) This is connected to web2py how exactly?

2) I should be considerably shocked to find a QA tester reading posts
in this forum looking for work.

3) If your company is run in the manner suggested by the act of
looking for such applicants here, I'm afraid that most people worth
hiring will not even consider you.

So your post was entirely pointless.


[web2py] Re: Should I work for free? Funny

2011-01-15 Thread cjrh
On Jan 14, 8:46 pm, mattgorecki m...@goelephant.com wrote:
 I like that it was all done with CSS.  No images in sight.

Namaste.

(The geek in me greets the geek in you)


[web2py] issue with TAG and unicode

2011-01-15 Thread carlo
I have this code:

myrows=[]
for r in range(riga+1,nrows):
myrow=[]
for c in range(ncols):
cell=mysheet.cell_value(r,c) ##reading some text, cell is
unicode object
myrow.append(cell)

myrows.append(myrow)

idx=range(len(colnames))  ##colnames=['label1','label2','label3']
colnames=[item.replace('.','_') for item in colnames]
records=[]

for row in myrows: records.append(TAG['item'](*[TAG[colnames[i]]
(row[i]) for i in idx]))
response.headers['Content-Type']='application/xml'
return str(TAG['root'](*records))


As commented above cell is unicode object so myrows is a list of lists
of unicode objects.

If cell is an ascii char everything is ok; if it is not I get:

Traceback (most recent call last):
  File C:\Python26\web2py\gluon\restricted.py, line 188, in
restricted
exec ccode in environment
  File c:/Python26/web2py/applications/xcel2xml/controllers/
default.py, line 334, in module
  File C:\Python26\web2py\gluon\globals.py, line 95, in lambda
self._caller = lambda f: f()
  File c:/Python26/web2py/applications/xcel2xml/controllers/
default.py, line 255, in step44
return gen_xml(nomefile,riga,images)
  File c:/Python26/web2py/applications/xcel2xml/controllers/
default.py, line 296, in gen_xml
return str(TAG['root'](*records))
  File C:\Python26\web2py\gluon\html.py, line 797, in __str__
return self.xml()
  File C:\Python26\web2py\gluon\html.py, line 780, in xml
(fa, co) = self._xml()
  File C:\Python26\web2py\gluon\html.py, line 771, in _xml
self.components])
  File C:\Python26\web2py\gluon\html.py, line 110, in xmlescape
return data.xml()
  File C:\Python26\web2py\gluon\html.py, line 780, in xml
(fa, co) = self._xml()
  File C:\Python26\web2py\gluon\html.py, line 771, in _xml
self.components])
  File C:\Python26\web2py\gluon\html.py, line 110, in xmlescape
return data.xml()
  File C:\Python26\web2py\gluon\html.py, line 790, in xml
return '%s%s%s/%s' % (self.tag, fa, co, self.tag)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
5: ordinal not in range(128)

From Inspect Attributes:
args=   ('ascii', 'label\xc3\xa0', 5, 6, 'ordinal not in range(128)')

And from Variables:

Variables
fa  ''
selfgluon.html.__tag__ object at 0x033D2490
self.tagu'label'
co  'label\xc3\xa0'
args('ascii', 'label\xc3\xa0', 5, 6, 'ordinal not in range(128)')

the string raising the error is labelà and I see from Variables that
it was encoded in utf-8 by xml I think.

The original string was label\xe0 (as I said a unicode string).

Any suggestion? This is driving me crazy..thank you

carlo


[web2py] Re: Urgent Need@@@@@@QA Tester

2011-01-15 Thread Massimo Di Pierro
was spam. removed.

On Jan 15, 3:25 am, cjrh caleb.hatti...@gmail.com wrote:
 On Jan 14, 7:17 pm, sangeetha sangeetha.ksol...@gmail.com wrote:

  *Position : QA Tester

 1) This is connected to web2py how exactly?

 2) I should be considerably shocked to find a QA tester reading posts
 in this forum looking for work.

 3) If your company is run in the manner suggested by the act of
 looking for such applicants here, I'm afraid that most people worth
 hiring will not even consider you.

 So your post was entirely pointless.


[web2py] Re: Bugreport

2011-01-15 Thread Massimo Di Pierro
File /data/domains/web2py/applications/kenneths/controllers/
stuff.py,
line 49, in payment_receiver_update  has (onaccept=crud.archive)

this means you are storing history for the records in a archive table.
Perhaps you have migrations disabled and the f_address field is
missing in that table. If you do not need this, set onaccept=None.


On 12 tammi, 04:22, Kenneth Lundström kenneth.t.lundst...@gmail.com
wrote:
 I m working on a new application which I created with the online wizard.
 I just created a new record and then updated it via those crud forms
 which are created for all tables.

 This tabel was created by hand by editing the database models file and
 then I copied those crud forms too.

 But when I now tried to update that record I got this error ticket.
 There is a copy of the relevant part of the my database models file.

 Apache, mod_wsgi, MySQL

 Kenneth

 .2011-01-12.12-33-23.f900b81c-a5d5-45ac-8fcc-88b3bc0c3589
 Version
 web2py Version 1.91.6 (2011-01-03 17:55:14)
 Python Python 2.6.5: /usr/bin/python
 Traceback

 Traceback (most recent call last):
 File /data/domains/web2py/gluon/restricted.py, line 188, in restricted
 exec ccode in environment
 File /data/domains/web2py/applications/kenneths/controllers/stuff.py,
 line 162, in module
 File /data/domains/web2py/gluon/globals.py, line 95, in lambda
 self._caller = lambda f: f()
 File /data/domains/web2py/gluon/tools.py, line 2297, in f
 return action(*a, **b)
 File /data/domains/web2py/applications/kenneths/controllers/stuff.py,
 line 49, in payment_receiver_update
 onaccept=crud.archive)
 File /data/domains/web2py/gluon/tools.py, line 2860, in update
 callback(onaccept,form,table._tablename)
 File /data/domains/web2py/gluon/tools.py, line 50, in callback
 [action(form) for action in actions]
 File /data/domains/web2py/gluon/tools.py, line 2757, in archive
 id = archive_table.insert(**new_record)
 File /data/domains/web2py/gluon/dal.py, line 3875, in insert
 return self._db._adapter.insert(self,self._listify(fields))
 File /data/domains/web2py/gluon/dal.py, line 704, in insert
 raise e
 InternalError: (1054, uUnknown column 'f_address' in 'field list')

 Error snapshot help Detailed traceback description

 class 'gluon.contrib.pymysql.err.InternalError'((1054, uUnknown
 column 'f_address' in 'field list'))

 inspect attributes
 Exception instance attributes
 __module__ 'gluon.contrib.pymysql.err'
 __getslice__ method-wrapper '__getslice__' of InternalError object
 __str__ method-wrapper '__str__' of InternalError object
 __getattribute__ method-wrapper '__getattribute__' of InternalError object
 __dict__ {}
 __sizeof__ built-in method __sizeof__ of InternalError object
 __weakref__ None
 __init__ method-wrapper '__init__' of InternalError object
 __setattr__ method-wrapper '__setattr__' of InternalError object
 __reduce_ex__ built-in method __reduce_ex__ of InternalError object
 __new__ built-in method __new__ of type object
 __format__ built-in method __format__ of InternalError object
 __class__ class 'gluon.contrib.pymysql.err.InternalError'
 __doc__ 'Exception raised when the database encounters an...anymore, the
 transaction is\n out of sync, etc.'
 __getitem__ method-wrapper '__getitem__' of InternalError object
 __setstate__ built-in method __setstate__ of InternalError object
 __reduce__ built-in method __reduce__ of InternalError object
 args (1054, uUnknown column 'f_address' in 'field list')
 __subclasshook__ built-in method __subclasshook__ of type object
 __unicode__ built-in method __unicode__ of InternalError object
 __delattr__ method-wrapper '__delattr__' of InternalError object
 __repr__ method-wrapper '__repr__' of InternalError object
 __hash__ method-wrapper '__hash__' of InternalError object

 Function argument list

 (self=gluon.dal.MySQLAdapter object, table=Table {'current_record':
 gluon.dal.Field objec...te': gluon.dal.Field object at
 0x2aaab020bc90}, fields=[(gluon.dal.Field object, 'Suomi
 Communications Oy'), (gluon.dal.Field object, '157230-403873'),
 (gluon.dal.Field object, 'Upseerinkatu 3 A'), (gluon.dal.Field
 object, '02600'), (gluon.dal.Field object, 'Espoo'),
 (gluon.dal.Field object, 'lasku...@suomicom.fi'), (gluon.dal.Field
 object, 'www.suomicom.fi'), (gluon.dal.Field object, '1713769-5'),
 (gluon.dal.Field object, True), (gluon.dal.Field object,
 datetime.datetime(2011, 1, 12, 12, 28, 44)), (gluon.dal.Field object,
 datetime.datetime(2011, 1, 12, 12, 28, 44)), (gluon.dal.Field object,
 1), (gluon.dal.Field object, 1), (gluon.dal.Field object, 3L)])
 Code listing

 try:
 self.execute(query)
 except Exception, e:
 if isinstance(e,self.integrity_error_class()):
 return None
 raise e

 if hasattr(table,'_primarykey'):
 return dict( [ (k,fields[k]) for k in table._primarykey ])
 id = self.lastrowid(table)
 if not isinstance(id,int):

 Variables
 e InternalError(1054, uUnknown column 'f_address' in 'field list')

 
 db.define_table('t_payment_receiver',
 

[web2py] Re: Upload field

2011-01-15 Thread Massimo Di Pierro
Is there an oen issue here? I do no see a problem.

On 11 tammi, 08:20, Richard Vézina ml.richard.vez...@gmail.com
wrote:
 You need a upload field to store the path and a field to store the name of
 the file... The book is not clear I think about upload particularly about
 blob storage...

 My model :

 Field('chroma','upload',uploadfield='chroma_blob'),
 Field('chroma_blob','blob'),

 You need both doen't matter if you use blob.

 Hope this help!

 Richard

 2011/1/11 Kenneth Lundström kenneth.t.lundst...@gmail.com







  I惴 trying to find out how form.accepts handles the uploading of files (for
  my mail gateway) and made a form

     form=SQLFORM.factory(Field('text','string'),
                          Field('upload','upload'))

  When I submit a form I get a ticket stating
  you must specify a Field(...,uploadfolder=...)

  how come? In the manual it says:

  These are the default values of a Field constructor:

  Field(name, 'string', length=None, default=None,
       required=False, requires='default',
       ondelete='CASCADE', notnull=False, unique=False,
       uploadfield=True, widget=None, label=None, comment=None,
       writable=True, readable=True, update=None, authorize=None,
       autodelete=False, represent=None, compute=None,
       uploadfolder=os.path.join(request.folder,'uploads'),
       uploadseparate=None)

  I understand that if I don愒 give a uploadfolder it uses a default value of
  os.path.join(request.folder,'uploads')

  Kenneth


[web2py] Re: Ticket, do not understand why

2011-01-15 Thread Massimo Di Pierro
You seem to have a field which is data according to web2py but string
according to the db. What is the model? Did you keep migrations
enabled?

On 6 tammi, 06:34, Kenneth Lundström kenneth.t.lundst...@gmail.com
wrote:
 What is wrong with this row:
 bill_sub_items[item_id]['items'] = db(db.t_receipt_item.f_bill_item ==
 item_id).select()

 If I use the exact same row with an other query it works.

 Apache, Mysql, mod_wsgi

 Version
 web2py Version 1.91.6 (2011-01-03 17:55:14)
 Python Python 2.6.5: /usr/bin/python
 Traceback

 Traceback (most recent call last):
 File /web2py/gluon/restricted.py, line 188, in restricted
 exec ccode in environment
 File /web2py/applications/kenneths/controllers/billing.py, line 353,
 in module
 File /web2py/gluon/globals.py, line 95, in lambda
 self._caller = lambda f: f()
 File /web2py/gluon/tools.py, line 2297, in f
 return action(*a, **b)
 File /web2py/applications/kenneths/controllers/billing.py, line 123,
 in create_bill
 bill_sub_items[item_id]['items'] = db(db.t_receipt_item.f_bill_item ==
 item_id).select()
 File /web2py/gluon/dal.py, line 4507, in select
 return self.db._adapter.select(self.query,fields,attributes)
 File /web2py/gluon/dal.py, line 1008, in select
 return self.parse(rows,self._colnames)
 File /web2py/gluon/dal.py, line 1220, in parse
 str(value)[:10].strip().split('-')]
 ValueError: need more than 1 value to unpack


[web2py] Re: A bug or am I doing something wrong

2011-01-15 Thread Massimo Di Pierro
This is not the right syntax for decimal. Should be

Field('f_total_sum_all', type='decimal(5,10)', label=T('Total Sum')),

decimal(precision,scale) same syntax as SQL.

On 26 joulu 2010, 23:16, Kenneth Lundström
kenneth.t.lundst...@gmail.com wrote:
 Aapche 2, wsgi, MySQL 5.0, web2py 1.91.4, python 2.6.5

 I have defined in my model:
 Field('f_total_sum_all', type='decimal',
 label=T('Total Sum')),

 Even floeat gives the same error. Only integer works.

 Version
 web2py Version 1.91.4 (2010-12-22 17:31:23)
 Python Python 2.6.5: /usr/bin/python

 Traceback (most recent call last):
 File /web2py/gluon/restricted.py, line 188, in restricted
 exec ccode in environment
 File /web2py/applications/kenneths/models/db_wizard.py, line 70, in
 module
 migrate=settings.migrate)
 File /web2py/gluon/dal.py, line 3321, in define_table
 polymodel=polymodel)
 File /web2py/gluon/dal.py, line 444, in create_table
 precision, scale = [int(x) for x in field.type[8:-1].split(',')]
 ValueError: invalid literal for int() with base 10: ''

 Error snapshot help Detailed traceback description

 type 'exceptions.ValueError'(invalid literal for int() with base 10: '')

 inspect attributes
 Exception instance attributes
 __setattr__ method-wrapper '__setattr__' of exceptions.ValueError object
 __reduce_ex__ built-in method __reduce_ex__ of exceptions.ValueError
 object
 __getslice__ method-wrapper '__getslice__' of exceptions.ValueError object
 __getitem__ method-wrapper '__getitem__' of exceptions.ValueError object
 __setstate__ built-in method __setstate__ of exceptions.ValueError object
 __getattribute__ method-wrapper '__getattribute__' of
 exceptions.ValueError object
 __str__ method-wrapper '__str__' of exceptions.ValueError object
 args (invalid literal for int() with base 10: '',)
 __reduce__ built-in method __reduce__ of exceptions.ValueError object
 __format__ built-in method __format__ of exceptions.ValueError object
 __class__ type 'exceptions.ValueError'
 __dict__ {}
 __delattr__ method-wrapper '__delattr__' of exceptions.ValueError object
 __subclasshook__ built-in method __subclasshook__ of type object
 __repr__ method-wrapper '__repr__' of exceptions.ValueError object
 __init__ method-wrapper '__init__' of exceptions.ValueError object
 __hash__ method-wrapper '__hash__' of exceptions.ValueError object
 __sizeof__ built-in method __sizeof__ of exceptions.ValueError object
 __doc__ 'Inappropriate argument value (of correct type).'
 __unicode__ built-in method __unicode__ of exceptions.ValueError object
 __new__ built-in method __new__ of type object
 Frames

 File /web2py/gluon/restricted.py in restricted at line 188 code
 arguments variables
 Function argument list

 (code=### we prepend t_ to tablenames and f_ to
 fieldn...Field('current_record','reference t_bill_item'))\n,
 environment={'A': class 'gluon.html.A', 'Auth': class
 'gluon.tools.Auth', 'B': class 'gluon.html.B', 'BEAUTIFY': class
 'gluon.html.BEAUTIFY', 'BODY': class 'gluon.html.BODY', 'BR': class
 'gluon.html.BR', 'CENTER': class 'gluon.html.CENTER', 'CLEANUP':
 class 'gluon.validators.CLEANUP', 'CODE': class 'gluon.html.CODE',
 'CRYPT': class 'gluon.validators.CRYPT', ...},
 layer='/web2py/applications/kenneths/models/db_wizard.py')
 Code listing

 if type(code) == types.CodeType:
 ccode = code
 else:
 ccode = compile2(code,layer)

 exec ccode in environment

 except HTTP:
 raise
 except Exception:
 # XXX Show exception in Wing IDE if running in debugger

 Variables
 environment {'A': class 'gluon.html.A', 'Auth': class
 'gluon.tools.Auth', 'B': class 'gluon.html.B', 'BEAUTIFY': class
 'gluon.html.BEAUTIFY', 'BODY': class 'gluon.html.BODY', 'BR': class
 'gluon.html.BR', 'CENTER': class 'gluon.html.CENTER', 'CLEANUP':
 class 'gluon.validators.CLEANUP', 'CODE': class 'gluon.html.CODE',
 'CRYPT': class 'gluon.validators.CRYPT', ...}
 ccode code object module at 0x2aaab001f6c0, file
 /...plications/kenneths/models/db_wizard.py, line 5
 *

 File /web2py/applications/kenneths/models/db_wizard.py in module at
 line 70 code arguments variables
 Function argument list

 ()
 Code listing

 label=T('Created By'),writable=False,readable=False),
 Field('modified_by',db.auth_user,default=auth.user_id,
 label=T('Modified By'),writable=False,readable=False,
 update=auth.user_id),
 format='%(f_name)s',
 migrate=settings.migrate)

 db.define_table('t_receipt_archive',db.t_receipt,Field('current_record','re 
 ference
 t_receipt'))

 

 Variables
 migrate undefined
 settings.migrate True
 settings Storage {'layout_theme': 'Clicker', 'subtitle':...l_server':
 'localhost', 'login_method': 'local'}
 *

 File /web2py/gluon/dal.py in define_table at line 3321 code arguments
 variables
 Function argument list

 (self=DAL {'auth_permission': Table {'ALL': gluon.d...ab0014c90},
 '_migrate': True, '_pool_size': 0}, tablename='t_receipt',
 *fields=(gluon.dal.Field object, gluon.dal.Field object,
 gluon.dal.Field object, gluon.dal.Field object, 

[web2py] problem with dal

2011-01-15 Thread luifran

db.define_table('actividades_riesgos',Field('actividades',db.actividades),Field('riesgos',db.riesgos))

actividad=db(db.actividades.nombre==request.args(0)).select(db.actividades.
id)
riesgo=db(db.riesgos.nombre==request.args(1)).select(db.riesgos.id)
record = db((db.actividades_riesgos.actividades==actividad) 
(db.actividades_riesgos.riesgos==riesgo)).select().first()

The last line show the next error:
TypeError: int() argument must be a string or a number, not 'Rows' //


[web2py] Re: Number of records

2011-01-15 Thread Rick
So the problem was that the controller file line creates an error when
I
add the 'id' field and 'migrate=False' to the day table. Here is some
more code:

===in the model file===
import datetime
now = datetime.date.today()
db.define_table('day',
Field('the_id', 'id'),
Field('thedate','date', default=request.now),
Field('value', 'integer'),
migrate=False)

===in the controller file===
records = db().select(db.day.ALL, orderby=db.day.thedate)

On Jan 15, 8:16 am, Kenneth Lundström kenneth.t.lundst...@gmail.com
wrote:
 Could you shows us the relevant part of your models file, where the
 table is defined and then also the error ticket.

 Kenneth







  Thanks for the suggestion! The 'id' field looks like a smart solution.
  But there seem to be a problem -- This line creates an error when I
  add the 'id' field and 'migrate=False' to the day table:
  records = db().select(db.day.ALL, orderby=db.day.thedate)
  Any ideas?

  On Jan 4, 4:03 am, Fabianofabianoeng...@gmail.com  wrote:
  What stops you from using 'id' field?


[web2py] Re: problem with dal

2011-01-15 Thread Massimo Di Pierro
perhaps

(db.actividades_riesgos.riesgos==riesgo)

should be

(db.actividades_riesgos.riesgos==riesgo.first().id)

On Jan 15, 5:24 am, luifran lbernalhernan...@yahoo.es wrote:
 db.define_table('actividades_riesgos',Field('actividades',db.actividades),F 
 ield('riesgos',db.riesgos))

 actividad=db(db.actividades.nombre==request.args(0)).select(db.actividades.
 id)
 riesgo=db(db.riesgos.nombre==request.args(1)).select(db.riesgos.id)
 record = db((db.actividades_riesgos.actividades==actividad) 
 (db.actividades_riesgos.riesgos==riesgo)).select().first()

 The last line show the next error:
 TypeError: int() argument must be a string or a number, not 'Rows' //


[web2py] Re: Number of records

2011-01-15 Thread Massimo Di Pierro
Virtual Fields do not help you here because they are computed when
records are extracted not when stored. virtual fields are not stored
at all.

The 'input' table already has an auto-increment id field. You cannot
gave two autoincrement ids. It is bad design and would slow the
database a lot.

You can do something like this:

import uuid
db.define_table('input',
         Field('number', 'string',
str(default=uuid.uuid4()),readable=False,writable=False),
         Field('value', 'integer'))

On Jan 2, 2:39 pm, Rick sababa.sab...@gmail.com wrote:
 Hi,
 In addition to the records that are submitted with a SQLFORM, I want
 to give each record a specific identification number, so that the
 first record has number=1 and so on:

 ==from model/db.py==
 db.define_table('input',
         Field('number', 'integer'),
         Field('value', 'integer'))

 ...My problem is that I don't know how to automatically add the number
 to this form:
 form = SQLFORM(db.input, fields=['value'])

 Thanks in advance for help.


[web2py] Re: About bugreports

2011-01-15 Thread Massimo Di Pierro
I went through the treads. I cannot quite identify a bug. some of the
issues are most likely be related to web2py and db models being out of
sync. Are you using a legacy table? Do you have migrate=False?

On Jan 14, 2:41 pm, Kenneth Lundström kenneth.t.lundst...@gmail.com
wrote:
 https://groups.google.com/group/web2py/browse_thread/thread/9e3e43b49...

 I m not sure this is a 
 bug.https://groups.google.com/group/web2py/browse_thread/thread/2300767db...

 https://groups.google.com/group/web2py/browse_thread/thread/226113dea...

 https://groups.google.com/group/web2py/browse_thread/thread/6ea777cd6...

 Here are those that was refering to. I ll use Google code if I get ticket.

 Kenneth

 Hi Kenneth,







  I apologize. A couple of them I bookmarked and I am working ont them.
  Yet I cannot find 3-4. Please open tickets on googlecode so I can keep
  track of them more easily. Thanks for your help.

  Massimo

  On Jan 13, 2:24 am, Kenneth Lundstr mkenneth.t.lundst...@gmail.com
  wrote:
  Hello everybody,

  for the past month I have sent maybe 3-4 bugreports to this list, but so
  far only 1 of them have been answered. It feels a litte bit stupid to
  send those reports without getting any responce. Am I sending them to
  the wrong place or are they so simple that I should be able to solve
  them myself?

  Maybe a bug?

  Should the underlying database and web2pys database model files be in
  sync? In one applications I have a table defined to have 14 fields. But
  if I look at att the table on database level it has 15 fields?

  A question. What is the correct way to remove a foreign key
  relationsship between two tables? If I in a model file define a field
  like Field('group', db.group, required=true) and then remove it I get a
  error telling that mysql could not remove the foreign key. So far I have
  deleted the whole database and deleted all files in /databases/ so
  web2py has created all tables again. It s not a problem on my
  development system, but might become a problem on the production server.

  Kenneth


[web2py] Re: problem with dal

2011-01-15 Thread luifran
 Thank you, I've fixed it with:
 actividad_id=actividad[0].id
 riesgo_id=riesgo[0].id

On 15 ene, 12:45, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 perhaps

 (db.actividades_riesgos.riesgos==riesgo)

 should be

 (db.actividades_riesgos.riesgos==riesgo.first().id)

 On Jan 15, 5:24 am, luifran lbernalhernan...@yahoo.es wrote:







  db.define_table('actividades_riesgos',Field('actividades',db.actividades),F 
  ield('riesgos',db.riesgos))

  actividad=db(db.actividades.nombre==request.args(0)).select(db.actividades.
  id)
  riesgo=db(db.riesgos.nombre==request.args(1)).select(db.riesgos.id)
  record = db((db.actividades_riesgos.actividades==actividad) 
  (db.actividades_riesgos.riesgos==riesgo)).select().first()

  The last line show the next error:
  TypeError: int() argument must be a string or a number, not 'Rows' //


[web2py] web2py as daemon

2011-01-15 Thread Martin Weissenboeck
Hi,
there is the file web2py.fedora.sh in web2py/scripts.
I want to use Python2.7 and I had to change some lines.
I have found that  and  must be escaped, python need the full path
(CentOS).
Changed from

ADMINPASS=recycle
...
PYTHON=python


to

ADMINPASS=*\*recycle*\*
...
PYTHON=*/usr/local/bin/*python*2.7*

Further I had to add these lines:


*CERTS=/etc/pki/tls/certs/localhost.crt*
*PRIVATE=/etc/pki/tls/private/localhost.key*
*IP=123.123.123.123*

This is the new main line in start()


 daemon --check $NAME $PYTHON $DAEMON_DIR/web2py.py -Q --nogui *\*
-a $ADMINPASS -d $PIDFILE -p $PORT *\*
*-c $CERTS -k $PRIVATE -i $IP* RETVAL=$?


And I had to chmod web2pyd.

*chmod 755 web2pyd*


I think there should be an additional comment in chapter 11.1.6.

Maybe these lines could be helpful.
Regards, Martin


[web2py] Test controller

2011-01-15 Thread walter
This is my code
def index():
form = SQLFORM(db.article)
if form.accepts(request.vars): response.flash = Статья добавлена

articles = db().select(db.article.ALL)
return dict(articles=articles, form=form)

I can't understand how to test index? How to test articles value for
example?


Re: [web2py] Re: Integrating web2py and a CMS

2011-01-15 Thread David Bain
I believe web2py can act as a CAS authentication server. If you CMS does CAS
then you're good. Maybe an easier place to start is to figure what CMSes out
there can authenticate against CAS.

2011/1/15 Kenneth Lundström kenneth.t.lundst...@gmail.com

 I was thinking about using web2py as the authentication platform as it
 holds the members database. Or then a LDAP that gets it information from
 members database.

 The intranet will hold a lot of information that should be visible on the
 website via the CMS. Either lots of small info (names, telephone numbers) or
 maybe whole pages. Could iframe be a way of displaying data from web2y on a
 webpage?


 Kenneth




  This kind of information is often stored in a corporate directory using
 something called LDAP. I am not sure of the size of your company but it
 sounds like it is large enough to consider this solution. There is OpenLDAP
 on Linux or Active Directory on Microsoft which perform this task as
 concrete examples of product. The web2py server has a contrib module for
 using LDAP authentication which is documented in the manual. Check if your
 CMS is capable of this as well.

 The web2py server has a very diverse set of authentication mechanisms such
 as SMTP server login etc. This would get you username and password in one
 location but not a hierarchy or org chart.

 Since the choice of CMS is unknown at this point it is difficult to tell
 if it is open enough to be able to refer to tables in the web2py portion of
 the infrastructure.

 A couple of ideas,
 Ron





[web2py] Re: Test controller

2011-01-15 Thread Massimo Di Pierro
for example:

def index():

 request.vars.update(title='xxx'
 assert(len(index()['articles'].find(r:r['title']=='xxx'))==1)
 db(db.article.title=='xxx').delete()
1

form = SQLFORM(db.article)
if form.accepts(request.vars): response.flash = óÔÁÔØÑ
ÄÏÂÁ×ÌÅÎÁ
articles = db().select(db.article.ALL)
return dict(articles=articles, form=form)


On Jan 15, 7:29 am, walter wdv...@gmail.com wrote:
 This is my code
 def index():
     form = SQLFORM(db.article)
     if form.accepts(request.vars): response.flash = óÔÁÔØÑ ÄÏÂÁ×ÌÅÎÁ

     articles = db().select(db.article.ALL)
     return dict(articles=articles, form=form)

 I can't understand how to test index? How to test articles value for
 example?


[web2py] Re: Integrating web2py and a CMS

2011-01-15 Thread Massimo Di Pierro
It can.

http://web2py.com/cas

On Jan 15, 9:13 am, David Bain pigeonfli...@gmail.com wrote:
 I believe web2py can act as a CAS authentication server. If you CMS does CAS
 then you're good. Maybe an easier place to start is to figure what CMSes out
 there can authenticate against CAS.

 2011/1/15 Kenneth Lundström kenneth.t.lundst...@gmail.com







  I was thinking about using web2py as the authentication platform as it
  holds the members database. Or then a LDAP that gets it information from
  members database.

  The intranet will hold a lot of information that should be visible on the
  website via the CMS. Either lots of small info (names, telephone numbers) or
  maybe whole pages. Could iframe be a way of displaying data from web2y on a
  webpage?

  Kenneth

   This kind of information is often stored in a corporate directory using
  something called LDAP. I am not sure of the size of your company but it
  sounds like it is large enough to consider this solution. There is OpenLDAP
  on Linux or Active Directory on Microsoft which perform this task as
  concrete examples of product. The web2py server has a contrib module for
  using LDAP authentication which is documented in the manual. Check if your
  CMS is capable of this as well.

  The web2py server has a very diverse set of authentication mechanisms such
  as SMTP server login etc. This would get you username and password in one
  location but not a hierarchy or org chart.

  Since the choice of CMS is unknown at this point it is difficult to tell
  if it is open enough to be able to refer to tables in the web2py portion of
  the infrastructure.

  A couple of ideas,
  Ron


[web2py] Re: Need Help Using CRUD with Self-Referencing Tables

2011-01-15 Thread SaltyCow
Thanks Savio, I created a clean app to test this out and it works
great. Regards. Jeff


On Jan 14, 12:28 pm, Savio Sabino savi...@gmail.com wrote:
 Hi, the follow model is rigth to crud:

 db.define_table('category',iObj,
     Field('parent','reference category'),
     Field('name'),
     format='%(name)s')
 db.category.parent.requires =  IS_EMPTY_OR(IS_IN_DB(db,
 db.category.id, '%(name)s'))
 db.category.name.requires = IS_NOT_IN_DB(db, db.category.name)

 No need of a custom crud.

 On 12 jan, 18:53, SaltyCow jeff.bienkow...@gmail.com wrote:







  Hello there...

  I'm hoping that this is a common problem with a simple solution.

  I'm attempting to create an app that uses self-referencing tables, in
  one case to refer to employees and their managers (who themselves are
  also employees). I used the app wizard to generate the scaffolding. I
  am able to add records, but the boilerplate crud read and crud select
  functions return the following error: Using a recursive select, but
  encountered a broken reference. Also, the form generated by the crud
  create function does not generate a drop-down selection box as it
  normally would for a reference field.

  So, my question is, really, do I need to write custom crud functions
  to work with self-referencing tables and, if so, does anyone know the
  best way to do this? I've read the part in the docs about using
  with_alias but I can't seem to make heads or tails of it. (Not a
  problem with the manual, just my limited knowledge of SQL.)

  I'd appreciate any further direction anyone can give me.

  Thanks...Jeff


[web2py] Re: issue with TAG and unicode

2011-01-15 Thread carlo
Another example, same strange error:

File C:\Python25\web2py\gluon\html.py, line 790, in xml
return '%s%s%s/%s' % (self.tag, fa, co, self.tag)

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
3: ordinal not in range(128)

Variables
fa  ''
selfgluon.html.__tag__ object at 0x018C2F10
self.tagu'titolo'
co  'pap\xc3\xa0'



Re: [web2py] Upload field

2011-01-15 Thread Arun K.Rajeevan
No, blob is optional, and it'll work well without specifying a blob field. 
(I use only upload and it works on GAE too)

[web2py] Re: Upload field

2011-01-15 Thread Arun K.Rajeevan
Are you trying to do manual upload?
I remember I got such an error a while back.  Can't recall exactly 
what happened that time. I'll let you know if I can recall. (My Hg repo., of 
that project is lost due to hdd malfunction :( )


[web2py] Re: ajax upload for components

2011-01-15 Thread weheh
Michele, I tried out your slice and it works great. Thanks! I think
the problem I was experiencing is that I had not changed ajax=True to
ajax=False in the LOAD function.

On Jan 10, 5:35 pm, Michele Comitini michele.comit...@gmail.com
wrote:
 I made a slice:

 http://web2pyslices.com/main/slices/take_slice/114

 mic

 2011/1/10 K.R.Arun the1.a...@gmail.com:

  Can you show me an example with file upload using jQuery form plugin?
  Michele Comitini wrote:
  sorry i have to repeat myself, use the following, it is working and it
  is simple:
 http://jquery.malsup.com/form/

  it does everything for you, and gives more control than 
  LOAD(...,ajax=True).

  mic
  2011/1/9 Massimo Di Pierro massimo.dipie...@gmail.com:

   On Jan 9, 2011, at 11:31 AM, Arun K.Rajeevan wrote:

   iframe works its own. I'm not a pro on javascript.
   May be there is a way in js to access parent document from within iframe.
   If there's so, you can write your own js code to update main page (which
   embeds iframe).

   yes there is. windows. parent
  http://developer.apple.com/internet/webcontent/iframe.html

   I can tell you one more suggestion.
   If the parts in the page to be uploaded after each upload is represented
   together in the document,
   you can redesign the page so that, upload form and parts to be updated
   are separated out to a component and load it into iframe.
   Since everything is within same scope (iframe) it'll work.
   Sorry, I'm not an expert to suggest a way (if part to be uploaded are
   scattered in the main document)
   (I'm pretty sure JS can do that.)  also you are not limited to use only
   uploadify there are others too.
   --
   mail from:GoogleGroups web2py-developers mailing list
   make speech: web2py-develop...@googlegroups.com
   unsubscribe: web2py-developers+unsubscr...@googlegroups.com
   details :http://groups.google.com/group/web2py-developers
   the project:http://code.google.com/p/web2py/
   official :http://www.web2py.com/

   --
   mail from:GoogleGroups web2py-developers mailing list
   make speech: web2py-develop...@googlegroups.com
   unsubscribe: web2py-developers+unsubscr...@googlegroups.com
   details :http://groups.google.com/group/web2py-developers
   the project:http://code.google.com/p/web2py/
   official :http://www.web2py.com/




Re: [web2py] Best practice for including python libraries with my app

2011-01-15 Thread Arun K.Rajeevan
I use site-packages directory to put external libraries.

Because, I tried gdata (google data ) library to put in app modules folder.
But it breaks on import, because, gdata module has no knowledge of 
local_import() and since they try to do imports with usual way, it'll break.

So, for complex libraries I suggest to put it in site-packages directory.
Make not of server version of python is supported by library you put in.



[web2py] Re: issue with TAG and unicode

2011-01-15 Thread carlo
ok narrowed down the problem, this IS working:

def index():
response.headers['Content-Type']='application/xml'
rows=[['6.0', u'pap\xe0', u'kloiuy', '1995.0']]
return export_xml(rows)


def export_xml(rows):
colnames=['prima','seconda','terza','quarta']
idx=range(len(colnames))
records=[]
for row in rows: records.append(TAG['record'](*[TAG[colnames[i]]
(row[i]) for i in idx]))
return str(TAG['records'](*records))

but this IS NOT working with Unicode error etc etc:

def index():
response.headers['Content-Type']='application/xml'
rows=[['6.0', u'pap\xe0', u'kloiuy', '1995.0']]
return export_xml(rows)


def export_xml(rows):
colnames=[u'prima',u'seconda',u'terza',u'quarta']
idx=range(len(colnames))
records=[]
for row in rows: records.append(TAG['record'](*[TAG[colnames[i]]
(row[i]) for i in idx]))
return str(TAG['records'](*records))


so the problem is with tag names..I will try to have a look at html.py
but your opinion is welcome.

carlo


[web2py] Re: Test controller

2011-01-15 Thread walter
I have another one question. How to interact with controller in shell?


Re: [web2py] Re: Number of records

2011-01-15 Thread Fabiano - deStilaDo
Why can' t you use the already pre-defined id field? You don't need to
define a new one, every table already has and and id field with name
id.


Fabiano.



On Sat, Jan 15, 2011 at 6:37 AM, Rick sababa.sab...@gmail.com wrote:
 So the problem was that the controller file line creates an error when
 I
 add the 'id' field and 'migrate=False' to the day table. Here is some
 more code:

 ===in the model file===
 import datetime
 now = datetime.date.today()
 db.define_table('day',
        Field('the_id', 'id'),
        Field('thedate','date', default=request.now),
        Field('value', 'integer'),
        migrate=False)

 ===in the controller file===
 records = db().select(db.day.ALL, orderby=db.day.thedate)

 On Jan 15, 8:16 am, Kenneth Lundström kenneth.t.lundst...@gmail.com
 wrote:
 Could you shows us the relevant part of your models file, where the
 table is defined and then also the error ticket.

 Kenneth







  Thanks for the suggestion! The 'id' field looks like a smart solution.
  But there seem to be a problem -- This line creates an error when I
  add the 'id' field and 'migrate=False' to the day table:
  records = db().select(db.day.ALL, orderby=db.day.thedate)
  Any ideas?

  On Jan 4, 4:03 am, Fabianofabianoeng...@gmail.com  wrote:
  What stops you from using 'id' field?


[web2py] Recommended links in web2py

2011-01-15 Thread blackthorne
hi

ok this is not a specific web2py problem but I intend to solve it
using web2py and I like you guys, so here it goes:

I have a DB with posts, links, comments and other interesting
contents.
These contents are generated from an App.
Let's say I use it to make a post.
It would be nice to have a smart system that would recommend similar /
related articles that could interest the reader in an autonomous way.
The author of the post could check those recommendations and edit
them, by putting something arbitrarly on top or by removing a wrong
suggestion but the system should be as autonomous as possible.

It could be based on tags, the content itself (lucene?), the title and
the search criteria would be partly shared by the search engine.

Suggestions for this? Technologies used? are there examples?

Thank you
Best regards


[web2py] web2py tutorial at PyCon 2011 - important

2011-01-15 Thread Massimo Di Pierro
If you are planning to attend, please sign up by next week.

Tutorials that do not meet a minimum numbers of attendees by next
week, will be cancelled.

Massimo


[web2py] Re: Best practice for including python libraries with my app

2011-01-15 Thread mart
weather you're looking to distribute or even just for your self, You
can always use Distribute. The learning curb isn't huge and has many
bultin features (i.e. find_packages() which you may find helpful
here).

ANyways, here a link.

http://packages.python.org/distribute/setuptools.html#id3

Mart :)

On Jan 15, 1:01 pm, Arun K.Rajeevan the1.a...@gmail.com wrote:
 I use site-packages directory to put external libraries.

 Because, I tried gdata (google data ) library to put in app modules folder.
 But it breaks on import, because, gdata module has no knowledge of
 local_import() and since they try to do imports with usual way, it'll break.

 So, for complex libraries I suggest to put it in site-packages directory.
 Make not of server version of python is supported by library you put in.


[web2py] Re: Output of sum(), simplifying the JSON

2011-01-15 Thread Michael Toomim
I find it easiest and cleanest to reformat data structures in python,
using list comprehensions.  Javascript sucks for loops.  So instead of
jsonifying the raw database output, fix it first:

export_optimizer_records = [{'FreezeTime': r.panel_1hrs.FreezeTime,
'StringID': r.panel_1hrs.StringID, 'Po_avg_sum':
r._extra['sum(panel_1hrs.Po_avg)']} for r in export_optimizer_records]

Basically, just add this line to your controller.

On Jan 14, 5:58 pm, Lorin Rivers lriv...@mosasaur.com wrote:
 Controller:
 export_optimizer_records = 
 dbset(db.table.FreezeTime,db.table.StringID,db.table.Po_avg.sum(),groupby=. 
 .FreezeTime|..StringID).as_list()

 View:
 var optimizerdata = {{response.write(json(export_optimizer_records), 
 escape=False)}};

 The JSON looks like this:

 [{
     panel_1hrs: {
         FreezeTime: 2010-12-12 19:00:00,
         StringID: S0001
     },
     _extra: {
         sum(panel_1hrs.Po_avg): 519.912549612443
     }},

 {
     panel_1hrs: {
         FreezeTime: 2010-12-12 19:00:00,
         StringID: S0002
     },
     _extra: {
         sum(panel_1hrs.Po_avg): 532.390706326218
     }

 }]

 What I want is this:

 [{
     FreezeTime: 2010-12-12 19:00:00,
     StringID: S0001,
     Po_avg_sum: 519.912549612443},

 {
     FreezeTime: 2010-12-12 19:00:00,
     StringID: S0002,
     Po_avg_sum: 532.390706326218        

 }]

 What's the easiest way to get that?
 --
 Lorin Rivers
 Mosasaur: Killer Technical Marketing http://www.mosasaur.com
 mailto:lriv...@mosasaur.com
 512/203.3198 (m)


[web2py] Re: Output of sum(), simplifying the JSON

2011-01-15 Thread Massimo Di Pierro
Mind that this is old syntax:

r._extra['sum(panel_1hrs.Po_avg)']

it is equivalent and better to use:

r[db.panel_1hrs.Po_avg.sum()]

On Jan 15, 2:29 pm, Michael Toomim too...@gmail.com wrote:
 I find it easiest and cleanest to reformat data structures in python,
 using list comprehensions.  Javascript sucks for loops.  So instead of
 jsonifying the raw database output, fix it first:

 export_optimizer_records = [{'FreezeTime': r.panel_1hrs.FreezeTime,
 'StringID': r.panel_1hrs.StringID, 'Po_avg_sum':
 r._extra['sum(panel_1hrs.Po_avg)']} for r in export_optimizer_records]

 Basically, just add this line to your controller.

 On Jan 14, 5:58 pm, Lorin Rivers lriv...@mosasaur.com wrote:







  Controller:
  export_optimizer_records = 
  dbset(db.table.FreezeTime,db.table.StringID,db.table.Po_avg.sum(),groupby=. 
  .FreezeTime|..StringID).as_list()

  View:
  var optimizerdata = {{response.write(json(export_optimizer_records), 
  escape=False)}};

  The JSON looks like this:

  [{
      panel_1hrs: {
          FreezeTime: 2010-12-12 19:00:00,
          StringID: S0001
      },
      _extra: {
          sum(panel_1hrs.Po_avg): 519.912549612443
      }},

  {
      panel_1hrs: {
          FreezeTime: 2010-12-12 19:00:00,
          StringID: S0002
      },
      _extra: {
          sum(panel_1hrs.Po_avg): 532.390706326218
      }

  }]

  What I want is this:

  [{
      FreezeTime: 2010-12-12 19:00:00,
      StringID: S0001,
      Po_avg_sum: 519.912549612443},

  {
      FreezeTime: 2010-12-12 19:00:00,
      StringID: S0002,
      Po_avg_sum: 532.390706326218        

  }]

  What's the easiest way to get that?
  --
  Lorin Rivers
  Mosasaur: Killer Technical Marketing http://www.mosasaur.com
  mailto:lriv...@mosasaur.com
  512/203.3198 (m)


[web2py] Re: web2py tutorial at PyCon 2011 - important

2011-01-15 Thread Anthony
Just signed up for the web2py tutorial. :)
 
Do it by Monday and save $50.
 
Anthony
 

On Saturday, January 15, 2011 3:00:47 PM UTC-5, Massimo Di Pierro wrote:

 If you are planning to attend, please sign up by next week. 

 Tutorials that do not meet a minimum numbers of attendees by next 
 week, will be cancelled. 

 Massimo



[web2py] Re: web2py tutorial at PyCon 2011 - important

2011-01-15 Thread Anthony
And here's the link to sign up: https://www.cteusa.com/pycon4/ (rates are 
shown here: http://us.pycon.org/2011/tickets/).
 
Note, the tutorials are separate from the main conference, so if you want 
you can attend one or more tutorials without paying for the full conference.
 

On Saturday, January 15, 2011 3:41:36 PM UTC-5, Anthony wrote:

 Just signed up for the web2py tutorial. :)
  
 Do it by Monday and save $50.
  
 Anthony
  

 On Saturday, January 15, 2011 3:00:47 PM UTC-5, Massimo Di Pierro wrote:

 If you are planning to attend, please sign up by next week. 

 Tutorials that do not meet a minimum numbers of attendees by next 
 week, will be cancelled. 

 Massimo



[web2py] dumping pickles (sqlite)

2011-01-15 Thread mart
Hi,

seems I used to be able to store pickles, and now ... well I can't...
Has the API changed or have we decided to against the practice (which
generally I may agree with) but...  I need those pickles in there  for
archive purposes, reproducibility and necessary references to them...
I store run time data into dict objects (like storage) which are built
up throughout build process (they are not static).

Anyways, there didn't seem to be any issues a short while ago (pre-
updated DAL), but now I get these infamous exceptions;

   .../dal.py, line 3431, in __getattr__
return dict.__getitem__(self,key)
KeyError: '__getstate__'



thanks,
Mart :)


[web2py] Re: dumping pickles (sqlite)

2011-01-15 Thread Massimo Di Pierro
I do not think anything has changed in this respect. Can you provide
an example of doe that worked and does not work anymore?

Massimo

On Jan 15, 3:29 pm, mart msenecal...@gmail.com wrote:
 Hi,

 seems I used to be able to store pickles, and now ... well I can't...
 Has the API changed or have we decided to against the practice (which
 generally I may agree with) but...  I need those pickles in there  for
 archive purposes, reproducibility and necessary references to them...
 I store run time data into dict objects (like storage) which are built
 up throughout build process (they are not static).

 Anyways, there didn't seem to be any issues a short while ago (pre-
 updated DAL), but now I get these infamous exceptions;

                    .../dal.py, line 3431, in __getattr__
     return dict.__getitem__(self,key)
 KeyError: '__getstate__'

 thanks,
 Mart :)


[web2py] Re: account for each user

2011-01-15 Thread Rick
Thanks for the replies. My problem is that with the code I can create
one account for all users, but I want to create one account for each
user.

On Jan 4, 1:14 am, Martín Mulone mulone.mar...@gmail.com wrote:
 Commonly in internet, the users create their accounts,  via
 (/myapp/default/user/register/)

 But if you want to create some accounts take a look to this:

 def new_user(first_name, last_name, email, passw):

         users = db(db.auth_user.email==email).select()
         if users:
             return users[0].id
         else:
             my_crypt = CRYPT(key=auth.settings.hmac_key)
             crypt_pass = my_crypt(passw)[0]
             id_user= db.auth_user.insert(
                                        first_name=first_name,
                                        last_name=last_name,
                                        email = email,
                                        password = crypt_pass

                                        )
             return id_user

 iduser = new_user('Chris','Mills','ch...@nobody.com','somepasswordhere')

 2011/1/3 mdipierro mdipie...@cs.depaul.edu:









  I do not understand the question.sorry.

  On Jan 3, 3:46 pm, Rick sababa.sab...@gmail.com wrote:
  Hi,

  I suppose that this is a very elementary question, but I can't find
  the solution. My question is -- how to make a account for each user?

  I've tried with this code, but it gives just one account for all user:

  ==on the model file==
  db.define_table(
     auth.settings.table_user_name,
     Field('username'),
     Field('password'),
     Field('registration_key', default=''))
  auth.define_tables()
  custom_auth_table = db[auth.settings.table_user_name] # get the
  custom_auth_table
  db.define_table('day',
         Field('person', db[auth.settings.table_user_name]),
         Field('thedate','date'),
         Field('value', 'integer'))

  ==in a controller file==
  @auth.requires_login()
  def create():
         some code

  def user():
     return dict(form=auth())

 --
 My blog:http://martin.tecnodoc.com.ar
 My portfolio *spanish*:http://www.tecnodoc.com.ar
 Checkout my last proyect instant-press:http://www.instant2press.com
 Expert4Solution Profile:http://www.experts4solutions.com/e4s/default/expert/6


[web2py] Recommended links in web2py

2011-01-15 Thread pbreit
Recommendation engines are relatively difficult to build. I think you are on 
the right track starting with some simple, manual recommendations. You might 
also look at something like Easyrec.


[web2py] Re: web2py tutorial at PyCon 2011 - important

2011-01-15 Thread Massimo Di Pierro
I will personally reimburse $70 to the first 5 attendees from this
list who sign up for the web2py tutorial, if they sign up by next week
and email me a proof of registration.

Plus everybody who registers within Feb 9 will get a free copy of the
printed book.

Massimo

On Jan 15, 2:49 pm, Anthony abasta...@gmail.com wrote:
 And here's the link to sign up:https://www.cteusa.com/pycon4/(rates are
 shown here:http://us.pycon.org/2011/tickets/).

 Note, the tutorials are separate from the main conference, so if you want
 you can attend one or more tutorials without paying for the full conference.







 On Saturday, January 15, 2011 3:41:36 PM UTC-5, Anthony wrote:
  Just signed up for the web2py tutorial. :)

  Do it by Monday and save $50.

  Anthony

  On Saturday, January 15, 2011 3:00:47 PM UTC-5, Massimo Di Pierro wrote:

  If you are planning to attend, please sign up by next week.

  Tutorials that do not meet a minimum numbers of attendees by next
  week, will be cancelled.

  Massimo


[web2py] Re: dumping pickles (sqlite)

2011-01-15 Thread mart
hi, yes I can... I'll send you both snippets (although i think they
are the same, (but I'll do a diff)... although I just found this in
copy_reg:

except AttributeError:
if getattr(self, __slots__, None):
raise TypeError(a class that defines __slots__ without 
defining __getstate__ cannot be pickled)

so, I should have never been able to?

I'll gather the the snippets in a little while when the twins get
tired if pulling me away (loudly and insistantly) ;) - my nerves can't
take the stereo output ;)

Thanks :)


On Jan 15, 5:28 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 I do not think anything has changed in this respect. Can you provide
 an example of doe that worked and does not work anymore?

 Massimo

 On Jan 15, 3:29 pm, mart msenecal...@gmail.com wrote:







  Hi,

  seems I used to be able to store pickles, and now ... well I can't...
  Has the API changed or have we decided to against the practice (which
  generally I may agree with) but...  I need those pickles in there  for
  archive purposes, reproducibility and necessary references to them...
  I store run time data into dict objects (like storage) which are built
  up throughout build process (they are not static).

  Anyways, there didn't seem to be any issues a short while ago (pre-
  updated DAL), but now I get these infamous exceptions;

                     .../dal.py, line 3431, in __getattr__
      return dict.__getitem__(self,key)
  KeyError: '__getstate__'

  thanks,
  Mart :)


[web2py] Re: account for each user

2011-01-15 Thread pbreit
I may not understand either. The user authentication functionality is 
automatically provided by web2py scaffolding. I would suggest using it without 
modifications until you run into limitations.


[web2py] Re: web2py tutorial at PyCon 2011 - important

2011-01-15 Thread mart
is there web conferencing?if yes, then it probably means free access
to the online version of the book? :)

On Jan 15, 5:47 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 I will personally reimburse $70 to the first 5 attendees from this
 list who sign up for the web2py tutorial, if they sign up by next week
 and email me a proof of registration.

 Plus everybody who registers within Feb 9 will get a free copy of the
 printed book.

 Massimo

 On Jan 15, 2:49 pm, Anthony abasta...@gmail.com wrote:







  And here's the link to sign up:https://www.cteusa.com/pycon4/(ratesare
  shown here:http://us.pycon.org/2011/tickets/).

  Note, the tutorials are separate from the main conference, so if you want
  you can attend one or more tutorials without paying for the full conference.

  On Saturday, January 15, 2011 3:41:36 PM UTC-5, Anthony wrote:
   Just signed up for the web2py tutorial. :)

   Do it by Monday and save $50.

   Anthony

   On Saturday, January 15, 2011 3:00:47 PM UTC-5, Massimo Di Pierro wrote:

   If you are planning to attend, please sign up by next week.

   Tutorials that do not meet a minimum numbers of attendees by next
   week, will be cancelled.

   Massimo


[web2py] Re: account for each user

2011-01-15 Thread Rick
Perhaps I should reformulate the problem -- I want to make one table
for each auth-user, so that an auth-user can't see the records of
ohters auth-users.

On Jan 15, 11:52 pm, pbreit pbreitenb...@gmail.com wrote:
 I may not understand either. The user authentication functionality is 
 automatically provided by web2py scaffolding. I would suggest using it 
 without modifications until you run into limitations.


[web2py] Re: ajax upload for components

2011-01-15 Thread weheh
Actually, on closer inspection, this is not working just right. It
seems as if the component form is not getting refreshed after pressing
the submit button. I expected that the form would self submit.


[web2py] representing custom aliases to generate RSS feeds from generic tables

2011-01-15 Thread blackthorne
if you have an RSS feed generator like this:

def feed():
w = db.plugin_wiki_page
return db(w.active==True)
(w.public==True).select(orderby=w.created_on).as_list()

it won't work for plugin_wiki_pages out of the box because it doesn't
respect the RSS format, being:
dict(title=my feed,
link=http://feed.example.com;,
description=my first feed,
entries=[dict('title', 'link', 'created_on', 'description'),...]

It could be great if I could generate adapt the db().select() field
names returned by the query from the db.plugin_wiki_page table so that
I could easily match the contents in the entries dict without having
to fully regenerate it as a list of dicts to all existing pages.

The answer to this questions may be interesting to anyone that wants
to have RSS feeds attached to any table.

Thank you,
Best regards


[web2py] Re: account for each user

2011-01-15 Thread Rick
...or maybe the problem lies int this function in the controller file:
def admin():
records = db().select(custom_auth_table.ALL,
orderby=custom_auth_table.username)
form = SQLFORM(db[auth.settings.table_user_name])
if form.accepts(request.post_vars, session):
session.flash = 'saved.'
redirect(URL('admin'))
return dict(form=form, records=records)

On Jan 16, 1:08 am, Rick sababa.sab...@gmail.com wrote:
 Perhaps I should reformulate the problem -- I want to make one table
 for each auth-user, so that an auth-user can't see the records of
 ohters auth-users.

 On Jan 15, 11:52 pm, pbreit pbreitenb...@gmail.com wrote:







  I may not understand either. The user authentication functionality is 
  automatically provided by web2py scaffolding. I would suggest using it 
  without modifications until you run into limitations.


[web2py] Re: dumping pickles (sqlite)

2011-01-15 Thread mart

In both versions, the following DAL activity is identical. But is
failing with the new DAL (the 1st was with sql.py, the 2nd with the
new dal.py. I just realized while copying and pasting that you have
the full file (was attached in an email and called _blue.py). The 2
type of objects that are failing are xml etree and dfo (dfo is like
storage but starts by converting etree to dict object and the other
way around). the dfo.py file has not changed in over a year. There a
huge difference between the file I sent you and today but not the
chunk of code below. all those objects are derived from an xml file
which which triggers a build when submitted. They all do their jobs
while the process is running, but the automation can't insert/update
to the DB with those lines of code below.

I could send more modules if it can shed light. Oh, and one last
thing, the web isn't part of this process. Strictly script which uses
dal + some gluon modules. the web comes after the build. And its at
that time that those objects get used the most (I.e. QA finds the
reports they want by doing (//
reportsServer.root.folderStructure.reports.aReportFile.html)

Anyways, if you have any thoughts, it would be great.

Thanks for taking a look :)


dfo_main =
self.dfo_builder.dictOjectFunctionWrapper(self.dfo_builder.build._main_)
etree_main = self.convert2EtreeByTagName('_main_')

id =
self.db.buildData.insert(cumulativeProps=cPickle.dumps(_cumulativeProperties))
 
self.db(self.db.buildData.id==id).update(dfo_builder=cPickle.dumps(self.dfo_builder))
 
self.db(self.db.buildData.id==id).update(dfo_builtIn=cPickle.dumps(self.dfo_builtIn))
 
self.db(self.db.buildData.id==id).update(dfo_main=cPickle.dumps(dfo_main))
 
self.db(self.db.buildData.id==id).update(etree_builtIn=cPickle.dumps(self.etree_builtIn))
 
self.db(self.db.buildData.id==id).update(etree_builder=self.etree_builder)
 
self.db(self.db.buildData.id==id).update(etree_main=etree_main)
 
self.db(self.db.buildData.id==id).update(etree_builder=cPickle.dumps(self.etree_builder))
 
self.db(self.db.buildData.id==id).update(etree_main=cPickle.dumps(etree_main))
self.db.commit()

On Jan 15, 5:28 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 I do not think anything has changed in this respect. Can you provide
 an example of doe that worked and does not work anymore?

 Massimo

 On Jan 15, 3:29 pm, mart msenecal...@gmail.com wrote:







  Hi,

  seems I used to be able to store pickles, and now ... well I can't...
  Has the API changed or have we decided to against the practice (which
  generally I may agree with) but...  I need those pickles in there  for
  archive purposes, reproducibility and necessary references to them...
  I store run time data into dict objects (like storage) which are built
  up throughout build process (they are not static).

  Anyways, there didn't seem to be any issues a short while ago (pre-
  updated DAL), but now I get these infamous exceptions;

                     .../dal.py, line 3431, in __getattr__
      return dict.__getitem__(self,key)
  KeyError: '__getstate__'

  thanks,
  Mart :)


[web2py] Re: account for each user

2011-01-15 Thread Rick
Hurray, I'm getting somewhere now! Thanks pbreit, now I try to do what
I want to do without modifying the authentication functionality and it
works better. But I get the message invalid function when I try to
login. Here is the code:

===in the model file===
auth = Auth(globals(), db)
auth.define_tables(username=True)

===in the controller file===
def users():
return users[0].id

def admin():
records = db().select(auth.settings.table_user.ALL,
orderby=auth.settings.table_user.username)
form = SQLFORM(auth.settings.table_user,
fields=['username','password'],)
if form.accepts(request.post_vars, session):
session.flash = 'Address saved.'
redirect(URL('admin'))
return dict(form=form, records=records)

===in user.html===
{{extend 'layout.html'}}
h2{{=request.args(0).replace('_',' ').capitalize()}}/h2
{{=form}}
{{if request.args(0)=='login':}}
{{pass}}


On Jan 16, 3:24 am, Rick sababa.sab...@gmail.com wrote:
 ...or maybe the problem lies int this function in the controller file:
 def admin():
         records = db().select(custom_auth_table.ALL,
 orderby=custom_auth_table.username)
         form = SQLFORM(db[auth.settings.table_user_name])
         if form.accepts(request.post_vars, session):
                 session.flash = 'saved.'
                 redirect(URL('admin'))
         return dict(form=form, records=records)

 On Jan 16, 1:08 am, Rick sababa.sab...@gmail.com wrote:







  Perhaps I should reformulate the problem -- I want to make one table
  for each auth-user, so that an auth-user can't see the records of
  ohters auth-users.

  On Jan 15, 11:52 pm, pbreit pbreitenb...@gmail.com wrote:

   I may not understand either. The user authentication functionality is 
   automatically provided by web2py scaffolding. I would suggest using it 
   without modifications until you run into limitations.


[web2py] Re: ajax upload for components

2011-01-15 Thread weheh
Aha, finally got this thing to work completely. My comments have been
added to Michelle's slice.

On Jan 15, 8:06 pm, weheh richard_gor...@verizon.net wrote:
 Actually, on closer inspection, this is not working just right. It
 seems as if the component form is not getting refreshed after pressing
 the submit button. I expected that the form would self submit.


[web2py] Re: dumping pickles (sqlite)

2011-01-15 Thread mart
I works now (sort of) but i still have the issue (sort of)..

In the version that works, I create a one time reference obj, then use
it by running through its dict structure. This can be pickled and put
into a table with the older DAL, but not with the new:

   dfo_objCmd =
self.dfo_builder.dictOjectFunctionWrapper(cmdDFO)


Now, I tried something different. I use the same same object, but set
a new root (like setting a new root from an existing xml object). This
can be pickled and put into a table... I don't know why this works,
but it does.

...cmd

for item in self.dfo_builder.build.cmd_init_:
if item.cmdName == cmd :
dfo_objCmd = item.cmdName


So, turns out, I need to apologies for pointing the finger @ DAL...
This has to be something on my side. So, apologies for the ruckus and
for not looking deeper into this sooner.

And thanks for taking the time

Mart :)








On Jan 15, 10:16 pm, mart msenecal...@gmail.com wrote:
 In both versions, the following DAL activity is identical. But is
 failing with the new DAL (the 1st was with sql.py, the 2nd with the
 new dal.py. I just realized while copying and pasting that you have
 the full file (was attached in an email and called _blue.py). The 2
 type of objects that are failing are xml etree and dfo (dfo is like
 storage but starts by converting etree to dict object and the other
 way around). the dfo.py file has not changed in over a year. There a
 huge difference between the file I sent you and today but not the
 chunk of code below. all those objects are derived from an xml file
 which which triggers a build when submitted. They all do their jobs
 while the process is running, but the automation can't insert/update
 to the DB with those lines of code below.

 I could send more modules if it can shed light. Oh, and one last
 thing, the web isn't part of this process. Strictly script which uses
 dal + some gluon modules. the web comes after the build. And its at
 that time that those objects get used the most (I.e. QA finds the
 reports they want by doing (//
 reportsServer.root.folderStructure.reports.aReportFile.html)

 Anyways, if you have any thoughts, it would be great.

 Thanks for taking a look :)

         dfo_main =
 self.dfo_builder.dictOjectFunctionWrapper(self.dfo_builder.build._main_)
         etree_main = self.convert2EtreeByTagName('_main_')

         id =
 self.db.buildData.insert(cumulativeProps=cPickle.dumps(_cumulativePropertie 
 s))

 self.db(self.db.buildData.id==id).update(dfo_builder=cPickle.dumps(self.dfo 
 _builder))

 self.db(self.db.buildData.id==id).update(dfo_builtIn=cPickle.dumps(self.dfo 
 _builtIn))

 self.db(self.db.buildData.id==id).update(dfo_main=cPickle.dumps(dfo_main))

 self.db(self.db.buildData.id==id).update(etree_builtIn=cPickle.dumps(self.e 
 tree_builtIn))

 self.db(self.db.buildData.id==id).update(etree_builder=self.etree_builder)

 self.db(self.db.buildData.id==id).update(etree_main=etree_main)

 self.db(self.db.buildData.id==id).update(etree_builder=cPickle.dumps(self.e 
 tree_builder))

 self.db(self.db.buildData.id==id).update(etree_main=cPickle.dumps(etree_mai 
 n))
         self.db.commit()

 On Jan 15, 5:28 pm, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:







  I do not think anything has changed in this respect. Can you provide
  an example of doe that worked and does not work anymore?

  Massimo

  On Jan 15, 3:29 pm, mart msenecal...@gmail.com wrote:

   Hi,

   seems I used to be able to store pickles, and now ... well I can't...
   Has the API changed or have we decided to against the practice (which
   generally I may agree with) but...  I need those pickles in there  for
   archive purposes, reproducibility and necessary references to them...
   I store run time data into dict objects (like storage) which are built
   up throughout build process (they are not static).

   Anyways, there didn't seem to be any issues a short while ago (pre-
   updated DAL), but now I get these infamous exceptions;

                      .../dal.py, line 3431, in __getattr__
       return dict.__getitem__(self,key)
   KeyError: '__getstate__'

   thanks,
   Mart :)


[web2py] Re: Apache, Wsgi problem

2011-01-15 Thread VP
To follow up on this issue, I think it might be related to db and/or
DAL.

+ I don't think it relates to exhausting RAM or too many open files.
Using lsof to monitor open files during stress test, with 200
concurrent channels (ab), I witnessed up to 11,000 open files (most
are apache2).  There are several dozens of failed requests, causing by
premature end of script wsgi.  What is interesting is that I was
able to cause these errors even with only 20 concurrent channels (with
only about 3000-4000 open files).  This is under postgres.

+ I could not cause the error with sqlite or on a page (controller)
that has only 1 db call.

+ How was I able to cause this error with only 20 concurrent
channels?   First, I observed that ab is quite simple in that it hits
the same page again and again.  So I wanted a more realistic test
(with more complex behavior).  Without any other tools, I decided to
do 2 things simultaneously: (1) ab with 20 concurrent channels, and
(2) manually (ajax) search for items using the search form on the
website; search will perform several db queries which ab does not.

Well, the result is that there were several failed requests (resulting
from this error) even with only 20 concurrent channels (which is
ridiculous).

+ Another anecdote.  I myself experienced this error a number of times
while using normally the app (not a result of stress test).  Once the
error occurred, apache failed to serve the page, of course.  What I
observed is that when I immediately reload the page, it loads up again
very quickly (as normally the case).   What this tells me is that the
cause of this wsgi error is probably  NOT because of the exhaustion of
some type of resources (RAM, or opening files, etc.); because that
lacking resources was the cause, then there would be some time for the
resources to be recovered before the page would quickly be served
again.


This issue is annoying.  Crashing like this is not pleasant from
users' point of view.  It's clearly related to scalability of web2py.
I hope there's an answer to this soon.


Here's a typical output of ab with 20 concurrent connections showing
failed requests.


Finished 254 requests


Server Software:Apache/2.2.9
Server Port:80

Document Path:  /
Document Length:10133 bytes

Concurrency Level:  20
Time taken for tests:   10.045 seconds
Complete requests:  254
Failed requests:15
   (Connect: 0, Receive: 0, Length: 15, Exceptions: 0)
Write errors:   0
Non-2xx responses:  15
Keep-Alive requests:239
Total transferred:  2558415 bytes
HTML transferred:   2448532 bytes
Requests per second:25.29 [#/sec] (mean)
Time per request:   790.914 [ms] (mean)
Time per request:   39.546 [ms] (mean, across all concurrent
requests)
Transfer rate:  248.74 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:06  16.1  0  56
Processing:   121  748 592.96314312
Waiting:  120  688 589.95664243
Total:121  755 603.86314365

Percentage of the requests served within a certain time (ms)
  50%631
  66%710
  75%772
  80%804
  90%   1670
  95%   1893
  98%   2788
  99%   3929
 100%   4365 (longest request)






[web2py] Re: account for each user

2011-01-15 Thread pbreit
Hmm...still not quite sure what you're looking for. It's unlikely you want 
separate tables for separate users. By default, users cannot access records 
of other users. The built-in Web2py Access Control features may already do 
what you are looking for.

[web2py] prevent post on reload

2011-01-15 Thread weheh
Anyone know how to prevent posting on reload? Right after submitting a
form, if I reload, I'm always asked whether or not I want to re-post
the previous form values. Is there a way to override this behavior?
It's probably not a web2py issue, but maybe I'll get lucky ...


Re: [web2py] prevent post on reload

2011-01-15 Thread Robby O'Connor
I believe (somebody can correct me if i'm wrong) that this is a browser 
issue.

On 1/16/2011 2:22 AM, weheh wrote:

Anyone know how to prevent posting on reload? Right after submitting a
form, if I reload, I'm always asked whether or not I want to re-post
the previous form values. Is there a way to override this behavior?
It's probably not a web2py issue, but maybe I'll get lucky ...