Re: [web2py] how do I pass multiple variables in a Storage object to a function expecting named parameters?

2012-09-17 Thread Bruno Rocha
The better way is

def *_*blastoff(seconds, confirm):
# do whatever

def blastoff():
try:
x = *_*blastoff(**request.vars)
except Exception:
x = "error calling function, vars not passed or vars is wrong"
return dict(x=x)



On Mon, Sep 17, 2012 at 2:33 PM, Carl  wrote:

> I've got a request object coming to my Web2py app's controller function.
>
> request.args[0] is another function name e.g., blastoff
> request.vars are parameters e.g., Storage object: {'seconds':10,
> 'confirm' : 'okay'}
>
> how can I call blastoff with the parameters such that I can write
> blastoff as...
>
> def blastoff(seconds, confirm): ...
>
> --
>
>
>
>

-- 





Re: [web2py] Re: File name too long?

2012-09-17 Thread Bruno Rocha
What if I change in DAL my upload fields to the  "length=128" then the
migration will truncate the existing image names? or I need to backup and
re-upload them after this?

-- 





Re: [web2py] Re: Error on incorrect login - 'NoneType' object has no attribute 'count'

2012-09-17 Thread Bruno Rocha
I have facebook, google and standard auth.

-- 





Re: [web2py] Re: Error on incorrect login - 'NoneType' object has no attribute 'count'

2012-09-17 Thread Bruno Rocha
Using facebook connect and google+ user login with facebook account and
password stays null.

-- 





[web2py] Error on incorrect login - 'NoneType' object has no attribute 'count'

2012-09-17 Thread Bruno Rocha
When user password is incorrect I am getting this


*File /home/www-data/web2py/gluon/validators.py in __eq__ at line 2596*
código argumentos variáveis
 Function argument list

(self=, stored_password=None)
 Code listing


2591.
2592.
2593.
2594.
2595.
2596.

2597.
2598.
2599.
2600.


key = self.crypt.key.split(':')[1]

else:
key = self.crypt.key

else:
key = ''

if stored_password.count('$')==2:

(digest_alg, salt, hash) = stored_password.split('$')

h = simple_hash(self.password, key, salt, digest_alg)

temp_pass = '%s$%s$%s' % (digest_alg, salt, h)

else: # no salting

 Variables  stored_password.count undefined  stored_password None



Traceback (most recent call last):
  File "/home/www-data/web2py/gluon/restricted.py", line 209, in restricted

exec ccode in environment
  File "/home/www-data/web2py/applications/init/controllers/person.py"
,
line 173, in 

  File "/home/www-data/web2py/gluon/globals.py", line 186, in 

self._caller = lambda f: f()

  File "/home/www-data/web2py/applications/init/controllers/person.py"
,
line 116, in account

person = Person("account")
  File "applications/init/modules/handlers/base.py", line 43, in __init__

self.__getattribute__(hook)()
  File "applications/init/modules/handlers/person.py", line 740, in account

self.context.form = self.db.auth()

  File "/home/www-data/web2py/gluon/tools.py", line 1197, in __call__

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

  File "/home/www-data/web2py/gluon/tools.py", line 1967, in login

if form.vars.get(passfield, '') == temp_user[passfield]:

  File "/home/www-data/web2py/gluon/validators.py", line 2596, in __eq__

if stored_password.count('$')==2:
AttributeError: 'NoneType' object has no attribute 'count'





*Bruno Cezar Rocha** - @rochacbruno*
rochacbr...@gmail.com | Mobile: +55 (11) 99210-8821
www.CursoDePython.com.br | www.rochacbruno.com.br
Blog: App news reading
(portuguese)
  Get a signature like this.

Click
here.

-- 





Re: [web2py] Problem with validator IS_LIST_OF(IS_EMAIL())

2012-09-16 Thread Bruno Rocha
I just looked at the code but I cant see how did you solved this, I am
having the exact problem on another custom widget.

I want a field where users will put recipe ingredients separated by new
lines

*The field*

Field("ingredients", "list:string", requires=LINE_SEPARATED_LIST(),
widget=ListTextWidget.widget)

*on form it is*
*
*
--

Ingredient number 1
Ingredient number 2
...
...

---

*To validate that textarea I created this:*

class LINE_SEPARATED_LIST(object):
def __init__(self, error_message="value %s is invalid", sep="\n"):
self.error_message = error_message
self.sep = sep

def __call__(self, value):
items = value.split(self.sep)
return ([item.strip().replace("\r","") for item in items], None)

*And this widget to create the text area from stored list*

class ListTextWidget(FormWidget):
_class = 'text'

@classmethod
def widget(cls, field, value, **attributes):
if value:
value = "\n".join(value)
else:
value = ''

default = dict(value = value)
attr = cls._attributes(field, default,
   **attributes)
return TEXTAREA(**attr)

*The problem is that after validation with errors, the text area becomes:*

--

['Ingredient number 1', 'Ingredient number 2', ...]

---

-- 





Re: [web2py] Re: Is there a way to have a widget like list:string on list:reference?

2012-09-15 Thread Bruno Rocha
This one:http://ivaynberg.github.com/select2/#infinite

It is easy to implement, just a default text box and you bind this.

-- 





[web2py] Re: Postgres Heroku

2012-09-15 Thread Bruno Rocha
And data-clips are amazing feature!

https://postgres.heroku.com/dataclips/icuwejkuecgtzhbdtcpeomdakcyg

-- 





Re: [web2py] Re: Problem with validator IS_LIST_OF(IS_EMAIL())

2012-09-15 Thread Bruno Rocha
I have the exact same problem, but it is with tags widget.

I tried a lot but did not found the way to solve it :/

BEFORE VALIDATION ERROR:

[image: Inline image 1]

AFTER VALIDATION ERROR

[image: Inline image 2]

-- 





Re: [web2py] Re: Is there a way to have a widget like list:string on list:reference?

2012-09-15 Thread Bruno Rocha
I am using the default multi-select and this
http://ivaynberg.github.com/select2/

-- 





Re: [web2py] Re: [ANN] Started development on web2admin

2012-09-15 Thread Bruno Rocha
Your call, also if you prefer to take the modal logic from modules/server
side DOM on to HTML template it is easy to change.

I just created as Server side DOM because it can be reused.

-- 





Re: [web2py] Re: [ANN] Started development on web2admin

2012-09-15 Thread Bruno Rocha
I did the modal part, now need to do the shortcuts.

also as you are working on mult-db support, the code may change a little.

look:

[image: Inline image 1]

[image: Inline image 2]

-- 





Re: [web2py] Re: [ANN] Started development on web2admin

2012-09-15 Thread Bruno Rocha
I did that, a modal for field details... I did a pull-request with this,
maybe you can improve the design.

-- 





Re: [web2py] Re: [ANN] Started development on web2admin

2012-09-14 Thread Bruno Rocha
@rif I have some suggestion

Screenshot: http://i.imgur.com/3t2kv.png

For the suggested [fields] buttom it can be done with a modal or popup, it
can loads a   inside the
popup or modal, or if prefered it can retrieve this info via ajax.

To retrieve the info is easy,

for field in table.fields:
print name.name, name.type, name.length, name.comment, name.label,
name.compute, name.represent, name.requires, name.required, name.unique,
name.readable, name.writable
*first_name string 128 None First name None None
 False False True True*

So that info will be very important for developers and admins, also the
buttom can show up only if admin is logged in.

Let me know if you need some help, I am using this and I really think it
can be a replacement for appadmin.

-- 





Re: [web2py] Re: [ANN] Started development on web2admin

2012-09-14 Thread Bruno Rocha
There is Pyodel (learning tool), I dont know about the status of QAStak and
PyForum.

@rif what about multiple databases and databases named differently?

your code expects a "db" object, so I think you can put on the models a
config variable for dbs

plugin_web2admin_dbs = [db, other_db, sessions_db, user_db]

So in plugin code you can check

if "plugin_web2admin_dbs" in globals():
for db in  plugin_web2admin_dbs:
# logic to create navbar menus to change the "db" context.

-- 





Re: [web2py] Re: Loop on form.process(). Validation is not done

2012-09-14 Thread Bruno Rocha
What do you have in your view? are you using any JavaScript to manage the
form submission?

-- 





Re: [web2py] [ANN] Started development on web2admin

2012-09-13 Thread Bruno Rocha
Nice work!

the select2.js is the same as choosen? I really like it! should have a
web2py widget for this.

SUGGESTION:

it is very annoying to request "host/app/plugin_web2admin" the url does not
looks good. To change this, the hard option is tricking on routes. But
there is an easy way:

NOTE: it is a tricky, maybe it can change in the future, for now it works
nice.

On top of  MODELS/PLUGIN_WEB2ADMIN.PY add

if request.controller == 'web2admin':
> request.controller = 'plugin_web2admin'
> response.view = response.view.replace('web2admin', 'plugin_web2admin')



now you can calll "localhost:8000/app/web2admin/"

I will start to use this, great work!

** is there a license?

-- 





Re: [web2py] short term roadmap

2012-09-13 Thread Bruno Rocha
also it will need on admin BUTTON('update scaffold list') and in command
line web2py.py -S updatescaffold

-- 





Re: [web2py] short term roadmap

2012-09-13 Thread Bruno Rocha
I would like to have a repo of scaffold apps and a command line tool +
/admin tool to checkout

ADMIN -> create new app -> SELECT(*['simple', 'bootstrap', 'foundation',
'ecommerce', 'tuned',..long list])

and on command line

>>>python web2py.py -S newappname*|*foundation
>>> downloading 'foundation' scaffold app from
github.com/web2py/foundation..
>>> unpacking.
>>> done! WELCOME TO WEB2PY shell
>>>

-- 





[web2py] Re: [web2py-dev] on Redis Rows turns in to list() ?

2012-09-13 Thread Bruno Rocha
Ok, changing all my selects to cacheable=False it works on .disk, redis and
memcache.

Even on the rows where I am not using the .find() and .exclude() methods
the cache are failing.

If do

{{for row in cached_rows:}}

{{pass}}

it gives me nothing..

Also {{if cached_rows:}} returns always False.

It works good on cache.ram with cacheble=True|False

-- 





[web2py] Re: [web2py-dev] on Redis Rows turns in to list() ?

2012-09-13 Thread Bruno Rocha
The same problem without cacheable

-- 





[web2py] Re: [web2py-dev] on Redis Rows turns in to list() ?

2012-09-13 Thread Bruno Rocha
Yes, it raises the same error when using cache.disk, so I think for now we
should include a note on /book.

and I will try to emulate the .find .exclude and .sort externally using
listcomprehension or map.

-- 





Re: [web2py] Is there anyway to register a user manually just like login_bare? I am using it in the mobile app.

2012-09-13 Thread Bruno Rocha
*Create this function in some model*
*
*

> *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*



Now create user with this:


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


*Bruno Cezar Rocha** - @rochacbruno*
rochacbr...@gmail.com | Mobile: +55 (11) 99210-8821
www.CursoDePython.com.br | www.rochacbruno.com.br
Blog: App news reading
(portuguese)
  Get a signature like this.

Click
here.



On Thu, Sep 13, 2012 at 3:28 PM, Kenny  wrote:

> login_bare is so useful for accessing the database manually in mobile 
> application, is there anyway to let the users to register the website via 
> mobile application?
>
> ex) register_bare(id,password) -> Save it in the database -> user is 
> registered.
>
> I wasn't able to find how I should make this registration step for mobile app 
> + web2py.
>
> Thank you
>
>
>
>  --
>
>
>
>

-- 





Re: [web2py] Beginner trying to adapt the Chapter 11 ajax function 'echo' example

2012-09-13 Thread Bruno Rocha
The ajax function:

