[web2py] Re: Self Referential references in models not getting id decoded automatically

2012-02-05 Thread Mark Kirkwood
Ok figured out what was causing that - I had one record with '0' for a 
sire_id and no dog with id = 0. Fixing that up makes the representation 
code below work. Yay! *But*... now the edit drop down list is showing 
id's instead of names... scratches head I'm sure that *was* working 
before


I even redid the example from scratch and...still seeing id's instead of 
names in edit mode. Blast need to try again tomorrow and see if I can 
sort that.  Well at least figured out one of the problems!


On 05/02/12 15:51, Mark Kirkwood wrote:



However that brings back a header 'dog.name' that mucks up the 
appearance of the form. What I wanted to write was:


db.dog.sire_id.represent = lambda sire_id, row: db.dog(sire_id).name 
if sire_id != None else None


However that produces:

AttributeError: 'NoneType' object has no attribute 'name'

Which stumps me I must say, since I can clearly see a 'name:' entry 
displayed if I just leave off the '.name' in the code above...






[web2py] Re: Debugging in web2py

2012-02-05 Thread Web2Py Freak
i am trying to use wing but how can i use it on a application that is
deployed on apache


[web2py] Anyone deployed web2py on 1and1 shared hosting?

2012-02-05 Thread Edward Shave
If so, would appreciate any pointers. I'm a beginner with little or no 
experience and don't know where to start... :o)


[web2py] Re: lungo.js

2012-02-05 Thread Oli
we should have a mobile solution for web2py out of the box. Would this be 
possible?

[web2py] web2py + twitter bootstrap 2.0

2012-02-05 Thread sungchi
service like reddit(korean) : http://www.feed9.com/
source : https://github.com/sungchi/feed9

Thank you web2py,
Thank you twitter !


[web2py] Re: web2py + twitter bootstrap 2.0

2012-02-05 Thread sungchi
most prominent changes of twitter bootstrap 2.0 :

New 12-column, responsive grid system
New table styles with a common base class for improved compatibility
with other tools
New form styles with smarter defaults, requiring less HTML
Icons, graciously provided by Glyphicons
New, smarter navigation components
New buttons, button groups, and button dropdowns
New, simpler alert messages
New javascript plug-ins like carousel, collapse, and typeahead

http://twitter.github.com/bootstrap/

On 2월5일, 오후7시52분, sungchi sungc...@gmail.com wrote:
 service like reddit(korean) :http://www.feed9.com/
 source :https://github.com/sungchi/feed9

 Thank you web2py,
 Thank you twitter !


Re: [web2py] Re: lungo.js

2012-02-05 Thread Carlos Costa
+1

2012/2/5 Oli oliver.fr...@gmx.net:
 we should have a mobile solution for web2py out of the box. Would this be
 possible?



-- 
Carlos J. Costa
Cientista da Computação
Esp. Gestão em Telecom

EL MELECH NEEMAN!
אָמֵן


[web2py] Transparently convert request.vars into unicode strings

2012-02-05 Thread Vladimir Rutsky
Hello!

What is the best way to transparently convert all variables in
request.post_vars to Python unicode strings?

When I submit string with non-ascii characters using AJAX from browser
to web2py application I receive usual Python 2.6 string (str) in
request.post_vars.foo with submitted string encoded in UTF-8. I thing
encoding of request.post_vars.foo string depends on encoding specified
in client browser, so I can't always do
unicode(request.post_vars.foo, 'utf-8'). Also submitted string can
be non-valid unicode string, so this should be checked either.


Thanks in advance,

Vladimir Rutsky


Re: [web2py] Transparently convert request.vars into unicode strings

2012-02-05 Thread Bruno Rocha
On Sun, Feb 5, 2012 at 11:26 AM, Vladimir Rutsky
rutsky.vladi...@gmail.comwrote:

 unicode(request.post_vars.foo, 'utf-8')


Use dictionary comprehension, in models 0.py do:

from gluon.storage import Storage

 request.post_vars = Storage({key: unicode(value, 'utf-8') for key, value
 in request.post_vars.items()})


-- 

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


[web2py] Re: Transparently convert request.vars into unicode strings

2012-02-05 Thread Alan Etkin
Perhaps web2py must retrieve the client's charset and convert
accordingly the input, as the framework uses UTF-8 internally. If
web2py expects always UTF-8, this could be reported as an issue. The
server response could also be re-converted for client's compatibility.

On 5 feb, 10:26, Vladimir Rutsky rutsky.vladi...@gmail.com wrote:
 Hello!

 What is the best way to transparently convert all variables in
 request.post_vars to Python unicode strings?

 When I submit string with non-ascii characters using AJAX from browser
 to web2py application I receive usual Python 2.6 string (str) in
 request.post_vars.foo with submitted string encoded in UTF-8. I thing
 encoding of request.post_vars.foo string depends on encoding specified
 in client browser, so I can't always do
 unicode(request.post_vars.foo, 'utf-8'). Also submitted string can
 be non-valid unicode string, so this should be checked either.

 Thanks in advance,

 Vladimir Rutsky


[web2py] Re: BrowserID web2py authentication plugin done! Please test

2012-02-05 Thread Alan Etkin
Congratulations. I tried to open the url of the project and it returns
a 404 error.

On 4 feb, 12:54, whowhywhat mads...@gmail.com wrote:
 Dear Web2py community,
 I just finished writing a web2py authentication plugin (custom
 authentication) to authenticate using BrowserID accounts (https://
 browserid.org). BrowserID is a project by Mozilla Labs
 (mozillalabs.org). It aims to provide a de-centralized, free, easy to
 use authentication method.
 BrowserID provides a nice alternative (or used side by side) to RPX,
 loginza, openID etc. personally, i feel BrowserIDs advantage is that
 you can use any email id verified by BrowserID.
 You can view the code here (https://code.google.com/p/browserid-web2py-
 plugin/source/browse/browserid_account.py).
 The browserid_account.py file needs to be in the gluon/contrib/
 login_methods/ folder. Usage is given in the doc string.

 Would love to hear your thoughts on BrowserID ..

 I have tested the plugin, everything seems to be working fine. Please
 test, look at the code and give me feedback, critique etc.. :). Please
 tell me if I am doing something wrong (security etc)

 Massimo I will email the patch to you in a few minutes.


[web2py] Re: Anyone deployed web2py on 1and1 shared hosting?

2012-02-05 Thread Alan Etkin
The web2py book's 13.1.8 section has information to install web2py in
shared hostings with apache and mod_python

On 5 feb, 07:07, Edward Shave ed.sh...@eshavefindings.co.uk wrote:
 If so, would appreciate any pointers. I'm a beginner with little or no
 experience and don't know where to start... :o)


Re: [web2py] Re: bug ticket for IS_IN_DB validator

2012-02-05 Thread Manuele Pesenti

Il 05/02/2012 03:16, DenesL ha scritto:

In the issue report you say:

What steps will reproduce the problem?
1. create a table (for example: db.define.table('mytab',
Field('foo')))
...
 IS_IN_DB(db, 'mytab.id', '%(foo)s', multiple=True)(value)

but IS_IN_DB(..., multiple=True) should be used for field type
list:reference as discussed in Chapter 6 of the book, but mytab.id
type is reference, not list:reference.

Hi Danes,

Yes you're right but It's not necessary to define another table with a 
list:reference field to test the validator while I can directly call the 
validator. Anyway I got the problem using the method 
validate_and_update for a field of type list:reference but the same 
list passed to the simple update method worked fine.
In my example I immagine to use a list:reference field without an 
explicit definition... I don't think it's a problem. I thought to better 
focus on the problem with this example, but maybe I wouldn't be so clear.


well I can say a little more... actually I have used in my project the 
definition of a list:reference field and everything works fine through 
the web interface where I can insert, upgrade, delete and so on even 
after the code modification I proposed in the issue.


Thanks for your attention

Cheers

Manuele


Re: [web2py] lungo.js

2012-02-05 Thread Bruno Rocha
looks much better than Jquery mobile, and simple to implement.

Thanks for sharing it!

On Fri, Feb 3, 2012 at 2:53 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 http://www.lungojs.com/




-- 

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


[web2py] Re: web2py + twitter bootstrap 2.0

2012-02-05 Thread Massimo Di Pierro
Rally Nice.


On Feb 5, 4:58 am, sungchi sungc...@gmail.com wrote:
 most prominent changes of twitter bootstrap 2.0 :

 New 12-column, responsive grid system
 New table styles with a common base class for improved compatibility
 with other tools
 New form styles with smarter defaults, requiring less HTML
 Icons, graciously provided by Glyphicons
 New, smarter navigation components
 New buttons, button groups, and button dropdowns
 New, simpler alert messages
 New javascript plug-ins like carousel, collapse, and typeahead

 http://twitter.github.com/bootstrap/

 On 2월5일, 오후7시52분, sungchi sungc...@gmail.com wrote:







  service like reddit(korean) :http://www.feed9.com/
  source :https://github.com/sungchi/feed9

  Thank you web2py,
  Thank you twitter !