ajax(
  url, # here you set a string to a complete url, it can include args
and vars
  [], # form inputs, if you have a form on the page you can set
['name', 'email'] if you do not have a form set it to null
  target, # an id of any html element where you want the response to be
inputed #mydiv or a function to be used as callback function(data){//do
something})
   )


NOTE: avoid the use of inline java script

Example:

{{extend 'layout.html'}}

$(function(){
$('.myactions li').click(function(){
elem = $(this);
url = elem.attr('data-url');
ajax(url, *null*, parse_my_data);
});
});

function parse_my_data(data){

   $("#sometarget").html(data);  # replaces the content of #sometarget with
returned data
   $("#sometarget").append(data);  # append data on the end of sometarget
content
   $("#sometarget").prepend(data); # prepend data on the begin of the
sometarget content
   // or you can do whatever you want with data as it can be json, txt or
html
}



{{for item in collection:}}
 Do something

{{pass}}


-- 





Re: [web2py] Validating form fields manually

2012-09-13 Thread Bruno Rocha
You can read the read-only or hidden fields from the form directly on
request.vars, instead of form.vars use request.vars and it should work.

-- 





[web2py] Re: on Redis Rows turns in to list() ?

2012-09-13 Thread Bruno Rocha
I noted that this happens with memcached too.

 'list' object has no attribute 'find'

My cached .select(cache=(cache.memcache, 1200)) is retrived as a list.

 Function argument list

(menus=[, , , , ], visibility=1, parent=None, place='top')
 Code listing


148.
149.
150.
151.
152.
153.

154.
155.
156.
157.



def get_menu(menus, visibility=1, parent=None, place="top"):

ret = []
if not parent:
ret = menus.find(lambda row: (row.parent == 0 or row.parent ==
None) and row.visibility == visibility and row.place == place)

else:
ret = menus.find(lambda row: row.parent == parent and
row.visibility == visibility and row.place == place)

return ret



and I cannot use .find or other methods, this does not happens when using
internal cache.ram.

Is that the expected behavior?

-- 





[web2py] Pynes notify

2012-09-11 Thread Bruno Rocha
This plugin for Bootstrap looks very nice for response.flash

http://pinesframework.org/pnotify/

-- 





Re: [web2py] Modelless app no longer works with web2py 2.0.x ???

2012-09-11 Thread Bruno Rocha
I did some changes on Movuca, but I still have to solve little issues in
order to commit.

But I just commited a workarounf for the problem:
https://github.com/rochacbruno/Movuca/commit/aa25103e9c37921a34a225b8e82ca0f8634ca831

-- 





Re: [web2py] Re: Best Method to implement a "like" button

2012-09-11 Thread Bruno Rocha
The computation should be

compute= lambda row: "%(username)s-%(songname)s-%(playlist_name)s" % row

-- 





Re: [web2py] Re: Best Method to implement a "like" button

2012-09-11 Thread Bruno Rocha
db.define_table('likes',
Field('username', 'reference auth_user'),

Field('songname', 'reference songs'),
Field('playlist_name', 'reference playlist'),
Field('unique_key', unique=True, notnull=True,  compute= lambda row:
"%(username)s-%(songname)s-%(playlist_name)s"),

)

Now on any attempt to insert duplicates DAL will have an exception, because
unique_key is unique and the computation will try to add same values.

try:
db.likes.insert(..)
except:
#YOU ALREADY LIKE THIS


*Bruno Cezar Rocha** - @rochacbruno*
rochacbr...@gmail.com | Mobile: +55 (11) 99210-8821
www.CursoDePython.com.br | www.rochacbruno.com.br
Blog: Using Python to get all the external links from a
webpage
  Get a signature like this.

Click
here.

-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-11 Thread Bruno Rocha
for that cases shouldn't use _before_insert and _before_update triggers?

-- 





Re: [web2py] Help with python module import error

2012-09-10 Thread Bruno Rocha
If you are running on webfaction, maybe it is under apache and mod_wsgi, so
you need to restart Apache to reload the mod_wsgi.

$service apache2 restart

or

$/etc/init.d/apache2 restart

(but you need to check if it is running apache, nginx or other)

-- 





Re: [web2py] Help with python module import error

2012-09-10 Thread Bruno Rocha
if the package is in your Python wen2py have to see this..

you can try inside web2py code (i.e models)

import sys
sys.path.append("/path/to/installed/package")

Have you restarted web2py since you installed the module?

On Mon, Sep 10, 2012 at 4:52 PM, monotasker  wrote:

>
> I'm having trouble on Webfaction with web2py not finding the pytz module,
> even though it is found fine in my local environment. I've
> already installed the module using easy_install at myname/lib/python2.7 (as
> per Webfaction instructions), and I've confirmed that I can import it from
> the python prompt (in an ssh session). I've also confirmed that web2py is
> running on python2.7. But I'm still getting an import error. Any ideas?
>
> I thought I might try putting the package in my site-packages directory,
> but I'm not exactly sure what to put there. Would I use easy_install or do
> I need to put some files there manually?
>
> Thanks,
>
> Ian
>
>
>  --
>
>
>
>

-- 





Re: [web2py] Modelless app no longer works with web2py 2.0.x ???

2012-09-09 Thread Bruno Rocha
On Sun, Sep 9, 2012 at 9:27 PM, Andrew W  wrote:

> (although I still don't quite really understand what a lazy table is).


imagine you have

models/db.py

db = DAL(...)
db.define_table("table1".)
db.define_table("table2".)
...
...
db.define_table("table30".)

So, for each request (I mean every time user hits an url or click on
something) all that 30 tables will be imeddiatelly instantiated even if the
requested page does not need to all the 30 tables.

The process of table definition involves some logic such as instantiate a
new Table object, check all the fields, do migrations, check reserved
keywords, check the tablename atc...

Now if you turn

db = DAL(... lazy_tables=True)

for each request web2py will just store some data in a dictionary
{"tablename": {"fields": ., "options":}, no table will be
instantiated ultil needed.

So when in your program you do

db(db.table1),select() # in this time web2py will fire the table
instantiation and all the process, so it will happen only for the table you
need and you saved 29.

Thats it.

-- 





Re: [web2py] Re: help test codemirrorw

2012-09-09 Thread Bruno Rocha
Maybe we can put a dropdown  and adjust the prefered editor using
cookies in the same way we do with the admin language?

So it will be easy to switch from codemirror to ace and no need to edit the
0.py


On Sun, Sep 9, 2012 at 4:35 PM, Marin Pranjić wrote:

> It is not about the colors. Ace has smaller font and it looks more elegant
> that way.
> Maybe it's just me... :)
>
> And the edit box is larger by default: http://i49.tinypic.com/19o3g1.jpg
>
> Dana nedjelja, 9. rujna 2012. 21:25:37 UTC+2, korisnik Massimo Di Pierro
> napisao je:
>
>> I changed the web2py codemirror style. We can still work on it
>>
>> On Sunday, 9 September 2012 14:16:17 UTC-5, Massimo Di Pierro wrote:
>>>
>>> Which theme di you like better?
>>> http://codemirror.net/demo/**theme.html
>>>
>>> On Sunday, 9 September 2012 14:00:01 UTC-5, Marin Pranjić wrote:

 Is there anything that actually works on IE?

 codemirror works for me (ubuntu, Firefox15).

 But ace has nicer look.

 Dana nedjelja, 9. rujna 2012. 20:52:34 UTC+2, korisnik Massimo Di
 Pierro napisao je:
>
> If we move to codemirror (and we should) what do we get rid of
> (editarea, amy, ace)? We cannot ship with 4 editors.
>
>
 Maybe pack them as plugins?

>>>  --
>
>
>
>

-- 





Re: [web2py] Modelless app no longer works with web2py 2.0.x ???

2012-09-09 Thread Bruno Rocha
Here is the solution:
https://github.com/rochacbruno/web2py_model_less_app/blob/master/modules/myapp.py#L82

That approach subclasses DAL so it need to include _lazy_tables = {}

But, now that we have lazy_tables in default DAL, I recommend you to use
the default web2py scheme with lazy_tables=True, and you will not have the
ols problem of lot of tables defined.

BTW: I am still using the modelless class based scheme and it is working
good.


*Bruno Cezar Rocha** - @rochacbruno*
rochacbr...@gmail.com | Mobile: +55 (11) 99210-8821
www.CursoDePython.com.br | www.rochacbruno.com.br
Blog: Using Python to get all the external links from a
webpage
  Get a signature like this.

Click
here.



On Sun, Sep 9, 2012 at 3:22 PM, Don_X  wrote:

> Considering that I have many tables in my model files on the main app I am
> building &
>
> Wanting to take the modelless approach ( slice submitted by BrunoRocha )
>
> in order to avoid possible future bottleneck and/or latency
>
> I wanted to advise that the modelless app no longer works under web2py
> 2.0.x
>
> When I downloaded and installed the running test app to check it out with
> any 2.0.x
>
> I get the following error ticket msg :
>
>  'DataBase' object has no attribute
> '_lazy_tables'
>
>
> Can anyone help me with this ??? ...  so I can make it right ... before I
> incorporate this approach in my app dev habit ..
>
> is there a patch for it ??? ...
>
> thank you
>
> Don
>
>
>
>  --
>
>
>
>

-- 





Re: [web2py] help test codemirrorw

2012-09-08 Thread Bruno Rocha
code mirror works ok for me in chrome, opera and firefox (ubuntu).

-- 





Re: [web2py] help test codemirrorw

2012-09-08 Thread Bruno Rocha
Thats great!  I started using codemirror on another project and I find it
awesome.

I will update from trunk now and test in Ubuntu..

-- 





Re: [web2py] Re: Object Row. Error in 2.0.8 not in 2.0.0

2012-09-08 Thread Bruno Rocha
I am using:

cache_key = "%s_%s_%s" % (query, start, end)
total, rows = cache.ram(cache_key, lambda: (db(query).count(),
db(query).select(limitby=(start, end), cacheable=True)), 3600)

Should I put a dummy cache=(...) just to have the benefits?

-- 





Re: [web2py] Populating widgets with queries

2012-09-07 Thread Bruno Rocha
maybe this?

form = SQLFORM.factory(
Field('test',
type='string',
requires=IS_IN_DB(*db(db.table.field == xyz)*, db.city.name_url,
'%(name)s', multiple=True),
widget=lambda f, v: SQLFORM.widgets.checkboxes.widget(f, v,
style='divs'),
default = 'New-York'), formstyle='divs')

or

myset = [("value 1", "text 1"), ("value 2", "text 2"), ("value 2", "text
2")]

form = SQLFORM.factory(
Field('test',
type='string',
requires=IS_IN_SET(myset, multiple=True),
widget=lambda f, v: SQLFORM.widgets.checkboxes.widget(f, v,
style='divs'),
default = 'New-York'), formstyle='divs')

or

myset = {"value 1": "text 1", "value 2": "text 2", "value 2": "text 2"}

form = SQLFORM.factory(
Field('test',
type='string',
requires=IS_IN_SET(myset, multiple=True),
widget=lambda f, v: SQLFORM.widgets.checkboxes.widget(f, v,
style='divs'),
default = 'New-York'), formstyle='divs')

or


myset = db.executesql("SELECT value, text FROM sometable")

form = SQLFORM.factory(
Field('test',
type='string',
requires=IS_IN_SET(myset, multiple=True),
widget=lambda f, v: SQLFORM.widgets.checkboxes.widget(f, v,
style='divs'),
default = 'New-York'), formstyle='divs')


*Bruno Cezar Rocha** - @rochacbruno*
rochacbr...@gmail.com | Mobile: +55 (11) 99210-8821
www.CursoDePython.com.br | www.rochacbruno.com.br
Blog: Using Python to get all the external links from a
webpage
  Get a signature like this.

Click
here.



On Sat, Sep 8, 2012 at 3:22 AM, Mike Girard  wrote:

> I have a checkboxes widget which I invoke like so:
>
> form = SQLFORM.factory(
> Field('test',
> type='string',
> requires=IS_IN_DB(db, db.city.name_url, '%(name)s',
> multiple=True),
> widget=lambda f, v: SQLFORM.widgets.checkboxes.widget(f, v,
> style='divs'),
> default = 'New-York'), formstyle='divs')
>
> I use requires=IS_IN_DB solely to populate the checkboxes with fresh data.
> I don't really need the validation. Now I would prefer to spread the data
> in the one table being used across multiple checkbox groups. Is there an
> out-of-the-box way to populate form elements with queries instead of just
> binding them to tables?
>
> --
>
>
>
>

-- 





Re: [web2py] Re: [OT] Ubuntu 12.10 will no longer ship with Python 2

2012-09-07 Thread Bruno Rocha
Let's create a virtual-env with Python 2.7 and it will not be a problem.

-- 





Re: [web2py] invalid view (default/contribuyentes.html)

2012-09-06 Thread Bruno Rocha
that should be under */views/default/contribuyentes.html*


On Thu, Sep 6, 2012 at 4:48 PM, ocascante wrote:

> Hi, i am new in web2py.
>
> I have web2py 2.07 installed in my linux mint 13 computer. I used the
> script available in google to install it.
>
> Now, i have a problem that i don't understand.
>
> First I have in the default.py this:
>
> def contribuyentes():
> grid = SQLFORM.smartgrid(db.contribuyentes)
> return dict(grid=grid)
>
> and second i created the contribuyentes.html view with:
>
> {{extend 'layout.html'}}
> {{=grid}}
>
> If i write "response.generic_patterns = ['*']" in the contribuyentes
> function, i access the generic view but not the contribuyentes view.
> Without this sentence, i have this error: "invalid view
> (default/contribuyentes.html)"
> I don't want to use the generic view.
>
> Thanks for your help.
>
>
>  --
>
>
>
>

-- 





Re: [web2py] sqlform.grid and query conditions

2012-09-05 Thread Bruno Rocha
You can do:

if request.args(0) in ['edit', 'delete']:
STORE_DETAILS.id == int(request.args(2)) or redirect(URL('default',
'wherever'))

db.pages.stores_id.default = STORE_DETAILS.id
query = ((db.pages.stores_id == STORE_DETAILS.id))
form = SQLFORM.grid(query=query)

return dict(form=form)



On Wed, Sep 5, 2012 at 9:38 PM, Kevin C  wrote:

> Basically, we are generating a SQLFORM.grid with the following code:
>
> db.pages.stores_id.default = STORE_DETAILS.id
> query = ((db.pages.stores_id == STORE_DETAILS.id))
> form = SQLFORM.grid(query=query)
>
> return dict(form=form)
>
> This is working perfectly fine for us.  However, we have noticed that if
> we just change the ID in the query string for the edit page, we are allowed
> to edit other store's entries.
>
> IE
> http://test.oursite.com/test/admin/pages/edit/pages/6?_signature=f8c5560743.
> ..
>
> What is the proper way to do this, then?  The grid itself looks great, but
> just by changing the page ID in the URL, we are allowed to edit pages not
> belonging to us.  I guess I was hoping that the query conditional would be
> passed to each function (add, edit, delete) but that obviously is not the
> case.  Is multi-tenancy the solution to this issue or are we overlooking
> something simple?
>
> --
>
>
>
>

-- 





Re: [web2py] Web2Py : JQuery .ajax data sent not present in request.vars

2012-09-05 Thread Bruno Rocha
or you call it with .json extension and use the generic json view

url: /test01/default/getContent*.json*?sourceTitle=x

or you do this on the return

import json

def getContent():
titleArg = str(request.vars.sourceTitle)
print "--"
print "--"
print request.vars # Starts working if "contentType" in ajax request
above is commented
print "Getting news content for : " + titleArg
print "--"
print "--"
#rows=db(db.NewsMaster).select(db.NewsMaster.ALL)
"""
"""
myobj = [dict(value=x),dict(value=x), dict(value=x)]
return json.dumps(myobj)



On Wed, Sep 5, 2012 at 6:51 PM, Nik  wrote:

> Thanks Bruno !
> That worked, but now when I get the response back as JSON, JQuery throws
> an error saying the JSON isn't valid. The JSON seems valid to me & also
> passes JSONLint test :
>
> {"readyState":4,"responseText":"FIFA support India for U-17 and 2022 World
> Cup - Times","status":200,"statusText":"OK"}
>
>
>
> On Wednesday, 5 September 2012 17:40:42 UTC-4, rochacbruno wrote:
>>
>> Your URL should have the vars
>>
>> url: /test01/default/getContent?**sourcetitle=xxx
>>
>> If you do not pass the vars on url you can't get them at the called
>> controller
>>
>  --
>
>
>
>

-- 





Re: [web2py] Web2Py : JQuery .ajax data sent not present in request.vars

2012-09-05 Thread Bruno Rocha
Your URL should have the vars

url: /test01/default/getContent?sourcetitle=xxx

If you do not pass the vars on url you can't get them at the called
controller

-- 





Re: [web2py] Filtering on NULL values in DAL query

2012-09-05 Thread Bruno Rocha
On Wed, Sep 5, 2012 at 3:12 PM, Marin Pranjić wrote:

> it is db.table.field != None
>
> operator ~ is used for ORDER BY and it maps to DESC.


Yes, my bad, you are right, but there is one case where ~ is used in query

~db.table.field.belongs(list) and ~db.table.listfield.contains(value)

-- 





Re: [web2py] Filtering on NULL values in DAL query

2012-09-05 Thread Bruno Rocha
db(db.table.field == None).select()

should give you all records with field = NULL

db(~db.table.field == None).select()

All records where field <> NULL

Is that?

-- 





Re: [web2py] Re: Auth Decorator / Model Question.

2012-09-04 Thread Bruno Rocha
cache.ram or even better (memcached) is preferred! if you use session and
your sessions are stored on filesystem, if you have too much data it will
be hard to load on each request.

DATA = cache.ram(request.http_host, lambda: db(..).select(cacheable=True),
86400) # keeps for 24  hours.

Now, on every place where data is changed you can call
cache.ram.clear(regex=None) to reset that cache.

-- 





Re: [web2py] Re: Twitter account for @web2py

2012-09-04 Thread Bruno Rocha
www.facebook.com/web2py

-- 





Re: [web2py] Validating form fields manually

2012-09-04 Thread Bruno Rocha
this:

def validate_my_form(form)
if form.vars.channel == "foo":
form.errors.channel = "This channel is not valid"

if form.process(onvalidation=validate_my_form).accepted:
# do whatever here




*Bruno Cezar Rocha** - @rochacbruno*
rochacbr...@gmail.com | Mobile: +55 (11) 99210-8821
www.CursoDePython.com.br | www.rochacbruno.com.br
Blog: Using Python to get all the external links from a
webpage
  Get a signature like this.

Click
here.



On Tue, Sep 4, 2012 at 4:09 PM, Daniel Gonzalez  wrote:

> Something like this:
>
> if form.process().accepted:
> if request.var.channel == 'voicemail': validate requests.var.destination
> as a mail address.
> elif request.var.channel == 'sipaddress' validate requests.var.destination
> as a sip address.
> elfi request.var.channel == 'phone' validate requests.var.destination
> as a telephone number
>
>
> I have two questions:
>

-- 





Re: [web2py] Re: Twitter account for @web2py

2012-09-04 Thread Bruno Rocha
There is a free option..

I manage the web2py facebook page, (also Massimo and Anthony are added as
co-managers), facebook can tweet automatically from page --> twitter.

So we can add more people to page management and all publications by page
will go to twitter.

Just need to enter there, go to page admin and include web2py twitter
account. (Massimo you have admin permissions to do it on the facebook page)

On Tue, Sep 4, 2012 at 4:08 PM, Luther Goh Lu Feng  wrote:

> Oops I am so sorry Massimo. Seems that cotweet became a paid service
> earlier this year. Maybe someone can recommend a free alternative?
>
>
> On Tuesday, September 4, 2012 11:57:31 PM UTC+8, Massimo Di Pierro wrote:
>>
>> Do not worry.
>>
>> On Tuesday, 4 September 2012 10:26:52 UTC-5, David J wrote:
>>>
>>>  Don't tweet commit messages, that is really very annoying.
>>>
>>> Releases are fine.
>>>
>>>
>>>
>>> On 9/4/12 11:21 AM, Massimo Di Pierro wrote:
>>>
>>> I cannot figure out how to sign up for cotweet. :-(
>>>
>>> On Monday, 3 September 2012 15:45:14 UTC-5, Luther Goh Lu Feng wrote:

 I think it is also possible to give trusted and active members of the
 community access to the twitter account via some service like cotweet.

 On Tuesday, September 4, 2012 4:14:02 AM UTC+8, rochacbruno wrote:
>
> You can use 
> http://feeds.feedburner.**com/web2pyslices
>  as
> source for automatic posts...
> also it would be nice to include 
> web2py.com/download/changelog.**rss(create
>  it) and use as source to tweet automatically when change log gets
> updated.
> It can also be done with github commits (you can integrate the account
> on github --< twitter)
>
>
> On Mon, Sep 3, 2012 at 5:08 PM, Massimo Di Pierro <
> massimo@gmail.com> wrote:
>
>> No particular reason. I am planning to get back to it. Any
>> suggestions on how to make it more active?
>>
>>
>> On Monday, 3 September 2012 14:32:23 UTC-5, Luther Goh Lu Feng wrote:
>>>
>>> I just noticed that the twitter account has been very inactive :o
>>>
>>>  Is there any reason for that? Anyway to improve the situation?
>>>
>>>  https://twitter.com/web2py
>>>
>> --
>>
>>
>>
>>
>
>
>   --
>>>
>>>
>>>
>>>
>>>
>>>   --
>
>
>
>

-- 





Re: [web2py] Updated cheatsheet

2012-09-04 Thread Bruno Rocha
So I assume cache.ram.clear() will do the job ?

-- 





Re: [web2py] Updated cheatsheet

2012-09-04 Thread Bruno Rocha
Small question..

cache.ram.clear(regex='*')  will clear the whole cache?

-- 





Re: [web2py] Re: web2pyslices for Android

2012-09-03 Thread Bruno Rocha
That is just a RSS reader with local storage for favorites, read/unread
etc..

-- 





Re: [web2py] Re: Checking for upgrades isn't working as I expected (1.99.7 installed)

2012-09-03 Thread Bruno Rocha
If you have access to files (ssh or ftp) you can try to edit this line

 File "...web2py/applications/admin/controllers/default.py"
,
line 113, in check_version


+ XML(' %s' % version_number)


and change to


+ XML(' %s' % str(version_number))


Including str(version_number) and saving, now you can try to click on
check for upgrade and it will work!

-- 





Re: [web2py] help with apache

2012-09-03 Thread Bruno Rocha
I guess it can help you to discover the problems:
http://nicolargo.github.com/glances/

(I would like to have a web-socket version of that app)

-- 





Re: [web2py] Re: Twitter account for @web2py

2012-09-03 Thread Bruno Rocha
You can use http://feeds.feedburner.com/web2pyslices as source for
automatic posts...
also it would be nice to include web2py.com/download/changelog.rss (create
it) and use as source to tweet automatically when change log gets updated.
It can also be done with github commits (you can integrate the account on
github --< twitter)


On Mon, Sep 3, 2012 at 5:08 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> No particular reason. I am planning to get back to it. Any suggestions on
> how to make it more active?
>
>
> On Monday, 3 September 2012 14:32:23 UTC-5, Luther Goh Lu Feng wrote:
>>
>> I just noticed that the twitter account has been very inactive :o
>>
>> Is there any reason for that? Anyway to improve the situation?
>>
>> https://twitter.com/web2py
>>
>  --
>
>
>
>

-- 





Re: [web2py] Re: web2py book on github

2012-09-03 Thread Bruno Rocha
FYK:

The portuguese will be done by a community, so we are tracking the statuses
on this file:

https://github.com/rochacbruno/web2py-book/blob/master/sources/37-web2py-portuguese-work-in-progress/translation_status.md

Maybe someone can follow the pattern...

-- 





Re: [web2py] Re: web2py book on github

2012-09-03 Thread Bruno Rocha
Martin, I am doing the same for portuguese.

Which number did you named your spanish version?
36-spanish-work-in-progress ?

I forked and I will put a 37-portuguese-work-in-progress

On Mon, Sep 3, 2012 at 4:27 PM, Martín Mulone wrote:

> I know but it's not in markmin, and make changes and sync is a hell pain.
> Google translation is funny, is not serious.
>
> 2012/9/3 Massimo Di Pierro 
>
>> Mind that I believe there is already around a spanish translation of the
>> 3rd edition.
>>
>> There is also this version translated by google:
>>
>>https://dl.dropbox.com/u/18065445/web2py/web2py_manual_es.pdf
>>
>> and this one translated in portuguese by google:
>>
>>https://dl.dropbox.com/u/18065445/web2py/web2py_manual_pt.pdf
>>
>>
>>
>>
>>
>> On Monday, 3 September 2012 13:28:35 UTC-5, Martin.Mulone wrote:
>>
>>> Thanks massimo, this is a huge advance!, and the app is also very cool.
>>> I started translation to spanish based on fork (29-english), here
>>> https://github.com/**mulonemartin/web2py-book.
>>>
>>>
>>> 2012/9/3 Massimo Di Pierro 
>>>
>>> Planning to add that by the end of the week.


 On Monday, 3 September 2012 11:41:56 UTC-5, Mandar Vaze wrote:
>
>
>
> On Saturday, September 1, 2012 10:30:49 PM UTC+5:30, Massimo Di Pierro
> wrote:
>>
>> The web2py book app has been rewritten
>>
>>http://www.web2py.com/book
>>
>
> Does this mean the PDF is also (automatically) updated ? I checked
> online, the PDF still says Build Date "December 2011"
>
> -Mandar
>
  --




>>>
>>>
>>>
>>> --
>>>  http://www.tecnodoc.com.ar
>>>
>>>  --
>>
>>
>>
>>
>
>
>
> --
>  http://www.tecnodoc.com.ar
>
>  --
>
>
>
>

-- 





Re: [web2py] Classes in markmin

2012-09-02 Thread Bruno Rocha
There is markmin2pdf and markmin2html on gluon.contrib

https://github.com/web2py/web2py/tree/master/gluon/contrib/markmin

-- 





Re: [web2py] Re: Global formstyle configuration

2012-09-02 Thread Bruno Rocha
This should work..

# On models
class SQLFORM(SQLFORM):
''' Customized SQLFORM '''

def __init__(self, *args, **kwargs):
kwargs.setdefault("formstyle", "divs")
super(MySQLFORM, self).__init__(*args, **kwargs)




On Sun, Sep 2, 2012 at 8:11 PM, vinicius...@gmail.com  wrote:

> Anthony, another one would be hide_error.
>
> These are settings affect app style of visualization and user interaction.
> So, it makes sense to be defined once and overriden when necessary.
>
> --
> Vinicius Assef
>
>
>
> On 09/02/2012 12:34 PM, Anthony wrote:
>
>> Are there other examples of potential global configs? For forms, perhaps
>> we could set the default via a "formstyle" class attribute, which you
>> could then change once in your code.
>>
>> Anthony
>>
>> On Sunday, September 2, 2012 11:27:42 AM UTC-4, viniciusban wrote:
>>
>> I think it would be nice to have some global configs in web2py.
>> One of them is formstyle.
>>
>> It's unpleasant to define formstyle in every FORM definition.
>> This formstyle config could come in db.py like Auth configs.
>>
>> So, once defined my app formstyle, it should be used as default. But
>> in
>> a specific FORM, I could override it, according to my needs.
>>
>> Any oppinion?
>>
>> --
>> Vinicius Assef
>>
>>
>> On 09/02/2012 12:12 PM, Anthony wrote:
>> > We also need to document the new formstyle='bootstrap' option as
>> well as
>> > the new callable formstyle option that takes the form and fields and
>> > builds the entire form DOM.
>> >
>> > Anthony
>> >
>> > On Saturday, September 1, 2012 5:37:11 PM UTC-4, Massimo Di Pierro
>> wrote:
>> >
>> > These features are now documented in the html book. Working on
>> more.
>> >
>> > [x] Support for DAL(lazy_tables=True) and
>> > db.define_table(on_define=**lambda table:), thanks Jonathan
>> > [x] db(...).select(cacheable=True) make select 30% faster
>> > [x] db(...).select(cache=(cache.**ram,3600)) now caches parsed
>> data
>> > 100x faster
>> > [x] db(...).count(cache=(cache.**ram,3600)) now supported
>> > [x] MongoDB support in DAL (experimental), thanks Mark Breedveld
>> > [x] db.mytable._before_insert, _after_insert, _before_update,
>> > _after_update, _before_delete. _after_delete (list of callbacks)
>> > [x] DAL BIGINT support and DAL(...,bigint_id=True)
>> > [x] IS_IN_DB(..., distinct=True)
>> > [x] new syntax: db.mytable.insert(**myuploadfield=open()),
>> thank
>> > you Iceberg
>> > [x] db(...).select(db.mytable.**myfield.count(distinct=True))
>> > [x] teradata adapter, thanks Andrew Willimott
>> > [x] experimental Sybase Adapter
>> > [x] added db.table.field.avg()
>> > [x] Field(... 'upload', default=path) now accepts a path to a
>> local
>> > file as default value, if user does not upload a file. Relative
>> path
>> > looks inside current application folder, thanks Marin
>> > [x] executesql(...,fields=,**columns=) allows parsing of
>> results in
>> > Rows, thanks Anthony
>> >
>> > [x] @auth.requires_login(**otherwise=URL(...))
>> > [x] CRYPT now defaults to pbkdf2(1000,20,sha1)
>> > [x] allow storage of uploads on any PyFileSystem (including
>> amazon)
>> >
>> > [x] more export options in SQLFORM.grid and SQLFORM.smartgrid
>> (html,
>> > xml, csv, ...)
>> >
>> > [x] new layout based on Twitter Bootstrap
>> > [x] New generic views: generic.ics (Mac Mail Calendar) and
>> > generic.map (Google Maps)
>> > [x] request.args(0,default=0, cast=int, otherwise=URL(...)),
>> thanks
>> > Anthony
>> > [x] redirect(...,type='auto') will be handled properly in ajax
>> responses
>> > [x] routes in can redirect outside with
>> > routes_in=[('/path','303->**http://..')]
>> > [x] .coffee and .less support in response.files, thanks Sam
>> Sheftel
>> > [x] ldap certificate support
>> > [x] pg8000 postgresql driver support (experimental)
>> >
>> > [x] db.table.field.like(...,case_**sensitive=False) (thanks
>> Floyd)
>> > [x] db.table.field.regexp(...) for sqlite and postgres
>> > [ ] db(...,ignore_common_filters=**True)
>> > [x] db(db.dog_id.belongs(db.dogs.**owner=='james')).select()
>> > [ ] db(...).select().group_by_**value(db.table.field) (thanks
>> Yair)
>> > [x] db = DAL('imap://user:password@**server:port') support
>> (thanks
>> > Alan Etkin)
>> > [x] db = DAL('teradata://DSN=dsn;UID=**user;PWD=pass;
>> > DATABASE=database') (thanks Adrew Willmott)
>> > [x] db = 
>> DAL('mongodb://127.0.0.1:5984/**db<
>> http://127.0.0.1:5984/db>
>> > ') (experimental, thanks Mark
>> Breedveld)
>> > 

Re: [web2py] Changing the HTML attribute of fields generated by SQLFORM

2012-09-02 Thread Bruno Rocha
Server side DOM.

An example:

mysubmitbutton = form.elements('input[type=submit]')[0]
mysubmitbutton["_value"] = "GO"
mysubmitbutton["_class"] = "btn btn-primary"

Other example, if you want to change the class of all "input" objects.

inputs = form.elements("input')
for input in inputs:
input['_class'] = 'form-input'



On Sun, Sep 2, 2012 at 3:01 PM, Dadepo Aderemi  wrote:

> Dear All,
> How would HTML attributes like id, class etc be added to a form generated
> using the SQLFORM? I know with FORM, you can easily use the attribute name
> prepended with an underscore "_" to set the properties. How can this be
> done with SQLFORM?
>
> Specifically I am looking at adding an HTML class attribute to SUBMIT
> button generated?
>
> Would appreciate the help.
>
> Kind Regards!
>
>  --
>
>
>
>

-- 





Re: [web2py] Re: How to persist session data for user across browsers

2012-09-01 Thread Bruno Rocha
I think you can use cache.

user_data = cache.ram("user_data_%s" % auth.user_id, lambda :
dict(field=value, field=value), 86400)

-- 





Re: [web2py] Use web2py to create offline desktop application

2012-09-01 Thread Bruno Rocha
Yes!

You have some options:

1 Use sqlite locally, use rocket server (built-in), use py2exe to pack your
app as a windows application .exe, or py2app to pack as apple application.
Take a look on to this:
http://web2py.com/books/default/chapter/29/14#How-to-distribute-your-applications-as-binaries

2 Use rad2py with its gui2py
http://code.google.com/p/rad2py/


On Sat, Sep 1, 2012 at 9:46 PM, luckysmack  wrote:

> I am curious, if there could be a way to use web2py to create an
> installable desktop application. The app would be based on a web app so
> would have much of the same code.  I would want/hope to find a way to
> bundle a local database (mongodb or couchdb if it works with web2py) and
> have the local db sync to the server when changes are made. For a UI, i
> would probably keep it web based and see if I could package it with a
> webkit instance, or have it open in the browser as the main ui, this way I
> can still use html/js for the front end as the web app is.
>
> Example. Say that online there is a large product catalog. each company
> has their own catalog. when using the offline app, you would authenticate
> with the server first, then once authenticated, it would download/sync your
> companies catalog to your local server/computer. Then you could work with
> it even while there is no internet. When you come back on line (or as youre
> using it) it would sync/stay in sync with the server. Syncing, i know is
> another task unto itself. But in this case, one could use this offline app
> as a POS system for an in store purchase. when you add a product it syncs
> with the server.
>
> Is there any way this can be done with web2py?
>
> --
>
>
>
>

-- 





Re: [web2py] Re: web2py book on github

2012-09-01 Thread Bruno Rocha
Also mention that this

[x] new syntax: db.mytable.insert(myuploadfield=open()), thank you
Iceberg

Now works as:

[ ] db.table.myuploadfield.default = open()

-- 





Re: [web2py] Re: web2py book on github

2012-09-01 Thread Bruno Rocha
Include this:

[ ] Rows.find(lambda row: bool(), limitby=(0,1))

-- 





Re: [web2py] web2py appliance released by Turnkey Linux

2012-09-01 Thread Bruno Rocha
It is running web2py 1.99.7, is there a way they upgrade to 2.0.5 ?

*Bruno Cezar Rocha** - @rochacbruno*
rochacbr...@gmail.com | Mobile: +55 (11) 99210-8821
www.CursoDePython.com.br | www.rochacbruno.com.br
Blog: Using Python to get all the external links from a
webpage
  Get a signature like this.

Click
here.



On Sat, Sep 1, 2012 at 4:47 PM, rik goldman  wrote:

> TurnKey Linux did it. Web2py appliance now available in several forms from
> http://www.turnkeylinux.org/web2py.
>
> --
>
>
>
>

-- 





Re: [web2py] help with apache

2012-08-31 Thread Bruno Rocha
There is something here: http://ubuntuforums.org/showthread.php?t=1636667

On Fri, Aug 31, 2012 at 7:02 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Address already in use: make_sock: could not bind to address [::]:80

-- 





Re: [web2py] Upgrade to 2.0.x - AttributeError: 'Table' object has no attribute 'permissionid'

2012-08-31 Thread Bruno Rocha
did you turned lazy_tables to True on your db definition?

Bruno Rocha
http://rochacbruno.com.br
mobile
 Em 31/08/2012 10:02, "Jim S"  escreveu:

> Getting the following:
>
> Traceback (most recent call last):
>   File "C:\dev\web2py\gluon\restricted.py", line 209, in restricted
> exec ccode in environment
>   File "C:/dev/web2py/applications/infocenter/models/db.py" 
> <http://127.0.0.1:8000/admin/default/edit/infocenter/models/db.py>, line 152, 
> in 
> format='%(name)s')
>   File "C:\dev\web2py\gluon\dal.py", line 7047, in define_table
> table = self.lazy_define_table(tablename,*fields,**args)
>   File "C:\dev\web2py\gluon\dal.py", line 7078, in lazy_define_table
> polymodel=polymodel)
>   File "C:\dev\web2py\gluon\dal.py", line 920, in create_table
> fake_migrate=fake_migrate)
>   File "C:\dev\web2py\gluon\dal.py", line 988, in migrate_table
> and not isinstance(table[key].type, SQLCustomType) \
>   File "C:\dev\web2py\gluon\dal.py", line 7559, in __getitem__
> return ogetattr(self, str(key))
> AttributeError: 'Table' object has no attribute 'permissionid'
>
> Relevant define_table in db.py:
>
> link = db.define_table('link',
> Field('linkId', 'id', readable=False),
> Field('name', length=50, required=True, unique=True),
> Field('parentLinkId', 'reference link', required=True,
>   label='Parent Link'),
> Field('controller', length=512, required=True),
> Field('method', length=512, required=True),
> Field('picture', length=512, required=False),
> Field('permissionId', db.auth_permission, label='Rqd Permission'),
> Field('groupId', db.auth_group, label='Rqd Group'),
> Field('description', 'text', required=True),
> format='%(name)s')
>
>
> This is line 152.  If I change it to the following (added .id to
> definition of permissionId field reference) :
>
> link = db.define_table('link',
>  Field('linkId', 'id', readable=False),
>  Field('name', length=50, required=True, unique=True),
>  Field('parentLinkId', 'reference link', required=True,
>  label='Parent Link'),
>  Field('controller', length=512, required=True),
>  Field('method', length=512, required=True),
>  Field('picture', length=512, required=False),
>  Field('permissionId', db.auth_permission.id, label='Rqd Permission'),
>  Field('groupId', db.auth_group, label='Rqd Group'),
>  Field('description', 'text', required=True),
>  format='%(name)s')
>
> Then I get the following traceback:
>
> Traceback (most recent call last):
>   File "C:\dev\web2py\gluon\restricted.py", line 209, in restricted
> exec ccode in environment
>   File "C:/dev/web2py/applications/infocenter/models/db.py" 
> <http://127.0.0.1:8000/admin/default/edit/infocenter/models/db.py>, line 152, 
> in 
> format='%(name)s')
>   File "C:\dev\web2py\gluon\dal.py", line 7047, in define_table
> table = self.lazy_define_table(tablename,*fields,**args)
>   File "C:\dev\web2py\gluon\dal.py", line 7078, in lazy_define_table
> polymodel=polymodel)
>   File "C:\dev\web2py\gluon\dal.py", line 721, in create_table
> elif field_type.startswith('reference'):
>   File "C:\dev\web2py\gluon\dal.py", line 8122, in startswith
> raise SyntaxError, "startswith used with incompatible field type"
> SyntaxError: startswith used with incompatible field type
>
> Any ideas where to look for this one?
>
> -Jim
>
>  --
>
>
>
>

-- 





Re: [web2py] Sites not working on http://web2py.com/poweredby

2012-08-30 Thread Bruno Rocha
3 of them are hosted on my server. unfortunatelly I got problems migrating
my VPS and I am working on this.

Bruno Rocha
http://rochacbruno.com.br
mobile
Em 31/08/2012 02:25, "Jemes Hsu"  escreveu:

-- 





Re: [web2py] urgent mysql, postgresql, firebird, ... users.

2012-08-30 Thread Bruno Rocha
Now I got this:

bcr@vaiubuntu:~/projects/web2py203$ python web2py.py -a 1234
Traceback (most recent call last):
  File "web2py.py", line 18, in 
import gluon.widget
  File "/home/bcr/projects/web2py203/gluon/__init__.py", line 15, in

from globals import current
  File "/home/bcr/projects/web2py203/gluon/globals.py", line 24, in 
from serializers import json, custom_json
  File "/home/bcr/projects/web2py203/gluon/serializers.py", line 11, in

from languages import lazyT
  File "/home/bcr/projects/web2py203/gluon/languages.py", line 242, in

PLURAL_RULES = read_possible_plurals()
  File "/home/bcr/projects/web2py203/gluon/languages.py", line 223, in
read_possible_plurals
import gluon.contrib.plural_rules as package
ImportError: No module named plural_rules
bcr@vaiubuntu:~/projects/web2py203$

-- 





Re: [web2py] urgent mysql, postgresql, firebird, ... users.

2012-08-30 Thread Bruno Rocha
Reverted to old checkout and it worked again, so the passwd it not wrong..

On Fri, Aug 31, 2012 at 1:41 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> I do not think this is related. Sure this worked before? Looks like
> legitimate wrong password.
>
>
> On Thursday, 30 August 2012 23:27:57 UTC-5, rochacbruno wrote:
>>
>>  TICKET ID
>>
>> 127.0.0.1.2012-08-31.01-09-21.**3e3284ec-20dd-4076-9a0b-**889f72a85cf7
>>  Failure to connect, tried 5 times:
>> Traceback (most recent call last): File 
>> "/home/bcr/projects/web2py21/**gluon/dal.py",
>> line 6722, in __init__ self._adapter = ADAPTERS[self._dbname](*args) File
>> "/home/bcr/projects/web2py21/**gluon/dal.py", line 2440, in __init__
>> self.pool_connection(connect) File 
>> "/home/bcr/projects/web2py21/**gluon/dal.py",
>> line 553, in pool_connection self.connection = f() File
>> "/home/bcr/projects/web2py21/**gluon/dal.py", line 2439, in connect
>> return self.driver.connect(msg,driver_args) File
>> "/usr/lib/python2.7/dist-**packages/psycopg2/__init__.py"**, line 179,
>> in connect connection_factory=connection_**factory, async=async)
>> OperationalError: FATAL: password authentication failed for user "postgres"
>> FATAL: password authentication failed for user "postgres" VERSION web2py™ (2,
>> 0, 3, datetime.datetime(2012, 8, 30, 23, 7, 46), 'stable') PythonPython
>> 2.7.3: /usr/bin/python TRACEBACK
>>
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>> 17.
>> 18.
>> 19.
>> 20.
>> 21.
>> 22.
>> 23.
>> 24.
>> 25.
>> 26.
>> 27.
>> 28.
>> 29.
>> 30.
>> 31.
>> 32.
>> 33.
>>
>>
>> Traceback (most recent call last):
>>   File "/home/bcr/projects/web2py21/**gluon/restricted.py", line 209, in 
>> restricted
>>
>>
>>
>> exec ccode in environment
>>   File 
>> "/home/bcr/projects/web2py21/**applications/menuvegano/**controllers/article.py"
>>  
>> ,
>>  line 180, in 
>>
>>
>>
>>   File "/home/bcr/projects/web2py21/**gluon/globals.py", line 185, in 
>> 
>>
>>
>>
>> self._caller = lambda f: f()
>>
>>
>>
>>   File 
>> "/home/bcr/projects/web2py21/**applications/menuvegano/**controllers/article.py"
>>  
>> ,
>>  line 7, in show
>>
>>
>>
>> article = Article('show')
>>
>>
>>
>>   File "applications/menuvegano/**modules/handlers/base.py", line 32, in 
>> __init__
>>
>>
>>
>> self.start()
>>
>>
>>
>>   File "applications/menuvegano/**modules/handlers/article.py", line 16, in 
>> start
>>
>>
>>
>> self.db = DataBase([User, UserTimeLine, ContentType, Category, Article, 
>> Favoriters, Subscribers, Likers, Dislikers, Comments, CommentVotes])
>>
>>
>>
>>   File "applications/menuvegano/**modules/movuca.py", line 37, in __init__
>>
>>
>>
>> check_reserved=['all'])
>>
>>
>>
>>   File "/home/bcr/projects/web2py21/**gluon/dal.py", line 6741, in __init__
>>
>>
>>
>> raise RuntimeError, "Failure to connect, tried %d times:\n%s" % 
>> (attempts, tb)
>>
>>
>> RuntimeError: Failure to connect, tried 5 times:
>>
>>
>> Traceback (most recent call last):
>>   File "/home/bcr/projects/web2py21/**gluon/dal.py", line 6722, in __init__
>>
>>
>>
>> self._adapter = ADAPTERS[self._dbname](*args)
>>
>>
>>
>>   File "/home/bcr/projects/web2py21/**gluon/dal.py", line 2440, in __init__
>>
>>
>>
>> self.pool_connection(connect)
>>
>>
>>
>>   File "/home/bcr/projects/web2py21/**gluon/dal.py", line 553, in 
>> pool_connection
>>
>>
>>
>> self.connection = f()
>>
>>
>>
>>   File "/home/bcr/projects/web2py21/**gluon/dal.py", line 2439, in connect
>>
>>
>>
>> return self.driver.connect(msg,**driv**er_args)
>>
>>
>>
>>   File "/usr/lib/python2.7/dist-**packages/psycopg2/__init__.py"**, line 
>> 179, in connect
>>
>>
>>
>> connection_factory=connection_**factory, async=async)
>>
>>
>> OperationalError: FATAL:  password authentication failed for user "postgres"
>>
>>
>> FATAL:  password authentication failed for user "postgres"
>>
>>
>>
>>
>> ERROR SNAPSHOT [image: help]
>>
>> (**Failure to connect, tried 5 times:
>> Traceback (most recent call last): File 
>> "/home/bcr/projects/web2py21/**gluon/dal.py",
>> line 6722, in __init__ self._adapter = ADAPTERS[self._dbname](*args) File
>> "/home/bcr/projects/web2py21/**gluon/dal.py", line 2440, in __init__
>> self.pool_connection(connect) File 
>> "/home/bcr/projects/web2py21/**gluon/dal.py",
>> line 553, in pool_connection self.connection = f() File
>> "/home/bcr/projects/web2py21/**gluon/dal.py", line 2439, in connect
>> return self.driver.connect(msg,driver_args) File
>> "/usr/lib/python2.7/dist-**packages/psycopg2/__init__.py"**, line 179,
>> in connect connection_factory=connection_**factory, async=async)
>> OperationalError: FATAL: password authentication failed for user "postgres"
>> FATAL: password authentication failed for user "postgres" )
>>
>>  --
>
>
>
>