[web2py] Re: web2py + twitter bootstrap 2.0

2012-02-05 Thread Massimo Di Pierro
You you be able to add a README to the github page with a screenshot
and a link to feed9?


On Feb 5, 4:52 am, sungchi sungc...@gmail.com wrote:
 service like reddit(korean) :http://www.feed9.com/
 source :https://github.com/sungchi/feed9

 Thank you web2py,
 Thank you twitter !


Re: [web2py] validator for valid SQL table name

2012-02-05 Thread Manuele Pesenti

Il 03/02/2012 11:03, Bruno Rocha ha scritto:


look the code in dal.py referencing check_reserved, you can copy 
patterns and dicts from there in to your validator.


http://zerp.ly/rochacbruno


ok thanks again Bruno,
I solved defining this subsequent custom validator with some cutpaste 
code from dal.py as suggested:


in modules/plugin_metadb.py

from dal import regex_python_keywords
from validators import Validator, translate
class IS_VALID_SQL_TABLE_NAME(Validator):

def __init__(self, db, check_reserved='common'):
self.db = db
self.check_reserved = check_reserved
if self.check_reserved:
from reserved_sql_keywords import ADAPTERS as RSK
self.RSK = RSK

def check_reserved_keyword(self, name):

Validates ``name`` against SQL keywords
Uses self.check_reserve which is a list of
operators to use.
self.check_reserved
['common', 'postgres', 'mysql']
self.check_reserved
['all']

for backend in self.check_reserved:
if name.upper() in self.RSK[backend]:
raise SyntaxError, 'invalid table/column name %s is a 
%s reserved SQL keyword' % (name, backend.upper())


def __call__(self, value):
if value.startswith('_') or hasattr(self.db,value.lower()) or \
regex_python_keywords.match(value):
return (value, translate('invalid table name: %s' % value))
elif value.lower() in self.db.tables:
return (value, translate('table already defined: %s' % value))
elif self.check_reserved:
try:
self.check_reserved_keyword(value)
except Exception, error:
return (value, translate(str(error)))
else:
return (value, None)

I hope it could be usefull to someone else.

Cheers

Manuele


[web2py] Re: lungo.js

2012-02-05 Thread Massimo Di Pierro
Yes. Right now web2py comes with skeleton which provides flexible
layouts. Do people think we need to include something like lungo.js?
And/or replace skeleton with boostrap 2.0?

On Feb 5, 4:46 am, Oli oliver.fr...@gmx.net wrote:
 we should have a mobile solution for web2py out of the box. Would this be
 possible?


[web2py] Getting the name of the Application

2012-02-05 Thread Sathvik Ponangi
How do I get the name of the current Web2Py app, so that my code is 
resilient to app-name changes?

Re: [web2py] Re: geo-capabilities for DAL

2012-02-05 Thread Manuele Pesenti

Il 04/02/2012 16:30, Massimo Di Pierro ha scritto:

We are working on this and you should expect it as one of the next
web2pu features.

veeery good news :)

thanks!

M.


Re: [web2py] Getting the name of the Application

2012-02-05 Thread David

On 2/5/12 10:06 AM, Sathvik Ponangi wrote:
How do I get the name of the current Web2Py app, so that my code is 
resilient to app-name changes? 

request.application I think, but its in the docs.



[web2py] web2py and mongodb - current status

2012-02-05 Thread David Marko
Hello, recently there was some discussion on mongodb intergration effort 
... what is the current status? Is there anyone working with web2py and 
mongodb? Any experience ?

David


[web2py] Re: DAL Limitations with aggregate and union queries

2012-02-05 Thread Niphlod
well, same old, same old sorry for the introduction, but I work as
a DBA and query tuning/optimization is in front of my eyes for more
than 8 hours a day ;-)

The first thing you learn in this job is try. The second is try. The
third is try. The fourth is understand the complexity. The fifth is
retry ;-)

Actually this is a pretty common request, and, first things first,
relational databases sucks at this kind of queries.

Just to clear out some doubts, I'll put some key points on this
requirement:
- you have a table
- you want only one record for max and one record for min salaries
(e.g. : if jobs and gates have the same salary, extract only one of
them, no matter what)