-- 





Re: [web2py] urgent mysql, postgresql, firebird, ... users.

2012-08-30 Thread Bruno Rocha
 TICKET ID

127.0.0.1.2012-08-31.01-09-21.3e3284ec-20dd-4076-9a0b-889f72a85cf7
 Failure to connect, tried 5 times:
Traceback (most recent call last): File
"/home/bcr/projects/web2py21/gluon/dal.py", line 6722, in __init__
self._adapter = ADAPTERS[self._dbname](*args) File
"/home/bcr/projects/web2py21/gluon/dal.py", line 2440, in __init__
self.pool_connection(connect) File
"/home/bcr/projects/web2py21/gluon/dal.py", line 553, in pool_connection
self.connection = f() File "/home/bcr/projects/web2py21/gluon/dal.py", line
2439, in connect return self.driver.connect(msg,**driver_args) File
"/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, in
connect connection_factory=connection_factory, async=async)
OperationalError: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres" VERSION web2py™ (2,
0, 3, datetime.datetime(2012, 8, 30, 23, 7, 46), 'stable') PythonPython
2.7.3: /usr/bin/python TRACEBACK


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.


Traceback (most recent call last):
  File "/home/bcr/projects/web2py21/gluon/restricted.py", line 209, in
restricted

exec ccode in environment
  File 