In addition, I'll clear some more doubts to you: when you use the DAL,
every query is made in the same connection. If you use multiple
queries, they use the same connection (no additional roundtrips for
connections, that have some impact on timings). Once the connection is
established, one can argue that making two distinct queries is anyway
slower that making two queries, and this is generally considered true,
but watch out the tests!!

Let's break some method to achieve you resultset:

method1 (you method):
select name, salary from (select min(salary) as minsal from emp) as x
inner join emp as t on t.salary = x.minsal union select name, salary
from (select max(salary) as maxsal from emp) as x inner join emp as t
on t.salary = x.maxsal

it has a problem... if your table is populated with common salaries
(for example, jobs and gates have a salary of 5), you have more than 2
rows, so the final print statements report incorrect data.

Let's say, for the sake of the discussion, that you have distinct
salaries in your table.

method2:
SELECT * FROM (SELECT  emp.name, emp.salary FROM emp ORDER BY
emp.salary LIMIT 1 OFFSET 0) AS a UNION ALL SELECT * FROM (SELECT
emp.name, emp.salary FROM emp ORDER BY emp.salary DESC LIMIT 1 OFFSET
0) AS b

PS: UNION ALL is used to be sure to return exactly two rows, UNION
filters out the same rows

which can be composed dinamically as:
minquery = db()._select(db.emp.name, db.emp.salary,
orderby=db.emp.salary, limitby=(0,1))
maxquery = db()._select(db.emp.name, db.emp.salary,
orderby=~db.emp.salary, limitby=(0,1))
final_statement = 'SELECT * FROM (%s) AS a UNION ALL SELECT * FROM
(%s) AS b' % (minquery[:-1], maxquery[:-1])

method3:
two distinct queries:
SELECT  emp.name, emp.salary FROM emp ORDER BY emp.salary LIMIT 1
OFFSET 0
SELECT  emp.name, emp.salary FROM emp ORDER BY emp.salary DESC LIMIT 1
OFFSET 0
they can be composed as
minquery = db()._select(db.emp.name, db.emp.salary,
orderby=db.emp.salary, limitby=(0,1))
maxquery = db()._select(db.emp.name, db.emp.salary,
orderby=~db.emp.salary, limitby=(0,1))

So, method2 and method3 are fullfilling your request to have some
way to write this kind of queries abstracted in DAL, in some ways.
method3 pisses you off because of the multiple queries involved.

Always for the sake of discussion, let me test this three methods.
Let's say you want to measure actual db performance, using
db.executesql() for all of the three methods with the plain text query
used for every method (we want to measure db performance without our
results being compromised by the DAL actually abstracting your
queries)

All tests were done initializing the db, and timing only the
db.executesql() function, repeated 1 times. Results, as always
with timeit, are in seconds.

test1: 5 records in the db, sqlite
method1 : 0.867677211761
method2 : 1.0282201767
method3 : 1.17870497704

test2: 5 records in the db, sqlite, column salary indexed
method1 : 0.867677211761
method2 : 0.810430049896
method3 : 0.806806087494

test3: 5000 records in the db, sqlite
method1 : 59.733631134
method2 : 100.970735073
method3 : 100.889001131

test4: 5000 records in the db, sqlite, column salary indexed
method1 : 31.619473
method2 : 0.830200910568
method3 : 0.837182998657

test5: 5 records in the db, postgresql
method1 : 7.11347198486
method2 : 5.63948893547
method3 : 7.27239108086

test6: 5 records in the db, postgresql, column salary indexed
method1 : 7.69179606438
method2 : 5.09459590912
method3 : 6.26593804359

test7: 5000 record in the db, postgresql
method1 : 39.8379509449
method2 : 29.3324680328
method3 : 30.5438249111

test8: 5000 records in the db, postgresql, column salary indexed
method1 : 22.3900408745
method2 : 4.97471690178
method3 : 6.57953190804

So, what do the tests show in general?
A) different engines respond in different ways (i.e. if you are
superoptimizing you have to test and consider the best way associated
with your db engine). I won't be surprised if Mysql or Oracle show
totally different timings
B) different number of records in a table matter. Again, if you are
superoptimizing, you have to consider the expected number of rows in
a table

What do the tests show in this particular case?
A) putting an index in the column you are ordering on always wins
B) scaling the 

[web2py] Re: Self Referential references in models not getting id decoded automatically