"/home/bcr/projects/web2py21/applications/menuvegano/controllers/article.py"
,
line 180, in 

  File "/home/bcr/projects/web2py21/gluon/globals.py", line 185, in 

self._caller = lambda f: f()

  File 
"/home/bcr/projects/web2py21/applications/menuvegano/controllers/article.py"
,
line 7, in show

article = Article('show')

  File "applications/menuvegano/modules/handlers/base.py", line 32, in __init__

self.start()

  File "applications/menuvegano/modules/handlers/article.py", line 16, in start

self.db = DataBase([User, UserTimeLine, ContentType, Category,
Article, Favoriters, Subscribers, Likers, Dislikers, Comments,
CommentVotes])

  File "applications/menuvegano/modules/movuca.py", line 37, in __init__

check_reserved=['all'])

  File "/home/bcr/projects/web2py21/gluon/dal.py", line 6741, in __init__

raise RuntimeError, "Failure to connect, tried %d times:\n%s" %
(attempts, tb)
RuntimeError: Failure to connect, tried 5 times:
Traceback (most recent call last):
  File "/home/bcr/projects/web2py21/gluon/dal.py", line 6722, in __init__

self._adapter = ADAPTERS[self._dbname](*args)

  File "/home/bcr/projects/web2py21/gluon/dal.py", line 2440, in __init__