2012-02-05 Thread DenesL
You could do:

def register_dog():
if request.args(0) == 'edit':
db.dog.sire_id.requires = IS_IN_DB(db(db.dog.id!
=request.args(2)), db.dog, db.dog._format)
form=SQLFORM.grid(db.dog, csv=False, paginate=5,
user_signature=False)
return dict(form=form)

On Feb 5, 4:23 am, Mark Kirkwood mark.kirkw...@gmail.com wrote:
 Ok figured out what was causing that - I had one record with '0' for a
 sire_id and no dog with id = 0. Fixing that up makes the representation
 code below work. Yay! *But*... now the edit drop down list is showing
 id's instead of names... scratches head I'm sure that *was* working
 before

 I even redid the example from scratch and...still seeing id's instead of
 names in edit mode. Blast need to try again tomorrow and see if I can
 sort that.  Well at least figured out one of the problems!

 On 05/02/12 15:51, Mark Kirkwood wrote:









  However that brings back a header 'dog.name' that mucks up the
  appearance of the form. What I wanted to write was:

  db.dog.sire_id.represent = lambda sire_id, row: db.dog(sire_id).name
  if sire_id != None else None

  However that produces:

  AttributeError: 'NoneType' object has no attribute 'name'

  Which stumps me I must say, since I can clearly see a 'name:' entry
  displayed if I just leave off the '.name' in the code above...


Re: [web2py] validator for valid SQL table name

2012-02-05 Thread Manuele Pesenti

Il 05/02/2012 15:58, Manuele Pesenti ha scritto:

ok thanks again Bruno,
I solved defining this subsequent custom validator with some cutpaste 
code from dal.py as suggested:


I beg your pardon too many bugs in my previous code and not enough 
test... that's a better solution:


in modules/plugin_metadb.py

from dal import regex_python_keywords
from validators import Validator, translate
import re
class IS_VALID_SQL_TABLE_NAME(Validator):
'''
Checks if the field's value is a valid SQL table name.

Arguments:

db: an instance of the DAL class that represent the database that will
contain the table

check_reserved: list of adapters to check tablenames and column names
 against sql reserved keywords. (Default ('common', ))
* 'common' List of sql keywords that are common to all database 
types

such as SELECT, INSERT. (recommended)
* 'all' Checks against all known SQL keywords. (not recommended)
* adaptername Checks against the specific adapters list of 
keywords

(recommended)

Examples:

#Check if text string is a good sql table name:
INPUT(_type='text', _name='name', 
requires=IS_VALID_SQL_TABLE_NAME(db))


#Check if text string is a good sql table name specific for 
postgres dialect:
INPUT(_type='text', _name='name', 
requires=IS_VALID_SQL_TABLE_NAME(db, check_reserved=('postgres', )))


 IS_VALID_SQL_TABLE_NAME(db)('')
('', 'invalid table name: ')
 IS_VALID_SQL_TABLE_NAME(db)('foo')
('foo', None)
 IS_VALID_SQL_TABLE_NAME(db)('test')
('test', 'table/attribute name already defined: test')
 IS_VALID_SQL_TABLE_NAME(db)('select')
('select', 'invalid table/column name select is a COMMON 
reserved SQL keyword')


'''
def __init__(self, db, check_reserved=('common', )):
self.db = db
self.check_reserved = check_reserved
if self.check_reserved:
from reserved_sql_keywords import ADAPTERS as RSK
self.RSK = RSK

def __call__(self, value):