self.pool_connection(connect)

  File "/home/bcr/projects/web2py21/gluon/dal.py", line 553, in pool_connection

self.connection = f()

  File "/home/bcr/projects/web2py21/gluon/dal.py", line 2439, in connect

return self.driver.connect(msg,**driver_args)

  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line
179, in connect

connection_factory=connection_factory, async=async)
OperationalError: FATAL:  password authentication failed for user "postgres"
FATAL:  password authentication failed for user "postgres"


ERROR SNAPSHOT [image: help]

(Failure to connect, tried 5 times:
Traceback (most recent call last): File
"/home/bcr/projects/web2py21/gluon/dal.py", line 6722, in __init__
self._adapter = ADAPTERS[self._dbname](*args) File
"/home/bcr/projects/web2py21/gluon/dal.py", line 2440, in __init__
self.pool_connection(connect) File
"/home/bcr/projects/web2py21/gluon/dal.py", line 553, in pool_connection
self.connection = f() File "/home/bcr/projects/web2py21/gluon/dal.py", line
2439, in connect return self.driver.connect(msg,**driver_args) File
"/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, in
connect connection_factory=connection_factory, async=async)
OperationalError: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres" )

-- 





Re: [web2py] Cannot install on computer

2012-08-30 Thread Bruno Rocha
Which version of web2py? which version of windows?

BTW: You have not to install web2py, web2py is executable, no need to
install!

If you downloaded the windows version .exe you just need to run it (if it
is not working, please tell us your version of windows and web2py)

If you download the source_code version **recommended** you just need to
unzip it, then you need to install Python, go to www.python.org and install
version 2.7 for windows. After having Python installed open a windows
command line: I guess you can do it clicking on start button then write
"cmd" on the text box there.

On cmd:

> cd c:\myuserfolder\Downloads\web2py

** the path where you unzipped

then

> c:\python27\python.exe web2py.py



On Thu, Aug 30, 2012 at 9:23 PM, lukedc  wrote:

> Hi everyone,
>
> I know that this is a dumb question, but i could not find an answer to it
> anywhere i looked. I am just instaling web2py, but when I click on the 
> web2py.exe,
> it does not work. just a quick cmd screen comes up and then goes away real
> quick. What should I do? I don't know how to install from the command
> prompt.
>
> Thank you so much, Luke
>
> --
>
>
>
>

-- 





Re: [web2py] Re: Versioning static files or other options for browser cache reloading

2012-08-30 Thread Bruno Rocha
I think it is now working, I checked the source and there is:

if isinstance(item,str):
f = item.lower().split('?')[0]
if f.endswith('.css'):  s += css_template % item
elif f.endswith('.js'): s += js_template % item
elif f.endswith('.coffee'): s += coffee_template % item
elif f.endswith('.less'): s += less_template % item
elif isinstance(item,(list,tuple)):

So "f" is splitted by "?", but I have not tested.

-- 





Re: [web2py] Re: Lazy_tables with virtual fields

2012-08-30 Thread Bruno Rocha
How are you defining the db connection? are you using models or modules?
which db?

-- 





Re: [web2py] "Tweet this" and web2py forms. How do I design this?

2012-08-30 Thread Bruno Rocha
It is only possible if you have implemented OAuth and user gave access
permission for your application.

-- 





Re: [web2py] Re: Versioning static files or other options for browser cache reloading

2012-08-30 Thread Bruno Rocha
I tested this on a project (maybe web2py version -1.97)

response.files.append(URL('static', 'css', args='myfile.css',
vars=dict(v=get_random(

I dont know if it is working now, but I used the plan html for doing this.

-- 





Re: [web2py] "Tweet this" and web2py forms. How do I design this?

2012-08-30 Thread Bruno Rocha
Without OAuth and permissions I only can see one way.

The twitter url for tweets is:

def tweet():
tweet_url =
"https://twitter.com/intent/tweet?original_referer=%(referer)s&related=%(related)s&source=%(source)s&text=%(text)s"
form = SQLFORM(db.tweets)
if form.process().accepted:
if form.vars.tweetthis:
data = dict(referer="mysiteurl.com",
related="mytwittername",
source="myappname",
text=form.vars.tweet_text)
redirect(tweet_url % data)  # here you can choose to use
Javascript and open in a popup (aditional logic needed)
return dict(form=form)


On Thu, Aug 30, 2012 at 4:17 PM, Pystar  wrote:
>
> I have a form that includes a "tweet this" select box option. I would like to 
> tweet the contents of the textarea which is the only form field and at the 
> same time submit the form to a database. I am at a loss on how to develop 
> this. Is it possible with web2py. Considering the fact that I am only using 
> the inbuilt auth for user authentication.
>
> --
>
>
>

-- 





Re: [web2py] Re: Versioning static files or other options for browser cache reloading

2012-08-30 Thread Bruno Rocha
I cant understand how versioned folders would help on this case? I ran on
to this issue a long time ago and I ended using pure html for this.


Re: [web2py] Changes in trunk when accessing a field in a row?

2012-08-29 Thread Bruno Rocha
can you show the code?

I am using

db.table.field.compute = lambda row: row.otherfield



On Wed, Aug 29, 2012 at 4:09 PM, Daniel Gonzalez  wrote:

> Hi,
>
> I have recently updated trunk.
>
> I am using a compute function when creating new entries. In the compute
> function I access the field row.email. Previously this was giving me the
> *value* of the field, now I just get a reference to "gluon.dal.Field".
>
> Is this expected? How can I access the value of the field?
>
> Thanks,
> Daniel
>
> --
>
>
>
>

-- 





Re: [web2py] Multiple tables or a single big one?

2012-08-29 Thread Bruno Rocha
I generally do this on user function:

profile_fields = ['first_name', 'last_name', 'email', 'description',
'picture']

if 'profile' in request.args:
for field in db.auth_user.fields:
if field not in profile_fields:
db.auth_user[field].readable = db.auth_user[field].writable =
False



On Wed, Aug 29, 2012 at 3:24 PM, Alec Taylor  wrote:

> I have been extending my auth_user table with a bunch of new options.
>
> When there's a 1:1 relation with the user, I'll store it in their profile.
>
> On 1:n, I'll keep them in separate tables.
>
> Now I am realising the problems with doing it this way. To make my
> register form "nice" I have set almost all fields with readable=False and
> writable=False.
>
> This means that I can no longer use the crud.create or crud.update form
> creator helpers on those subset of a users' profile I want the form to
> change for them.
>
> But it also has its advantage: no extra queries are required to grab all
> the 1:1 fields of a users' profile after login.
>
> Is this enough of an advantage?
>
> Thanks for all suggestions,
>
> Alec Taylor
>
> --
>
>
>
>

-- 





Re: [web2py] Removing labels from forms

2012-08-29 Thread Bruno Rocha
placeholders = {
"name": "fill in your name",
   "email": "enter a valid email address"
}

for input in form.elements("input[type='text']"):
input["_placeholder"] = placeholders.get(input["_name"], "")


On Wed, Aug 29, 2012 at 3:07 PM, Alec Taylor  wrote:

> Thanks, also would there be a loop I can add before that to set the
> placeholder of each input?
>
> On Thu, Aug 30, 2012 at 3:58 AM, Bruno Rocha 
> wrote:
> > for label in form.elements('label'):
> > label["_style"] = "display:none;"
> >
> >
> >
> >
> > On Wed, Aug 29, 2012 at 2:47 PM, Alec Taylor 
> wrote:
> >>
> >> How do I remove labels from forms?
> >>
> >> I want to use placeholders instead...
> >>
> >> (this is for the auth.register form)
> >>
> >> Thanks for all suggestions,
> >>
> >> Alec Taylor
> >>
> >> --
> >>
> >>
> >>
> >
> >
> > --
> >
> >
> >
>
> --
>
>
>
>

-- 





Re: [web2py] Removing labels from forms

2012-08-29 Thread Bruno Rocha
for label in form.elements('label'):
label["_style"] = "display:none;"




On Wed, Aug 29, 2012 at 2:47 PM, Alec Taylor  wrote:

> How do I remove labels from forms?
>
> I want to use placeholders instead...
>
> (this is for the auth.register form)
>
> Thanks for all suggestions,
>
> Alec Taylor
>
> --
>
>
>
>

-- 





Re: [web2py] Re: {{code}} compile in view

2012-08-29 Thread Bruno Rocha
You can use template render

from gluon.template import render

html = "{{=name}} {{for x in range(10)}} Hello {{pass}}"

print render(content=html, context=dict(name="Bruno"))



On Wed, Aug 29, 2012 at 1:14 PM, lucas  wrote:

> ok, that is fine for simple code execution, but what of the more complex?
> how does web2py execute all of that complex code we can embed within a
> view?  that is what i want to reproduce in my scheme.
>
> --
>
>
>
>

-- 





Re: [web2py] Avoiding loading models for the public portion of a site

2012-08-28 Thread Bruno Rocha
- You can use conditional models.

- You can use IF on models

if not request.controller == "public":
# my logic goes here

- You can go to the option B (simple separate app)

- You can serve the login form as static html file
http://yourapp/static/public.html

- You can use lazy_tables and not worry about it.


On Tue, Aug 28, 2012 at 10:52 PM, Yarin  wrote:

> A basic architecture question:
>
> We're putting together a typical web app where non-logged in users reach a
> public-facing basic 'brochure' site, and then log in to reach the 'real'
> application. With such a setup, it makes no sense to be loading models for
> the public portion of the site, as it's just some semi-static pages and a
> login form. So I'm wondering
>
>- a) Is there a way to prevent models loading at the request or
>controller level?
>- b) Should the 'public' site be part of the same application at all,
>or should it be a separate light-weight application with a login form that
>then points to the 'real' application?
>
>  --
>
>
>
>

-- 





Re: [web2py] more benchmarks of web2py 2.0 in trunk

2012-08-28 Thread Bruno Rocha
For me on Linux Ubuntu 12.10

bcr@vaiubuntu:~/projects/web2py21$ python web2py.py -S welcome -N -R
../thisfile.py
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2012
Version 2.00.1 (2012-08-28 14:26:44) rc4
Database drivers available: SQLite3, pymysql, psycopg2, pg8000, IMAP

time to access field obj 8.60691070557e-07
time to select 1000 recods 2.90545892715e-05
time to access field values 5.29289245605e-07

Changed cacheable to True

time to access field obj 6.69956207275e-07
time to select 1000 recods 2.16320896149e-05
time to access field values 3.38554382324e-07

Lazy Tables = True

time to access field obj 5.79357147217e-07
time to select 1000 recods 2.04881191254e-05
time to access field values 3.60012054443e-07


Using cache.ram

t0 = time.time()
for k in range(n):
rows = cache.ram("test", lambda: db(db.test).select(cacheable=True),
1200) # (*)
print 'time to select 1000 recods',(time.time()-t0)/n/1000

row = cache.ram("test", lambda: db(db.test).select(cacheable=True),
1200).first() # (*)
t0 = time.time()
for k in range(n):
y = row.id
y = row.one
print 'time to access field values',(time.time()-t0)/n


time to access field obj 8.60691070557e-07
time to select 1000 recods 3.34150791168e-07
time to access field values 2.59876251221e-07




On Tue, Aug 28, 2012 at 4:43 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> # run with web2py.py -S welcome -N -R thisfile.py
>
> import time
>
> db=DAL()
> db.define_table('test',Field('one'))
> db(db.test).delete()
> for k in range(1000):
> db.test.insert(one='one')
> db.commit()
>
> n = 100
> t0 = time.time()
> for k in range(n):
> y = db.test.one
> print 'time to access field obj',(time.time()-t0)/n
>
> t0 = time.time()
> for k in range(n):
> rows = db(db.test).select(cacheable=False) # (*)
>
> print 'time to select 1000 recods',(time.time()-t0)/n/1000
>
> row = db(db.test).select().first()
> t0 = time.time()
> for k in range(n):
> y = row.id
> y = row.one
> print 'time to access field values',(time.time()-t0)/n
>
> """
>
> Results:
>
>
>
> web2py 1.99.7
>
>
>
> time to access field obj 5.068 (microseconds)
>
> time to select 1000 recods  38.441 (microseconds)
>
> time to access field values  7.710 (microseconds)
>
> total time to access one field for each of 1000 records: 7748
> (microseconds)
>
>
> web2py 2.0
>
> time to access field obj 0.579 (microseconds)
>
> time to select 1000 recods  33.820 (microseconds)
>
> time to access field values  0.338 (microseconds)
>
> total time to access one field for each of 1000 records: 371
> (microseconds)
>
>
> web2py 2.0 w cacheable = True (*)
>
>
>
> time to access field obj 0.579 (microseconds)
>
> time to select 1000 recods  24.741 (microseconds)
>
> time to access field values  0.300 (microseconds)
>
> total time to access one field for each of 1000 records: 324
> (microseconds)
>
>
> (benhcmarks with SQLite on Mac Air and python 2.7)
>
> """
>
> --
>
>
>
>

-- 





Re: [web2py] Major speed improvement need testers

2012-08-27 Thread Bruno Rocha
To solve this issue include in the line 88 of myapp.py

https://github.com/rochacbruno/web2py_model_less_app/blob/master/modules/myapp.py#L88

self._LAZY_TABLES = []



On Mon, Aug 27, 2012 at 11:33 PM, Andrew  wrote:

> Possible Issue, this might be due to the dal changes (or it could be me?):
>
> I'm running a variation of Bruno's Modelless App (and I tried his out of
> the box) https://github.com/rochacbruno/web2py_model_less_app
> , and I get:
>
>
> AttributeError: 'DataBase' object has no attribute '_LAZY_TABLES'
>
>
>
>
> On Sunday, August 26, 2012 8:37:16 AM UTC+12, Massimo Di Pierro wrote:
>>
>> Exactly.
>>
>> mytable.myfield.set_**attributes(readable=True,**writable=True)
>>
>> is just a shortcut for
>>
>>mytable.myfield.readable=True
>>mytable.myfield.writable=True
>>
>> without it the lambda notation would not be very usable.
>>
>> On Saturday, 25 August 2012 11:50:10 UTC-5, Jonathan Lundell wrote:
>>>
>>> On 23 Aug 2012, at 7:25 AM, Massimo Di Pierro 
>>> wrote:
>>> > So now in trunk you can do:
>>> >
>>> > db = DAL(lazy_tables=True)
>>> > db.define_table('person',**Field('name'),Field('age','**integer'),
>>> >on_define=lambda table: [
>>> >
>>> > table.name.set_attributes(**requires=IS_NOT_EMPTY(),**default=''),
>>>
>>> >
>>> > table.age.set_attributes(**requires=IS_INT_IN_RANGE(0,**120),default=30),
>>>
>>> >   ])
>>> >
>>> > and the attributes will be set lazily. This is a good idea! Thanks
>>> Jonathan.
>>> >
>>>
>>> Clear something up for me, please. I was a little confused before about
>>> how this was implemented, but I've read the code and it looks like what I
>>> proposed. What I'm not following is the role of set_attributes. Is it
>>> simply to facilitate the lambda? Is this equivalent?
>>>
>>> def on_define(table):
>>>  table.name.requires = IS_NOT_EMPTY()
>>>  table.name.default = ''
>>>  table.age.requires = IS_INT_IN_RANGE(0,120)
>>>  table.age.default = 30
>>>
>>> db = DAL(lazy_tables=True)
>>> db.define_table('person', Field('name'), Field('age','integer'),
>>> on_define=on_define)
>>>
>>  --
>
>
>
>

-- 





Re: [web2py] web2py size

2012-08-26 Thread Bruno Rocha
examples images has 1.1 MB, examples static has 1.9MB


On Sun, Aug 26, 2012 at 8:46 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> According to this the web2py size doubled in Oct 2011 yet I cannot think
> of what caused this.
>
> Can anybody help figure it out? What did we include that doubled the size?
>
> massimo
>
>
>  --
>
>
>
>

-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-26 Thread Bruno Rocha
def show():
item_id = request.args(0)
item_slug = request.args(1)

query = (db.items.id == item_id) & (db.items.slug == item_slug)

item = db(query).select().first()
return dict(item=item)

http:///items/show/1/awesome-product

http:///items/show/2/awesome-product


On Sun, Aug 26, 2012 at 4:01 AM, SeamusSeamus
wrote:

> I would like to make it part of the URLbut am unsure how to do
> it...any tutorials or a quick way?
>
>
> On Saturday, August 25, 2012 6:59:29 PM UTC-6, Anthony wrote:
>>
>> Oh, yeah, I guess you probably can't use the id in a compute because
>> there is no id until the record has been inserted. You could instead make
>> the id part of the URL (like Stack Overflow), or maybe make it a virtual
>> field, or generate your own unique id (separate from the record id).
>>
>> Anthony
>>
>> On Saturday, August 25, 2012 8:34:22 PM UTC-4, SeamusSeamus wrote:
>>>
>>> Thanks for the info Anthony...
>>> When I do this:
>>> Field('slug', compute=lambda row: IS_SLUG()(row.title + "-" + str(
>>> row.id))[0])
>>>
>>>  I get none as a slug...
>>>
>>>
>>>
>>> On Saturday, August 25, 2012 5:53:49 PM UTC-6, Anthony wrote:

 Sure, something like that seems fine. Look at what SO does -- for
 example: http://stackoverflow.**com/questions/12050934/web2py-**
 build-forms-in-controller-or-**view.
 I think they use the number as the unique record identifier, but also
 include a slug (which doesn't necessarily have to be unique).

 Anthony

 On Saturday, August 25, 2012 7:16:50 PM UTC-4, SeamusSeamus wrote:
>
> This runs into a problem where if I have two items of the same
> 'title', the user will only be linked to the first one that was created.
> Can I make it so the slug is a field that I designate? Or make it so the
> slug adds a incrementing number such as:
> Field('slug', compute=lambda row: IS_SLUG()(row.title *+ row.id*
> )[0])
>  I know thats not how you do it, but do you get what I mean? Is there
> a better way?
>
>
> On Thursday, August 23, 2012 1:18:16 AM UTC-6, Anthony wrote:
>>
>> links = [lambda ro
>>> w: A('Details',_href=URL('**default','show', args=[row.slug]))]
>>> fields = [db.equipment.category, db.equipment.title,
>>> db.equipment.price]
>>>
>>
>> You have not included "slug" in your list of fields, so I believe it
>> will not be included in the data query. Instead of specifying the list of
>> fields, you can set the readable attribute to False for fields you don't
>> want displayed (including "slug"). In that case, all fields will be
>> included in the query (including "slug"), but only the fields you want to
>> show will be visible in the grid.
>>
>> Anthony
>>
>  --
>
>
>
>

-- 





Re: [web2py] Web2py MVC pattern using wx for "V"

2012-08-24 Thread Bruno Rocha
this: http://code.google.com/p/gui2py/

-- 





Re: [web2py] Web2py MVC pattern using wx for "V"

2012-08-24 Thread Bruno Rocha
You should see Rad2py, created by Mariano Reingart
http://code.google.com/p/rad2py/

On Fri, Aug 24, 2012 at 6:14 PM, Christian Espinoza wrote:

> Hello guys,
> There are somebody with some experience using wx instead of a web view
> layer??
>
> I have some questions about it, and I want to know if exist some
> example over there...
>
>
> Thanks in advance.
> Christian.
>
> --
>
>
>
>

-- 





Re: [web2py] Model for graph hierarchy (many-to-many ralationship)

2012-08-24 Thread Bruno Rocha
can you try changing db.bookpage to "reference bookpage"
Em 24/08/2012 13:01, "Niphlod"  escreveu:

> There is something else going on. This is the log (no errors creating
> tables) of the following model on mysql 5.5. web2py trunk (but at least on
> table creation nothing should have changed since 1.99.7)
>
> db.define_table('book',
>   Field('bookname')
>   )
>
> db.define_table('bookpage',
> Field('content', 'text'),
> Field('image', 'upload'),
> Field('from_book', db.book),
> Field('modified_on', 'datetime', default=request.now))
>
> db.bookpage.content.requires = IS_NOT_EMPTY()
> db.bookpage.from_book.requires = IS_NOT_EMPTY()
> db.bookpage.modified_on.writable = False
>
> db.define_table('page_link',
> Field('in_page', db.bookpage),
> Field('out_page', db.bookpage),
> Field('the_text'))
>
>
>
>
> timestamp: 2012-08-24T17:58:04.909000
> CREATE TABLE book(
> id INT AUTO_INCREMENT NOT NULL,
> bookname VARCHAR(255),
> PRIMARY KEY(id)
> ) ENGINE=InnoDB CHARACTER SET utf8;
> success!
> timestamp: 2012-08-24T17:58:04.937000
> CREATE TABLE bookpage(
> id INT AUTO_INCREMENT NOT NULL,
> content LONGTEXT,
> image VARCHAR(255),
> from_book INT, INDEX from_book__idx (from_book), FOREIGN KEY (
> from_book) REFERENCES book (id) ON DELETE CASCADE,
> modified_on DATETIME,
> PRIMARY KEY(id)
> ) ENGINE=InnoDB CHARACTER SET utf8;
> success!
> timestamp: 2012-08-24T17:58:04.959000
> CREATE TABLE page_link(
> id INT AUTO_INCREMENT NOT NULL,
> in_page INT, INDEX in_page__idx (in_page), FOREIGN KEY 
> (in_page)REFERENCES bookpage
> (id) ON DELETE CASCADE,
> out_page INT, INDEX out_page__idx (out_page), FOREIGN KEY 
> (out_page)REFERENCES bookpage
> (id) ON DELETE CASCADE,
> the_text VARCHAR(255),
> PRIMARY KEY(id)
> ) ENGINE=InnoDB CHARACTER SET utf8;
> success!
>
>
>
>
>  --
>
>
>
>

-- 





Re: [web2py] Re: Twitter Bootstrap scatfolding application *updated.

2012-08-24 Thread Bruno Rocha
Martin,

what about a twitter bootstrap plugin?

we can create a plugin to inject bootstrap specific helpers.

THUMBNAILS(), POPOVER(), MODAL(), PILLS() also a bootstrap manager.

{{=bootstrapmanager(v=2.1, js=True)}}

So it will be app agnostic.

what do you think about?
Em 24/08/2012 08:37, "Martín Mulone"  escreveu:

> It's just an application, it's just my way of doing thing what I'm
> sharing, I'm not proposing like a  replacement to welcome. Perhaps I have
> to warn to not use it, because is different and I think most of people
> working on web2py have to have your owns scatfolding app or already have
> it. Today is boostrap  perhaps tomorrow is bootstrap 12 or trapboost...I
> have not problem with this. If you like it, go for it.
>
> I usually do in my cycle of making applications: 1) Clone scatfolding
> (lease bootstrap, or whatever  layout popular of the moment ) as a new app
> 2) Hack the scatfold and do the app 3) finish the work and make app ready.
> New app? ok, we need to make changes to scatfold? make changes and start
> again with new app with point 1). I have doing this way for around 2 years
> in web2py and never do a breakage.
>
> I think web2py lacks on giving a very minimal app, is only giving a
> complex welcome, this will perhaps  help to teach basic functions on
> newones. Massimo you talk about the block header, sidebar, I know you have
> to force compatibility, but this kind of programming is wrong in my point
> of view, welcome introduce  some complex code in layout and in view that
> also ruin performance to show some sidebar. The people have to know that is
> developing a web application, so have to learn HTML and CSS, with grid
> system is more easy than ever to make this achiviement.
>
> Yes perhaps anytime is an issue. Flash work like normal nothing new there.
> What is missing, I think only grid I forgot.
>
> Martin.
>
> 2012/8/23 Massimo Di Pierro 
>
>> Martin,
>>
>> it is really well done but, as it is, it not appropriate for out
>> scaffolding app.
>>
>> First of all it relies on many bootstrap specific helpers.
>> Menus work in a different way than documented.
>> Flash has a more complex html structure and does not provide a good
>> example for new users.
>> It is based on anytime.js while we moved to calendar.js.
>> The html lacks the blocks for header, footer and sidebar.
>> Many web2py specific styles are missing.
>>
>> Yours is a more a by-the-book bootstrap app than welcome is but welcome
>> is designed above all to provide an example for new users who may or not
>> want to use bootstrap. The fact that is uses bootstrap is accidental and
>> only affects the CSS.
>>
>> It is in principle possible to merge it with the scaffolding but we would
>> still need to fix menus. Perhaps we should do it but web2py 2.0 has waited
>> long enough, mostly because of css. I would not want to put it off more
>> because we have a new css option.
>>
>> Massimo
>>
>>
>> On Thursday, 23 August 2012 13:48:03 UTC-5, Martin.Mulone wrote:
>>>
>>> Twitter Bootstrap scatfolding application *updated.
>>>
>>> Now is awesome :-P
>>>
>>> * Now based on version 2.1.0 (sync)
>>> * Menu based on twitter bootstrap navbar (support multilevel menu)
>>> * Plugin highlight.
>>> * Many fixes to layout now support responsive.
>>> * Very clean layout.
>>> * Started to document (getting)
>>> * Some examples.
>>> * Flash is render as alert.
>>>
>>> Working demo: 
>>> http://testbootstrap.tecnodoc.**com.ar/
>>> Doc: 
>>> http://testbootstrap.tecnodoc.**com.ar/getting
>>> Source: 
>>> https://bitbucket.org/**mulonemartin/bootstrap
>>>
>>> Note: Not yet fully tested.
>>>
>>  --
>>
>>
>>
>>
>
>
>
> --
>  http://www.tecnodoc.com.ar
>
>  --
>
>
>
>