if re.compile('[^0-9a-zA-Z_]').findall(value):
return (value, translate('only [0-9a-zA-Z_] allowed in 
table and field names, received %s' % value))
elif value.startswith('_') or 
regex_python_keywords.match(value) or not value:

return (value, translate('invalid table name: %s' % value))
elif value.lower() in self.db.tables or 
hasattr(self.db,value.lower()):
return (value, translate('table/attribute name already 
defined: %s' % value))

elif self.check_reserved:
# Validates ``name`` against SQL keywords
#+ Uses self.check_reserve which is a list of
#+ operators to use.
#+ self.check_reserved
#+ ['common', 'postgres', 'mysql']
#+ self.check_reserved
#+ ['all']
for backend in self.check_reserved:
if value.upper() in self.RSK[backend]:
return (value, translate('invalid table/column name 
%s is a %s reserved SQL keyword' % (value, backend.upper(

return (value, None)


[web2py] Re: how to restart only one app in uwsgi?

2012-02-05 Thread Niphlod
I think the default /etc/init.d script for uwsgi-python allows
specifying the app name (actually it's the name of the config file)
only for status, i.e. /etc/init.d/uwsgi-python status appname

However, pids are in /var/run/uwsgi-python/appname/pid.

If I'm not wrong, sighup to the master process reloads, so

kill -1 `cat /var/run/uwsgi-python/appname/pid`

should do the job.

Consider also using the touch-reload option of uwsgi


[web2py] Adding application specific data to httpserver.log ?

2012-02-05 Thread JC11
Hello,

I need to add logging to my application. Out of the box, httpserver.log 
supplies 90% of what I want, but I'd love to add another piece or two of 
data to it. The data to add is specific to my application and present on 
the incoming URLs.

Any advice on where I should start ?

Thanks,

John C.


[web2py] Re: Adding application specific data to httpserver.log ?

2012-02-05 Thread Massimo Di Pierro
The logging is done by appfactory, in main.py at around line 700.

appfactory is a wsgi middleware that wraps wsgibase (the main web2py
wsgi app).

Anything passed in the http headers can be logged.

On Feb 5, 10:22 am, JC11 john.c...@gmail.com wrote:
 Hello,

 I need to add logging to my application. Out of the box, httpserver.log
 supplies 90% of what I want, but I'd love to add another piece or two of
 data to it. The data to add is specific to my application and present on
 the incoming URLs.

 Any advice on where I should start ?

 Thanks,

 John C.


[web2py] Re: BrowserID web2py authentication plugin done! Please test

2012-02-05 Thread whowhywhat
https://browserid.org/ .. seems to be working fine here. It is a
promising project in its infancy. I think they may have some teething
problems.
They won a rookie award at the 2011 black duck open software awards:
http://www.blackducksoftware.com/rookies/

Am sure every good web service has had its share of bad days..


On Feb 5, 6:47 pm, Alan Etkin spame...@gmail.com wrote:
 Congratulations. I tried to open the url of the project and it returns
 a 404 error.

 On 4 feb, 12:54, whowhywhat mads...@gmail.com wrote:







  Dear Web2py community,
  I just finished writing a web2py authentication plugin (custom
  authentication) to authenticate using BrowserID accounts (https://
  browserid.org). BrowserID is a project by Mozilla Labs
  (mozillalabs.org). It aims to provide a de-centralized, free, easy to
  use authentication method.
  BrowserID provides a nice alternative (or used side by side) to RPX,
  loginza, openID etc. personally, i feel BrowserIDs advantage is that
  you can use any email id verified by BrowserID.
  You can view the code here (https://code.google.com/p/browserid-web2py-
  plugin/source/browse/browserid_account.py).
  The browserid_account.py file needs to be in the gluon/contrib/
  login_methods/ folder. Usage is given in the doc string.

  Would love to hear your thoughts on BrowserID ..

  I have tested the plugin, everything seems to be working fine. Please
  test, look at the code and give me feedback, critique etc.. :). Please
  tell me if I am doing something wrong (security etc)

  Massimo I will email the patch to you in a few minutes.


[web2py] update with variable field (stored in variable)

2012-02-05 Thread Serbitar
I need to do something like this:

variable_field = 'val1'
x = 2
id = 1

db.define_table('a',
Field('name', type = 'integer'),
Field('val1', type = 'integer'),
Field('val2', type = 'integer')
)

db(db.a.id==id).update(variable_field=x)


this obviously doesnt work.

Any way to do that?


[web2py] Re: update with variable field (stored in variable)

2012-02-05 Thread Anthony


On Sunday, February 5, 2012 2:04:13 PM UTC-5, Serbitar wrote:

 I need to do something like this: 

 variable_field = 'val1' 
 x = 2 
 id = 1 

 db.define_table('a', 
 Field('name', type = 'integer'), 
 Field('val1', type = 'integer'), 
 Field('val2', type = 'integer') 
 ) 

 db(db.a.id==id).update(variable_field=x) 


try .update(**{variable_field: x})

Anthony 


[web2py] Re: lungo.js

2012-02-05 Thread Anthony
Looks cool. Note, it's GPLv3 for app development, and paid commercial for 
OEM uses.

On Friday, February 3, 2012 11:53:40 AM UTC-5, Massimo Di Pierro wrote:

 http://www.lungojs.com/



[web2py] Re: DAL Limitations with aggregate and union queries

2012-02-05 Thread Simon Lukell
As a 'bystander', I personally think that Niphlod's response is of
such good quality that the gist of it deserves inclusion in the book.


[web2py] Re: is there an easier way to do subtotals/grouping?

2012-02-05 Thread Niphlod
Normally I don't need big messes but if you show us a sample
dataset (original data on the table) and a required resultset (data
in the format you want) at least we can analyze it and tell you the
ways of doing that.

Just looking at your request I can tell that if you have gazillions of
rows and you're about to build something like an analytics app (e.g.
take the resultset and show me subtotals for month, week, day or by
employee name) the best you can achieve is definitely from defining a
view right into the database using windowing functions. You can then
define_table('name_of_the_view', migrate=False) and use DAL to read
that table.

With an ideal db structure (references, indexed columns, etc) and
multiple DAL queries you can definitely achieve some kind of
performance (the kind of let's not let the user take a coffee on each
page reload).
It's really only a matter of the things you want to achieve with the
things you've got, and finding the right balance from
ultraparametrized queries (better developed using multiple DAL
queries) or controlled-set-of-operations (meaning you don't have to
smash your head to the wall to achieve that behaviour in one single
view).


[web2py] Re: Self Referential references in models not getting id decoded automatically

2012-02-05 Thread Mark Kirkwood
A simpler fix for the edit/add functions is to specify a format in the 
model:


db.dog.sire_id.requires = IS_EMPTY_OR(IS_IN_DB(db, 'dog.id', '%(name)s'))

(Hmm ... suspect I had that there before at some stage which, but edited 
the format away when I was trying to pin down the other problems - 
oops). Anyway, thanks for the help!


Mark

On 05/02/12 22:23, Mark Kirkwood wrote:
*But*... now the edit drop down list is showing id's instead of 
names... scratches head I'm sure that *was* working before





[web2py] Re: DAL patch to support fractional seconds

2012-02-05 Thread howesc
GAE gives me fractional sections all the time when i convert to strings (to 
say pass as a URL parameter to query for the next section of the results).  
turns out that GAE stores fractional sections in the DB, and an accurate 
query would include them.  i have worked around it satisfactorily for now, 
but i certianly wouldn't mind if web2py datetime validators dealt with 
fractional seconds.  if needed for backward compatibility i'm fine with 
specifying an optional parameter that says yes do parse this datetime that 
looks like '2011-12-31 13:01:43.453'

just my 3 cents (and i haven't looked at the patch.



[web2py] Re: DAL Limitations with aggregate and union queries

2012-02-05 Thread Massimo Di Pierro
+1

On Feb 5, 3:20 pm, Simon Lukell sluk...@gmail.com wrote:
 As a 'bystander', I personally think that Niphlod's response is of
 such good quality that the gist of it deserves inclusion in the book.


[web2py] keep shared objects permanently in RAM: Is it possible ?

2012-02-05 Thread Sebastian E. Ovide
Hi All,

Is it possible to keep a BIG chunk of information in memory RAM permanently
(without reloading it for each new session/request) so that different
sessions (from X different users using the system at the same time) can
access (R/W) it concurrently ? For the kind of processing that need to be
done on the data, ALL of it must be in memory at the same time, and due for
the size of it, it is not practical to load/save it for each request. (to
slow)

thanks

-- 
Sebastian E. Ovide


Re: [web2py] keep shared objects permanently in RAM: Is it possible ?

2012-02-05 Thread Bruno Rocha
Redis or MongoDB seems to be what you are looking for!


On Sun, Feb 5, 2012 at 9:58 PM, Sebastian E. Ovide 
sebastian.ov...@gmail.com wrote:

 Hi All,

 Is it possible to keep a BIG chunk of information in memory RAM
 permanently (without reloading it for each new session/request) so that
 different sessions (from X different users using the system at the same
 time) can access (R/W) it concurrently ? For the kind of processing that
 need to be done on the data, ALL of it must be in memory at the same time,
 and due for the size of it, it is not practical to load/save it for each
 request. (to slow)

 thanks

 --
 Sebastian E. Ovide







-- 

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


[web2py] Re: DAL patch to support fractional seconds

2012-02-05 Thread nick name
I tried to maintain backward compatibility in the best way possible - by 
keeping the old code in place if you don't need higher resolution. 

(Note, however, that there's a place in DAL where time() retains 
microseconds, and datetime does not, which was probably a bug -- in that 
case, I fixed it by retaining microseconds always)

As for my use case: The app in question gets a forensic event stream from 
other sources, which have millisecond timestamps. I need to give these back 
out when requested, and when searching, because it needs to correlate with 
logs in the event source. I don't manipulate the times, but I do need to 
retrieve them and use them for searches.

Up until now, I've passed them as strings to the table.insert() (in which 
case web2py does not interfere at all), and by configuring the driver to 
return datetime types in which case web2py doesn't format them (for sqlite, 
this is the 'PARSE_DECLTYPES' in driver_args that you've added a couple of 
months ago; psycopg does this automatically. 

However, I've been bitten two many times by forgetting to convert to str(); 
everything seems to work well, except that fractional seconds disappear, 
and it's really easy to overlook in testing. Which is why I did this patch.

Personally, I think that silent truncation IS a bug; I would have been 
happy with raising an Exception (fractional seconds not supported), but I 
don't like silent truncation.

unrelated: Would you be ok with turning foreign key checking on in sqlite3? 
It doesn't by default, which is a shame.


[web2py] Re: web2py + twitter bootstrap 2.0

2012-02-05 Thread sungchi
Thank you for your advice.

On 2월5일, 오후11시57분, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 You you be able to add a README to the github page with a screenshot
 and a link to feed9?

 On Feb 5, 4:52 am, sungchi sungc...@gmail.com wrote:







  service like reddit(korean) :http://www.feed9.com/
  source :https://github.com/sungchi/feed9

  Thank you web2py,
  Thank you twitter !


[web2py] web2py+arvixe hosting

2012-02-05 Thread Alex s
Hello,
Anyone has some experience installing web2py in arvixe shared hosting?
I created an account but they are not having success to install it.
Thanks
Alex


[web2py] Re: Minify (compress) response HTML

2012-02-05 Thread Kernc
On Feb 3, 6:07 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 OK, let's add a minifier in contrib.

Thanks! :-)



[web2py] Re: Anyone deployed web2py on 1and1 shared hosting?

2012-02-05 Thread Edward Shave
Yes, thanks for that. I managed to run info.py and there was no mention of 
mod_python. I couldn't even work out how to copy files to htdocs. Anyway, 
have decided to move to webfaction where it seems I will have much more 
control and access. I was just hoping someone may have already done it.  ;o)


[web2py] DAL Connection String

2012-02-05 Thread Hugh Barker
Hi,
I have a bit of a problem with my connection string in db.py - 
specifically, the database password has a '@' symbol, and so web2py chokes 
because it assumes this is the delimiter between password and host.

I had a look at dal.py and I guess the regex needs modifying to take this 
case into account. Unfortunately my regex skills are pretty rudimentary - I 
spent an hour or so trying to nut it out, but didn't get anywhere, so I 
thought I'd ask you guys. The code is around line 1800 of dal.py:

uri = uri.split('://')[1]
m = 
re.compile('^(?Puser[^:@]+)(\:(?Ppassword[^@]*))?@(?Phost[^\:@/]+)(\:(?Pport[0-9]+))?/(?Pdb[^\?]+)(\?sslmode=(?Psslmode.+))?$').match(uri)
if not m:
raise SyntaxError, Invalid URI string in DAL

I can see what it's doing and where it's going wrong, just not how to fix 
it :(

Any help is appreciated.. I guess the easy option is to change the DB 
password, but unfortunately that isn't an option for me.

Cheers,
Hugh.


[web2py] Re: using radio widget can't receive the empty submit

2012-02-05 Thread Dan
My view did include the default layout, I omit it when I writing this
discussions.

The response.flash can show up when I submit my first form.
But it doesn't work when I submit the second form which used the
widget = SQLFORM.widgets.radio.widget.

On Feb 3, 1:27 am, DenesL denes1...@yahoo.ca wrote:
 Your view does not include the default layout which in turn includes
 the response.flash, so you have to put it in your view somewhere:

 {{=response.flash}}

 On Feb 1, 9:11 pm,Danideall...@googlemail.com wrote:

  Hi Denesl,
  Thanks for the hints. I got the sumbit info from the xform.
      Storage {'_formkey': 'cbaea79f-4524-4fa8-b5e6-dbae7e2b2a71',
  '_formname': 'xform'}
  But what I want is the flash response Form X Response shows up like
  the dropdown select form behaviors and other form.vars during the
  submit.

  In form, it's okay but not in xform.  Many thanks