-- 





Re: [web2py] SQLFORM key error

2012-08-23 Thread Bruno Rocha
web2py version??


On Thu, Aug 23, 2012 at 10:00 PM, pylix  wrote:

> Here's my model
>
> db = DAL('sqlite://storage.sqlite')
> db.define_table('person',
> Field('name', requires=IS_NOT_EMPTY()),
> Field('phone', requires=IS_NOT_EMPTY()),
> Field('address', requires=IS_NOT_EMPTY()),
> Field('city', requires=IS_NOT_EMPTY()),
> Field('state', requires=IS_IN_SET(['NY' ,'NJ' ,'CN'])),
> Field('zip', requires=IS_NOT_EMPTY()),
> Field('year', requires=IS_NOT_EMPTY()),
> Field('model', requires=IS_NOT_EMPTY()),
> Field('make', requires=IS_NOT_EMPTY()),
> Field('engine', requires=IS_NOT_EMPTY()),
> Field('starts', 'boolean'),
> Field('foward', 'boolean'),
> Field('reverse', 'boolean'),
> Field('complaint', 'text'))
>
> the controller is
>
> def freequote():
> form = SQLFORM(db.person)
> return dict(form=form)
>
> and the view
>
> {{extend 'layout.html'}}
> {{=form}}
>
> I'm getting this error when i try to view the page
>  'person'
>
>
> Traceback (most recent call last):
> File "gluon/restricted.py", line 205, in restricted
>
> File "/controllers/default.py" 
> ,
>  line 10, in 
> File "gluon/globals.py", line 173, in 
> File "/controllers/default.py" 
> ,
>  line 8, in freequote
>
> File "gluon/dal.py", line 6343, in __getattr__
>
> File "gluon/dal.py", line 6337, in __getitem__
>
> KeyError: 'person'
>
>
> not sure why i'm getting a keyerror is the table is defined.
>
> --
>
>
>
>

-- 





Re: [web2py] Limit output of a "details" page to only show some items.

2012-08-23 Thread Bruno Rocha
Considering this:

def details():
try:
equipment = db.equipment[int(request.args(0))]
except:
equipment = db(db.equipment.slug == request.args(0)).select().
first()

return dict(equipment=equipment)

Your view details.html should be

{{=equipment.title}}
{{=equipment.description}}
{{=IMG(_src=URL('default', 'download',
args=equipment.image1))}}

*Bruno Cezar Rocha** - @rochacbruno*
rochacbr...@gmail.com | Mobile: +55 (11) 99210-8821
www.CursoDePython.com.br | www.rochacbruno.com.br
Blog: WEB APPS THAT WORTH A
TRY
  Get a signature like this.

Click
here.



On Thu, Aug 23, 2012 at 9:38 PM, SeamusSeamus
wrote:

> I am trying to set a nice clean "details" page that only shows some basic
> information for a product. I do not want ALL information that is being
> storded (such as my slug, private notes field, etc..) to be visable to the
> customer. Now, I have this:
>
> def details():
> try:
> equipment = db.equipment[int(request.args(0))]
> except:
> equipment = db(db.equipment.slug ==
> request.args(0)).select().first()
>
> return dict(equipment=equipment)
>
> and in my details.html I am just using the {{=BEAUTIFY(response._vars)}}
> which is displaying all of the info in a un clean way. What do I need to do
> to just display only a few items, and allow me to place the elements
> anywhere I would like on the page? For example, I just want the 'title',
> 'description' and 'photo' to be shown on the 'details' page. How would I
> make them independant of one another so I can place the image one spot, the
> title another spot (the ) and the description elsewhere ()
> For example
> {{title}}
> {{description}}
> {{image1}}
>
>  I know this may be basic stuff, but I am learning python as I go and
> these forums are a great help. I cannot seem to find my answer in the
> web2py docs.
>
>  --
>
>
>
>

-- 





Re: [web2py] Re: Twitter Bootstrap scatfolding application *updated.

2012-08-23 Thread Bruno Rocha
Put
z-index: 0;

on flash alert

On Thu, Aug 23, 2012 at 4:05 PM, David Marko  wrote:

> The alert 'Well done! ...' conflicts somehow with menu when you click e.g.
> on 'Bootstrap' menu item ...
>
> Dne čtvrtek, 23. srpna 2012 20:48:03 UTC+2 Martin.Mulone napsal(a):
>
>> Twitter Bootstrap scatfolding application *updated.
>>
>> Now is awesome :-P
>>
>> * Now based on version 2.1.0 (sync)
>> * Menu based on twitter bootstrap navbar (support multilevel menu)
>> * Plugin highlight.
>> * Many fixes to layout now support responsive.
>> * Very clean layout.
>> * Started to document (getting)
>> * Some examples.
>> * Flash is render as alert.
>>
>> Working demo: 
>> http://testbootstrap.tecnodoc.**com.ar/
>> Doc: 
>> http://testbootstrap.tecnodoc.**com.ar/getting
>> Source: 
>> https://bitbucket.org/**mulonemartin/bootstrap
>>
>> Note: Not yet fully tested.
>>
>  --
>
>
>
>

-- 





Re: [web2py] Twitter Bootstrap scatfolding application *updated.

2012-08-23 Thread Bruno Rocha
Great!

This new navbar is very better! Thank you Martin!


On Thu, Aug 23, 2012 at 3:48 PM, Martín Mulone wrote:

> Twitter Bootstrap scatfolding application *updated.
>
> Now is awesome :-P
>
> * Now based on version 2.1.0 (sync)
> * Menu based on twitter bootstrap navbar (support multilevel menu)
> * Plugin highlight.
> * Many fixes to layout now support responsive.
> * Very clean layout.
> * Started to document (getting)
> * Some examples.
> * Flash is render as alert.
>
> Working demo: http://testbootstrap.tecnodoc.com.ar/
> Doc: http://testbootstrap.tecnodoc.com.ar/getting
> Source: https://bitbucket.org/mulonemartin/bootstrap
>
> Note: Not yet fully tested.
>
> --
>
>
>
>

-- 





Re: [web2py] Major speed improvement need testers

2012-08-23 Thread Bruno Rocha
On Thu, Aug 23, 2012 at 3:11 PM, Anthony  wrote:

> I'd also still be interested to see a real-world example of where this
> would be useful.
>
> Anthony
>

Someone posted an example of GAE CPU Cycles, with class based Lazy Tables
it lower to half cycles. Also there is another user in the group which has
a huge traffic, so Lazy tables might be useful.

I would like to test it ASAP.

-- 





Re: [web2py] Creating a Contact Form

2012-08-22 Thread Bruno Rocha
how is your mail config?

from gluon.tools import Mail
mail = Mail()
mail.settings.sender = ?
  .server = ?

did you configured the login? is it ok?

use a try block to check which error you get.

try:
mail.send()
except Exception, e:
   print str(e)
Em 23/08/2012 01:18, "SeamusSeamus"  escreveu:

> Hi,
>  I am trying to make a simple contact form that emails me the arguments.
> The email is not sending, and as soon as the page loads, my message 'Unable
> to send email' shows up as an error.
>
> In Controller:
>
> def contactform():
>
> form=SQLFORM.factory(
> Field('your_email',requires=IS_EMAIL()),
> Field('question',requires=IS_NOT_EMPTY()))
> if form.process().accepted:
> if mail.send(to='m...@me.com',
> subject='From %s' % form.vars.your_email,
> message=form.vars.question):
> redirect(URL('confirmation'))
> else:
> form.errors.your_email='Unable to send email'
>
> return dict(form=form)
>
>
> In contactform.load
> {{=form}}
>
> In Contact me page:
> {{=LOAD('contactform.load',ajax=True)}}
>
>
>
>  --
>
>
>
>

-- 





<    1   2   3   4   5   6   7   8   9   10   >