[web2py:34921] TypeError in _insert

2009-11-08 Thread Dominic

Hi,

sql_represent() in sql.py (around line 461) contains:

elif isinstance(obj, (Row, Reference)):
return obj['id']

Shouldn't this be rather:

elif isinstance(obj, (Row, Reference)):
return str(obj['id'])

?

This would avoid a TypeError in _insert().

Kind regards,
Dominic

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



[web2py:34920] Re: testing a SQLFORM with doctest

2009-11-08 Thread Ahmed Soliman

Yes, I would like to hear the answer of that too, what if I want to
prepare a SQLFORM variables to be passed during doctest, how can
possible this happen as we don't know the key that is generated during
form creation?


On Oct 28, 10:44 am, Hamadaaway  wrote:
> Supposing I've a method like :
>
> def test():
>     '''
>     This is a docstring. The following 3 lines are adoctest:
>     >>> request.vars.name='Max'
>     >>> contactForm1 = SQLFORM(db.demo)
>     >>> test()
>     {'name': 'Max' ,'contactForm':contactForm1}
>     '''
>     contactForm = SQLFORM(db.demo)
>     return dict(contactForm=contactForm,name=request.vars.name)
>
> how can I test the SQLFORM usingdoctest, since the previous code
> fails in testing?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34919] Re: Change layout from controller

2009-11-08 Thread rondevu

Sorry skimmed the first person's question my wrong.

On Nov 9, 1:17 pm, mdipierro  wrote:
> That is now what I meant. You can bytecode with any layout. You cannot
> bytecode if the layout filename is stored in a variable instead of a
> contact because the layout is unknown until runtime.
>
> for example {{extend 'mylayout.html'}} you can bytecode
>
> {{extend x}} you cannot bytecode compile because x is undefined at
> compile time.
>
> Massimo
>
> On Nov 8, 9:19 pm, rondevu  wrote:
>
> > I didn't know that you can't bytecode compile with your own layout.
> > Isn't it a limitation if you want to use your own layout?
>
> > What is the solution if you'd want to compile your app with a custom
> > layout?
>
> > Ranjeev
>
> > On Nov 8, 5:53 am, mdipierro  wrote:
>
> > > You can do
>
> > > {{extend mylayout}}
>
> > > where mylayout is a variable passed from the controller to the view
> > > and containing a file name. The only problem with this approach is
> > > that you cannot bytecode compile the app since the layout will be
> > > unknown at compilation time.
>
> > > On Nov 7, 1:05 pm, villas  wrote:
>
> > > > I believe I've seen the answer to this before, but I can't find it.
>
> > > > 1. How does one change the layout from the controller?  Is the best
> > > > way to open the view file and write to it a new {{extend
> > > > 'mylayout.html'}}  as in the new layout plugin ?
>
> > > > 2. Is there a way of including a variable inside {{brackets}} in the
> > > > view?
> > > > I mean if one could put something like {{extend =mylayout}} in the
> > > > view,  it would be easy.  Sorry if that's a naive question!
>
> > > > Thanks,  David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34918] Re: Using web2py with jython

2009-11-08 Thread mdipierro

I changed it in trunk so that it is automatic and now (again) web2py
works with Jython out of the box. I have email the author of
wsgiserver hoping this is fixed in the official distribution.


On Nov 8, 1:56 pm, mdipierro  wrote:
> jython does not seem to support socket option no_delay. In gluon/
> wsgiserver.py replace
>
>  nodelay = True
>
> with
>
>  nodelay = False
>
> Massimo
>
> On Nov 8, 1:48 pm, Nik  wrote:
>
> > Hi folks,
>
> > For testing web2py with jython I have started it
> > by executing  "jython web2py.py" and got the following
> > error message:
>
> > ==
> > saturn:web2py_1.71.2 nik$ jython web2py.py
> > WARNING:root:no file locking
> > WARNING:root:unable to import dbhash
> > WARNING:root:GUI not available because Tk library is not installed
> > default applications appear to be installed already
> > web2py Enterprise Web Framework
> > Created by Massimo Di Pierro, Copyright 2007-2009
> > Version 1.71.2 (2009-11-04 15:48:54)
> > Database drivers available:
> > Starting cron...
> > choose a password:
> > please visit:
> >        http://127.0.0.1:8000
> > use "kill -SIGTERM 949" to shutdown the web2py server
> > Traceback (most recent call last):
> >   File "web2py.py", line 20, in 
> >     gluon.widget.start(cron=True)
> >   File "/Users/nik/work/web/web2py_1.71.2/gluon/widget.py", line 852,
> > in start
> >     server.start()
> >   File "/Users/nik/work/web/web2py_1.71.2/gluon/widget.py", line 852,
> > in start
> >     server.start()
> >   File "/Users/nik/work/web/web2py_1.71.2/gluon/main.py", line 710, in
> > start
> >     self.server.start()
> >   File "/Users/nik/work/web/web2py_1.71.2/gluon/wsgiserver.py", line
> > 1884, in start
> >     self.socket.listen(self.request_queue_size)
> >   File "", line 1, in listen
> >   File "/Users/nik/Applications/jython2.5.1/Lib/socket.py", line 824,
> > in listen
> >     self._config()
> >   File "/Users/nik/Applications/jython2.5.1/Lib/socket.py", line 824,
> > in listen
> >     self._config()
> >   File "/Users/nik/Applications/jython2.5.1/Lib/socket.py", line 763,
> > in _config
> >     self.sock_impl.setsockopt(level, optname, self.pending_options
> > [ (level, optname) ])
> >   File "/Users/nik/Applications/jython2.5.1/Lib/socket.py", line 282,
> > in setsockopt
> >     raise error(errno.ENOPROTOOPT, "Socket option '%s' (level '%s')
> > not supported on socket(%s)" % (_constant_to_name(option),
> > _constant_to_name(level), str(self.jsocket)))
> > socket.error: (42, "Socket option 'TCP_NODELAY' (level 'IPPROTO_TCP')
> > not supported on socket(ServerSocket[addr=/
> > 127.0.0.1,localport=8000])")
> > ==
>
> > Am I missing something here?
>
> > Regards
> > Nik
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34917] Re: Change layout from controller

2009-11-08 Thread mdipierro

That is now what I meant. You can bytecode with any layout. You cannot
bytecode if the layout filename is stored in a variable instead of a
contact because the layout is unknown until runtime.

for example {{extend 'mylayout.html'}} you can bytecode

{{extend x}} you cannot bytecode compile because x is undefined at
compile time.

Massimo

On Nov 8, 9:19 pm, rondevu  wrote:
> I didn't know that you can't bytecode compile with your own layout.
> Isn't it a limitation if you want to use your own layout?
>
> What is the solution if you'd want to compile your app with a custom
> layout?
>
> Ranjeev
>
> On Nov 8, 5:53 am, mdipierro  wrote:
>
> > You can do
>
> > {{extend mylayout}}
>
> > where mylayout is a variable passed from the controller to the view
> > and containing a file name. The only problem with this approach is
> > that you cannot bytecode compile the app since the layout will be
> > unknown at compilation time.
>
> > On Nov 7, 1:05 pm, villas  wrote:
>
> > > I believe I've seen the answer to this before, but I can't find it.
>
> > > 1. How does one change the layout from the controller?  Is the best
> > > way to open the view file and write to it a new {{extend
> > > 'mylayout.html'}}  as in the new layout plugin ?
>
> > > 2. Is there a way of including a variable inside {{brackets}} in the
> > > view?
> > > I mean if one could put something like {{extend =mylayout}} in the
> > > view,  it would be easy.  Sorry if that's a naive question!
>
> > > Thanks,  David
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34916] Re: Change layout from controller

2009-11-08 Thread rondevu

I didn't know that you can't bytecode compile with your own layout.
Isn't it a limitation if you want to use your own layout?

What is the solution if you'd want to compile your app with a custom
layout?

Ranjeev

On Nov 8, 5:53 am, mdipierro  wrote:
> You can do
>
> {{extend mylayout}}
>
> where mylayout is a variable passed from the controller to the view
> and containing a file name. The only problem with this approach is
> that you cannot bytecode compile the app since the layout will be
> unknown at compilation time.
>
> On Nov 7, 1:05 pm, villas  wrote:
>
> > I believe I've seen the answer to this before, but I can't find it.
>
> > 1. How does one change the layout from the controller?  Is the best
> > way to open the view file and write to it a new {{extend
> > 'mylayout.html'}}  as in the new layout plugin ?
>
> > 2. Is there a way of including a variable inside {{brackets}} in the
> > view?
> > I mean if one could put something like {{extend =mylayout}} in the
> > view,  it would be easy.  Sorry if that's a naive question!
>
> > Thanks,  David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34915] Re: Nested Sets implementation

2009-11-08 Thread Vasile Ermicioi
Testing nested sets on GAE got an error

BadFilterError: BadFilterError: invalid filter: Only one property per
query may have inequality filters (<=, >=, <, >)


Just don't know what to do at the moment to make it work...

On Mon, Nov 9, 2009 at 1:51 AM, mdipierro  wrote:

>
> It would be nice to implement in a general way so that once can do:
>
> db.define_table('mytabletree',Field('data_at_node'),Tree
> ('mytabletree'))
>
> where
>
> class Tree:
>   def __call__(self,tablename):
>  return sql.Table(...)
>   other methods
>
> Hope it makes sense. Not sure how doable.
>
> massimo
>
> On Nov 8, 5:40 pm, Thadeus Burgess  wrote:
> > Wow what timing, I was just about to post a similar thing :)
> >
> > http://pastebin.com/f4fc602d7
> >
> > -Thadeus
> >
> > On Sun, Nov 8, 2009 at 5:28 PM, Vasile Ermicioi 
> wrote:
> > > - for using in some queries like direct children (just too lazy to
> think
> > > how to use lft and rgt :) )
> > > - cascade delete (if is supported by the database)
> >
> > > On Mon, Nov 9, 2009 at 1:18 AM, mdipierro 
> wrote:
> >
> > >> what do you need parent_id for when you have lgt and rgt?
> >
> > >> On Nov 8, 5:10 pm, elffikk  wrote:
> > >> > Hi,
> >
> > >> > I started a nested sets implementation
> > >> > Just sharing the code. I welcome any thoughts you have
> >
> > >> > 2 files - nstree_controller (just quick and dirty tests of the
> model),
> > >> > and nstree_model
> >
> > >> > [nstree_controller :]
> >
> > >> > t1 = nstree(db, db.tree1)
> >
> > >> > def index():
> > >> > return dict(message="Version " + nstree.version)
> >
> > >> > def test_path():
> > >> > _id = 33
> > >> > return dict(message = " > ".join([node.name for node in t1.path
> > >> > (_id)]))
> >
> > >> > def test_removetree():
> > >> > _id = request.vars.id if request.vars.id else 3
> > >> > t1.remove_tree(_id)
> > >> > return dict(message="Success")
> >
> > >> > def test_delete():
> > >> > _id = request.vars.id if request.vars.id else 19
> > >> > node = t1.delete(_id)
> > >> > return dict(message= node.name + " deleted ")
> >
> > >> > def test_get():
> > >> > _id = request.vars.id if request.vars.id else 15
> > >> > #nodes = t1.ancestors(_id)
> > >> > #nodes = t1.descendants(_id)
> > >> > nodes = t1.children(_id)
> > >> > return dict(message= ", ".join([node.name for node in nodes]))
> >
> > >> > def test_gettree():
> > >> > root_id = request.vars.root_id if request.vars.root_id else 1
> > >> > nodes = t1.tree(root_id)
> > >> > return dict(message="Count "+str(len(nodes)))
> >
> > >> > def test_add():
> > >> > root_id = request.vars.root_id if request.vars.root_id else
> > >> > t1.roots()[0].id
> > >> > r1 = t1.add(root_id, name='1')
> > >> > r2 = t1.add(root_id, name='2')
> > >> > r3 = t1.add(root_id, name='3')
> > >> > t1.add(r1, name='11')
> > >> > t1.add(r1, name='12')
> > >> > return dict(message="Success")
> >
> > >> > def test_create_roots():
> > >> > '''
> > >> > t1.create_root(name='root1')
> > >> > t1.create_root(name='root2')
> > >> > t1.create_root(name='root3')
> > >> > t1.create_root(name='root4')
> > >> > '''
> > >> > roots = t1.roots()
> > >> > return dict(message="Roots count : " + str(len(roots)))
> >
> > >> > [nstree_model:]
> >
> > >> > db.define_table('tree1',
> > >> > SQLField('name', "string", 128),
> > >> > SQLField('lft','integer'),
> > >> > SQLField('rgt','integer'),
> > >> > SQLField('level','integer'),
> > >> > SQLField('root_id','integer'),
> > >> > SQLField('parent_id','reference tree1'),
> > >> > )
> > >> > #
> > >> > #  A Nested Sets implementation
> > >> > #  need to pass a table with following fields:
> > >> > #  lft, rgt, level, parent_id, root_id - all fields of type int
> > >> > #  ---
> > >> > #  Notes:
> > >> > #  - table can contain multiple roots
> > >> > #
> > >> > class nstree:
> > >> > version = "1.0.0.04"
> > >> > def __init__(self, db, dbtable):
> > >> > self.db = db
> > >> > self.dbtable = dbtable
> > >> > #self.lft = dbtable.lft
> > >> > #self.rgt = dbtable.rgt
> > >> > #self.level = dbtable.level
> > >> > #self.parent_id = dbtable.parent_id
> > >> > #self.root_id = dbtable.root_id
> > >> > #
> > >> > #  Methods for building tree (create, delete nodes)
> > >> > #
> > >> > def create_root(self, **fields):
> > >> > _id = self.dbtable.insert(lft=1, rgt=2, level=0, **fields)
> > >> > _root = self.dbtable[_id]
> > >> > _root.update_record(root_id  = _id)
> > >> > return _root
> > >> > def add(self, parent_id, **fields): return self.add_last_child
> > >> > (parent_id, **fields)
> > >> > def add_last_child(self, parent_id, **fields):
> > >> > _parent = self.dbtable[parent_id]
> > >> > q1 = self.dbtable.rgt >= _parent.rgt
> > >> > q2 = self.dbtable.lft >= _parent.rgt
> > >>

[web2py:34914] Re: Nested Sets implementation

2009-11-08 Thread mdipierro

It would be nice to implement in a general way so that once can do:

db.define_table('mytabletree',Field('data_at_node'),Tree
('mytabletree'))

where

class Tree:
   def __call__(self,tablename):
  return sql.Table(...)
   other methods

Hope it makes sense. Not sure how doable.

massimo

On Nov 8, 5:40 pm, Thadeus Burgess  wrote:
> Wow what timing, I was just about to post a similar thing :)
>
> http://pastebin.com/f4fc602d7
>
> -Thadeus
>
> On Sun, Nov 8, 2009 at 5:28 PM, Vasile Ermicioi  wrote:
> > - for using in some queries like direct children (just too lazy to think
> > how to use lft and rgt :) )
> > - cascade delete (if is supported by the database)
>
> > On Mon, Nov 9, 2009 at 1:18 AM, mdipierro  wrote:
>
> >> what do you need parent_id for when you have lgt and rgt?
>
> >> On Nov 8, 5:10 pm, elffikk  wrote:
> >> > Hi,
>
> >> > I started a nested sets implementation
> >> > Just sharing the code. I welcome any thoughts you have
>
> >> > 2 files - nstree_controller (just quick and dirty tests of the model),
> >> > and nstree_model
>
> >> > [nstree_controller :]
>
> >> > t1 = nstree(db, db.tree1)
>
> >> > def index():
> >> >     return dict(message="Version " + nstree.version)
>
> >> > def test_path():
> >> >     _id = 33
> >> >     return dict(message = " > ".join([node.name for node in t1.path
> >> > (_id)]))
>
> >> > def test_removetree():
> >> >     _id = request.vars.id if request.vars.id else 3
> >> >     t1.remove_tree(_id)
> >> >     return dict(message="Success")
>
> >> > def test_delete():
> >> >     _id = request.vars.id if request.vars.id else 19
> >> >     node = t1.delete(_id)
> >> >     return dict(message= node.name + " deleted ")
>
> >> > def test_get():
> >> >     _id = request.vars.id if request.vars.id else 15
> >> >     #nodes = t1.ancestors(_id)
> >> >     #nodes = t1.descendants(_id)
> >> >     nodes = t1.children(_id)
> >> >     return dict(message= ", ".join([node.name for node in nodes]))
>
> >> > def test_gettree():
> >> >     root_id = request.vars.root_id if request.vars.root_id else 1
> >> >     nodes = t1.tree(root_id)
> >> >     return dict(message="Count "+str(len(nodes)))
>
> >> > def test_add():
> >> >     root_id = request.vars.root_id if request.vars.root_id else
> >> > t1.roots()[0].id
> >> >     r1 = t1.add(root_id, name='1')
> >> >     r2 = t1.add(root_id, name='2')
> >> >     r3 = t1.add(root_id, name='3')
> >> >     t1.add(r1, name='11')
> >> >     t1.add(r1, name='12')
> >> >     return dict(message="Success")
>
> >> > def test_create_roots():
> >> >     '''
> >> >     t1.create_root(name='root1')
> >> >     t1.create_root(name='root2')
> >> >     t1.create_root(name='root3')
> >> >     t1.create_root(name='root4')
> >> >     '''
> >> >     roots = t1.roots()
> >> >     return dict(message="Roots count : " + str(len(roots)))
>
> >> > [nstree_model:]
>
> >> > db.define_table('tree1',
> >> >     SQLField('name', "string", 128),
> >> >     SQLField('lft','integer'),
> >> >     SQLField('rgt','integer'),
> >> >     SQLField('level','integer'),
> >> >     SQLField('root_id','integer'),
> >> >     SQLField('parent_id','reference tree1'),
> >> >     )
> >> > #
> >> > #  A Nested Sets implementation
> >> > #  need to pass a table with following fields:
> >> > #  lft, rgt, level, parent_id, root_id - all fields of type int
> >> > #  ---
> >> > #  Notes:
> >> > #  - table can contain multiple roots
> >> > #
> >> > class nstree:
> >> >     version = "1.0.0.04"
> >> >     def __init__(self, db, dbtable):
> >> >         self.db = db
> >> >         self.dbtable = dbtable
> >> >         #self.lft = dbtable.lft
> >> >         #self.rgt = dbtable.rgt
> >> >         #self.level = dbtable.level
> >> >         #self.parent_id = dbtable.parent_id
> >> >         #self.root_id = dbtable.root_id
> >> >     #
> >> >     #  Methods for building tree (create, delete nodes)
> >> >     #
> >> >     def create_root(self, **fields):
> >> >         _id = self.dbtable.insert(lft=1, rgt=2, level=0, **fields)
> >> >         _root = self.dbtable[_id]
> >> >         _root.update_record(root_id  = _id)
> >> >         return _root
> >> >     def add(self, parent_id, **fields): return self.add_last_child
> >> > (parent_id, **fields)
> >> >     def add_last_child(self, parent_id, **fields):
> >> >         _parent = self.dbtable[parent_id]
> >> >         q1 = self.dbtable.rgt >= _parent.rgt
> >> >         q2 = self.dbtable.lft >= _parent.rgt
> >> >         q3 = self.dbtable.root_id == _parent.root_id
> >> >         self.db(q1)(q3).update(rgt=self.dbtable.rgt+2)
> >> >         self.db(q2)(q3).update(lft=self.dbtable.lft+2)
> >> >         return self.dbtable.insert(
> >> >             parent_id = parent_id,
> >> >             lft = _parent.rgt,
> >> >             rgt = _parent.rgt+1,
> >> >             level = _parent.level+1,
> >> >             root_id = _parent.root_id,
> >> >             **fields
> >> >         )
> >> >     def delete(self, id): return self.remove(id)
> >> >     def r

[web2py:34913] Re: Nested Sets implementation

2009-11-08 Thread Thadeus Burgess
Wow what timing, I was just about to post a similar thing :)

http://pastebin.com/f4fc602d7

-Thadeus




On Sun, Nov 8, 2009 at 5:28 PM, Vasile Ermicioi  wrote:

> - for using in some queries like direct children (just too lazy to think
> how to use lft and rgt :) )
> - cascade delete (if is supported by the database)
>
>
> On Mon, Nov 9, 2009 at 1:18 AM, mdipierro  wrote:
>
>>
>> what do you need parent_id for when you have lgt and rgt?
>>
>>
>>
>> On Nov 8, 5:10 pm, elffikk  wrote:
>> > Hi,
>> >
>> > I started a nested sets implementation
>> > Just sharing the code. I welcome any thoughts you have
>> >
>> > 2 files - nstree_controller (just quick and dirty tests of the model),
>> > and nstree_model
>> >
>> > [nstree_controller :]
>> >
>> > t1 = nstree(db, db.tree1)
>> >
>> > def index():
>> > return dict(message="Version " + nstree.version)
>> >
>> > def test_path():
>> > _id = 33
>> > return dict(message = " > ".join([node.name for node in t1.path
>> > (_id)]))
>> >
>> > def test_removetree():
>> > _id = request.vars.id if request.vars.id else 3
>> > t1.remove_tree(_id)
>> > return dict(message="Success")
>> >
>> > def test_delete():
>> > _id = request.vars.id if request.vars.id else 19
>> > node = t1.delete(_id)
>> > return dict(message= node.name + " deleted ")
>> >
>> > def test_get():
>> > _id = request.vars.id if request.vars.id else 15
>> > #nodes = t1.ancestors(_id)
>> > #nodes = t1.descendants(_id)
>> > nodes = t1.children(_id)
>> > return dict(message= ", ".join([node.name for node in nodes]))
>> >
>> > def test_gettree():
>> > root_id = request.vars.root_id if request.vars.root_id else 1
>> > nodes = t1.tree(root_id)
>> > return dict(message="Count "+str(len(nodes)))
>> >
>> > def test_add():
>> > root_id = request.vars.root_id if request.vars.root_id else
>> > t1.roots()[0].id
>> > r1 = t1.add(root_id, name='1')
>> > r2 = t1.add(root_id, name='2')
>> > r3 = t1.add(root_id, name='3')
>> > t1.add(r1, name='11')
>> > t1.add(r1, name='12')
>> > return dict(message="Success")
>> >
>> > def test_create_roots():
>> > '''
>> > t1.create_root(name='root1')
>> > t1.create_root(name='root2')
>> > t1.create_root(name='root3')
>> > t1.create_root(name='root4')
>> > '''
>> > roots = t1.roots()
>> > return dict(message="Roots count : " + str(len(roots)))
>> >
>> > [nstree_model:]
>> >
>> > db.define_table('tree1',
>> > SQLField('name', "string", 128),
>> > SQLField('lft','integer'),
>> > SQLField('rgt','integer'),
>> > SQLField('level','integer'),
>> > SQLField('root_id','integer'),
>> > SQLField('parent_id','reference tree1'),
>> > )
>> > #
>> > #  A Nested Sets implementation
>> > #  need to pass a table with following fields:
>> > #  lft, rgt, level, parent_id, root_id - all fields of type int
>> > #  ---
>> > #  Notes:
>> > #  - table can contain multiple roots
>> > #
>> > class nstree:
>> > version = "1.0.0.04"
>> > def __init__(self, db, dbtable):
>> > self.db = db
>> > self.dbtable = dbtable
>> > #self.lft = dbtable.lft
>> > #self.rgt = dbtable.rgt
>> > #self.level = dbtable.level
>> > #self.parent_id = dbtable.parent_id
>> > #self.root_id = dbtable.root_id
>> > #
>> > #  Methods for building tree (create, delete nodes)
>> > #
>> > def create_root(self, **fields):
>> > _id = self.dbtable.insert(lft=1, rgt=2, level=0, **fields)
>> > _root = self.dbtable[_id]
>> > _root.update_record(root_id  = _id)
>> > return _root
>> > def add(self, parent_id, **fields): return self.add_last_child
>> > (parent_id, **fields)
>> > def add_last_child(self, parent_id, **fields):
>> > _parent = self.dbtable[parent_id]
>> > q1 = self.dbtable.rgt >= _parent.rgt
>> > q2 = self.dbtable.lft >= _parent.rgt
>> > q3 = self.dbtable.root_id == _parent.root_id
>> > self.db(q1)(q3).update(rgt=self.dbtable.rgt+2)
>> > self.db(q2)(q3).update(lft=self.dbtable.lft+2)
>> > return self.dbtable.insert(
>> > parent_id = parent_id,
>> > lft = _parent.rgt,
>> > rgt = _parent.rgt+1,
>> > level = _parent.level+1,
>> > root_id = _parent.root_id,
>> > **fields
>> > )
>> > def delete(self, id): return self.remove(id)
>> > def remove(self, id):
>> > node = self.dbtable[id]
>> > delta = node.rgt - node.lft + 1
>> > q1 = self.dbtable.lft >= node.lft
>> > q2 = self.dbtable.rgt <= node.rgt
>> > self.db(q1)(q2).delete()
>> > self.db(self.dbtable.lft > node.rgt).update(lft =
>> > self.dbtable.lft - delta)
>> > self.db(self.dbtable.rgt > node.rgt).update(rgt =
>> > self.dbtable.rgt - delta)
>> > return node
>> > def remove_descendants(self, id):
>> > node = self.d

[web2py:34912] Re: Nested Sets implementation

2009-11-08 Thread Vasile Ermicioi
second one is not a good argument, cascade delete will remove all
descendants, but we will have a broken tree, since on delete there are 2
updates to change lft and rgt,
so I have only to fight with myself not to be lazy :) and to remove
parent_id

On Mon, Nov 9, 2009 at 1:28 AM, Vasile Ermicioi  wrote:

> - for using in some queries like direct children (just too lazy to think
> how to use lft and rgt :) )
> - cascade delete (if is supported by the database)
>
>
> On Mon, Nov 9, 2009 at 1:18 AM, mdipierro  wrote:
>
>>
>> what do you need parent_id for when you have lgt and rgt?
>>
>>
>>
>> On Nov 8, 5:10 pm, elffikk  wrote:
>> > Hi,
>> >
>> > I started a nested sets implementation
>> > Just sharing the code. I welcome any thoughts you have
>> >
>> > 2 files - nstree_controller (just quick and dirty tests of the model),
>> > and nstree_model
>> >
>> > [nstree_controller :]
>> >
>> > t1 = nstree(db, db.tree1)
>> >
>> > def index():
>> > return dict(message="Version " + nstree.version)
>> >
>> > def test_path():
>> > _id = 33
>> > return dict(message = " > ".join([node.name for node in t1.path
>> > (_id)]))
>> >
>> > def test_removetree():
>> > _id = request.vars.id if request.vars.id else 3
>> > t1.remove_tree(_id)
>> > return dict(message="Success")
>> >
>> > def test_delete():
>> > _id = request.vars.id if request.vars.id else 19
>> > node = t1.delete(_id)
>> > return dict(message= node.name + " deleted ")
>> >
>> > def test_get():
>> > _id = request.vars.id if request.vars.id else 15
>> > #nodes = t1.ancestors(_id)
>> > #nodes = t1.descendants(_id)
>> > nodes = t1.children(_id)
>> > return dict(message= ", ".join([node.name for node in nodes]))
>> >
>> > def test_gettree():
>> > root_id = request.vars.root_id if request.vars.root_id else 1
>> > nodes = t1.tree(root_id)
>> > return dict(message="Count "+str(len(nodes)))
>> >
>> > def test_add():
>> > root_id = request.vars.root_id if request.vars.root_id else
>> > t1.roots()[0].id
>> > r1 = t1.add(root_id, name='1')
>> > r2 = t1.add(root_id, name='2')
>> > r3 = t1.add(root_id, name='3')
>> > t1.add(r1, name='11')
>> > t1.add(r1, name='12')
>> > return dict(message="Success")
>> >
>> > def test_create_roots():
>> > '''
>> > t1.create_root(name='root1')
>> > t1.create_root(name='root2')
>> > t1.create_root(name='root3')
>> > t1.create_root(name='root4')
>> > '''
>> > roots = t1.roots()
>> > return dict(message="Roots count : " + str(len(roots)))
>> >
>> > [nstree_model:]
>> >
>> > db.define_table('tree1',
>> > SQLField('name', "string", 128),
>> > SQLField('lft','integer'),
>> > SQLField('rgt','integer'),
>> > SQLField('level','integer'),
>> > SQLField('root_id','integer'),
>> > SQLField('parent_id','reference tree1'),
>> > )
>> > #
>> > #  A Nested Sets implementation
>> > #  need to pass a table with following fields:
>> > #  lft, rgt, level, parent_id, root_id - all fields of type int
>> > #  ---
>> > #  Notes:
>> > #  - table can contain multiple roots
>> > #
>> > class nstree:
>> > version = "1.0.0.04"
>> > def __init__(self, db, dbtable):
>> > self.db = db
>> > self.dbtable = dbtable
>> > #self.lft = dbtable.lft
>> > #self.rgt = dbtable.rgt
>> > #self.level = dbtable.level
>> > #self.parent_id = dbtable.parent_id
>> > #self.root_id = dbtable.root_id
>> > #
>> > #  Methods for building tree (create, delete nodes)
>> > #
>> > def create_root(self, **fields):
>> > _id = self.dbtable.insert(lft=1, rgt=2, level=0, **fields)
>> > _root = self.dbtable[_id]
>> > _root.update_record(root_id  = _id)
>> > return _root
>> > def add(self, parent_id, **fields): return self.add_last_child
>> > (parent_id, **fields)
>> > def add_last_child(self, parent_id, **fields):
>> > _parent = self.dbtable[parent_id]
>> > q1 = self.dbtable.rgt >= _parent.rgt
>> > q2 = self.dbtable.lft >= _parent.rgt
>> > q3 = self.dbtable.root_id == _parent.root_id
>> > self.db(q1)(q3).update(rgt=self.dbtable.rgt+2)
>> > self.db(q2)(q3).update(lft=self.dbtable.lft+2)
>> > return self.dbtable.insert(
>> > parent_id = parent_id,
>> > lft = _parent.rgt,
>> > rgt = _parent.rgt+1,
>> > level = _parent.level+1,
>> > root_id = _parent.root_id,
>> > **fields
>> > )
>> > def delete(self, id): return self.remove(id)
>> > def remove(self, id):
>> > node = self.dbtable[id]
>> > delta = node.rgt - node.lft + 1
>> > q1 = self.dbtable.lft >= node.lft
>> > q2 = self.dbtable.rgt <= node.rgt
>> > self.db(q1)(q2).delete()
>> > self.db(self.dbtable.lft > node.rgt).update(lft =
>> > self.dbtable.lft - delta)
>> > self.db(self.dbtable.rgt > node.

[web2py:34909] Re: problem with web2py with Postgresql on OS/X 10.5

2009-11-08 Thread mdipierro

Make sure you run web2py source (not binary) and use the same Python
version that you installed psycopg2 for.

On Nov 8, 5:14 pm, Steve  wrote:
> After some initial success with Web2py on a PC, I set it up on a
> Macbook Pro.  It worked but had problems with the database being
> locked when multiple web requests came in and compute times were long
> (running student game agents online).  So I installed Postgresql and
> psycopg2.  However, I am having a problem getting gluon to find it.
> I have my db=DAL('postgres://myacct:mypas...@localhost:5432/
> aitourney')
>
> The error I get is this:
> NameError: global name 'psycopg2' is not defined
>
> The traceback says this is in line 902 of gluon/sql.py in 
>
> How do I get past this error?  Is there a particular config file where
> I have to indicate how to find psycopg2?.
> How is that done?  I used Macports to install psycopg2 in the default
> location.
>
> Thanks.  Web2py generally seems to be an awesome tool.
>
> --Steve
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34908] T2 and Empty Flash Messages

2009-11-08 Thread jensk_dk

I just tried using T2 by adding the plugin as an application tarball
and I got a minor, but very odd problem. I have instantiated T2 but
not even used it yet. In the db.py, I copied the following code from
the T2 manual:

from applications.plugin_t2.modules.t2 import T2
t2=T2(request,response,session,cache,T,db)

But now I get empty flash popups with all pages. I'm sure there's a
perfectly natural explanation but I cannot think of one and I cannot
see any suspicious from the code. Can anyone tell me what's happening
here?

By the way, is T2 still being maintained? Everything I can find is
almost a year old. Has development stopped or is it just considered
done?

Thanks,
Jens Kristian Jensen

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



[web2py:34907] problem with web2py with Postgresql on OS/X 10.5

2009-11-08 Thread Steve

After some initial success with Web2py on a PC, I set it up on a
Macbook Pro.  It worked but had problems with the database being
locked when multiple web requests came in and compute times were long
(running student game agents online).  So I installed Postgresql and
psycopg2.  However, I am having a problem getting gluon to find it.
I have my db=DAL('postgres://myacct:mypas...@localhost:5432/
aitourney')

The error I get is this:
NameError: global name 'psycopg2' is not defined

The traceback says this is in line 902 of gluon/sql.py in 

How do I get past this error?  Is there a particular config file where
I have to indicate how to find psycopg2?.
How is that done?  I used Macports to install psycopg2 in the default
location.

Thanks.  Web2py generally seems to be an awesome tool.

--Steve

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



[web2py:34911] Re: Nested Sets implementation

2009-11-08 Thread Vasile Ermicioi
- for using in some queries like direct children (just too lazy to think how
to use lft and rgt :) )
- cascade delete (if is supported by the database)

On Mon, Nov 9, 2009 at 1:18 AM, mdipierro  wrote:

>
> what do you need parent_id for when you have lgt and rgt?
>
>
>
> On Nov 8, 5:10 pm, elffikk  wrote:
> > Hi,
> >
> > I started a nested sets implementation
> > Just sharing the code. I welcome any thoughts you have
> >
> > 2 files - nstree_controller (just quick and dirty tests of the model),
> > and nstree_model
> >
> > [nstree_controller :]
> >
> > t1 = nstree(db, db.tree1)
> >
> > def index():
> > return dict(message="Version " + nstree.version)
> >
> > def test_path():
> > _id = 33
> > return dict(message = " > ".join([node.name for node in t1.path
> > (_id)]))
> >
> > def test_removetree():
> > _id = request.vars.id if request.vars.id else 3
> > t1.remove_tree(_id)
> > return dict(message="Success")
> >
> > def test_delete():
> > _id = request.vars.id if request.vars.id else 19
> > node = t1.delete(_id)
> > return dict(message= node.name + " deleted ")
> >
> > def test_get():
> > _id = request.vars.id if request.vars.id else 15
> > #nodes = t1.ancestors(_id)
> > #nodes = t1.descendants(_id)
> > nodes = t1.children(_id)
> > return dict(message= ", ".join([node.name for node in nodes]))
> >
> > def test_gettree():
> > root_id = request.vars.root_id if request.vars.root_id else 1
> > nodes = t1.tree(root_id)
> > return dict(message="Count "+str(len(nodes)))
> >
> > def test_add():
> > root_id = request.vars.root_id if request.vars.root_id else
> > t1.roots()[0].id
> > r1 = t1.add(root_id, name='1')
> > r2 = t1.add(root_id, name='2')
> > r3 = t1.add(root_id, name='3')
> > t1.add(r1, name='11')
> > t1.add(r1, name='12')
> > return dict(message="Success")
> >
> > def test_create_roots():
> > '''
> > t1.create_root(name='root1')
> > t1.create_root(name='root2')
> > t1.create_root(name='root3')
> > t1.create_root(name='root4')
> > '''
> > roots = t1.roots()
> > return dict(message="Roots count : " + str(len(roots)))
> >
> > [nstree_model:]
> >
> > db.define_table('tree1',
> > SQLField('name', "string", 128),
> > SQLField('lft','integer'),
> > SQLField('rgt','integer'),
> > SQLField('level','integer'),
> > SQLField('root_id','integer'),
> > SQLField('parent_id','reference tree1'),
> > )
> > #
> > #  A Nested Sets implementation
> > #  need to pass a table with following fields:
> > #  lft, rgt, level, parent_id, root_id - all fields of type int
> > #  ---
> > #  Notes:
> > #  - table can contain multiple roots
> > #
> > class nstree:
> > version = "1.0.0.04"
> > def __init__(self, db, dbtable):
> > self.db = db
> > self.dbtable = dbtable
> > #self.lft = dbtable.lft
> > #self.rgt = dbtable.rgt
> > #self.level = dbtable.level
> > #self.parent_id = dbtable.parent_id
> > #self.root_id = dbtable.root_id
> > #
> > #  Methods for building tree (create, delete nodes)
> > #
> > def create_root(self, **fields):
> > _id = self.dbtable.insert(lft=1, rgt=2, level=0, **fields)
> > _root = self.dbtable[_id]
> > _root.update_record(root_id  = _id)
> > return _root
> > def add(self, parent_id, **fields): return self.add_last_child
> > (parent_id, **fields)
> > def add_last_child(self, parent_id, **fields):
> > _parent = self.dbtable[parent_id]
> > q1 = self.dbtable.rgt >= _parent.rgt
> > q2 = self.dbtable.lft >= _parent.rgt
> > q3 = self.dbtable.root_id == _parent.root_id
> > self.db(q1)(q3).update(rgt=self.dbtable.rgt+2)
> > self.db(q2)(q3).update(lft=self.dbtable.lft+2)
> > return self.dbtable.insert(
> > parent_id = parent_id,
> > lft = _parent.rgt,
> > rgt = _parent.rgt+1,
> > level = _parent.level+1,
> > root_id = _parent.root_id,
> > **fields
> > )
> > def delete(self, id): return self.remove(id)
> > def remove(self, id):
> > node = self.dbtable[id]
> > delta = node.rgt - node.lft + 1
> > q1 = self.dbtable.lft >= node.lft
> > q2 = self.dbtable.rgt <= node.rgt
> > self.db(q1)(q2).delete()
> > self.db(self.dbtable.lft > node.rgt).update(lft =
> > self.dbtable.lft - delta)
> > self.db(self.dbtable.rgt > node.rgt).update(rgt =
> > self.dbtable.rgt - delta)
> > return node
> > def remove_descendants(self, id):
> > node = self.dbtable[id]
> > delta = node.rgt - node.lft + 1
> > q1 = self.dbtable.lft > node.lft
> > q2 = self.dbtable.rgt < node.rgt
> > self.db(q1)(q2).delete()
> > self.db(self.dbtable.lft > node.rgt).update(lft =
> > self.dbtable.lft - delta)
> > self.db(self.dbtable.rgt

[web2py:34906] Re: Nested Sets implementation

2009-11-08 Thread mdipierro

what do you need parent_id for when you have lgt and rgt?



On Nov 8, 5:10 pm, elffikk  wrote:
> Hi,
>
> I started a nested sets implementation
> Just sharing the code. I welcome any thoughts you have
>
> 2 files - nstree_controller (just quick and dirty tests of the model),
> and nstree_model
>
> [nstree_controller :]
>
> t1 = nstree(db, db.tree1)
>
> def index():
>     return dict(message="Version " + nstree.version)
>
> def test_path():
>     _id = 33
>     return dict(message = " > ".join([node.name for node in t1.path
> (_id)]))
>
> def test_removetree():
>     _id = request.vars.id if request.vars.id else 3
>     t1.remove_tree(_id)
>     return dict(message="Success")
>
> def test_delete():
>     _id = request.vars.id if request.vars.id else 19
>     node = t1.delete(_id)
>     return dict(message= node.name + " deleted ")
>
> def test_get():
>     _id = request.vars.id if request.vars.id else 15
>     #nodes = t1.ancestors(_id)
>     #nodes = t1.descendants(_id)
>     nodes = t1.children(_id)
>     return dict(message= ", ".join([node.name for node in nodes]))
>
> def test_gettree():
>     root_id = request.vars.root_id if request.vars.root_id else 1
>     nodes = t1.tree(root_id)
>     return dict(message="Count "+str(len(nodes)))
>
> def test_add():
>     root_id = request.vars.root_id if request.vars.root_id else
> t1.roots()[0].id
>     r1 = t1.add(root_id, name='1')
>     r2 = t1.add(root_id, name='2')
>     r3 = t1.add(root_id, name='3')
>     t1.add(r1, name='11')
>     t1.add(r1, name='12')
>     return dict(message="Success")
>
> def test_create_roots():
>     '''
>     t1.create_root(name='root1')
>     t1.create_root(name='root2')
>     t1.create_root(name='root3')
>     t1.create_root(name='root4')
>     '''
>     roots = t1.roots()
>     return dict(message="Roots count : " + str(len(roots)))
>
> [nstree_model:]
>
> db.define_table('tree1',
>     SQLField('name', "string", 128),
>     SQLField('lft','integer'),
>     SQLField('rgt','integer'),
>     SQLField('level','integer'),
>     SQLField('root_id','integer'),
>     SQLField('parent_id','reference tree1'),
>     )
> #
> #  A Nested Sets implementation
> #  need to pass a table with following fields:
> #  lft, rgt, level, parent_id, root_id - all fields of type int
> #  ---
> #  Notes:
> #  - table can contain multiple roots
> #
> class nstree:
>     version = "1.0.0.04"
>     def __init__(self, db, dbtable):
>         self.db = db
>         self.dbtable = dbtable
>         #self.lft = dbtable.lft
>         #self.rgt = dbtable.rgt
>         #self.level = dbtable.level
>         #self.parent_id = dbtable.parent_id
>         #self.root_id = dbtable.root_id
>     #
>     #  Methods for building tree (create, delete nodes)
>     #
>     def create_root(self, **fields):
>         _id = self.dbtable.insert(lft=1, rgt=2, level=0, **fields)
>         _root = self.dbtable[_id]
>         _root.update_record(root_id  = _id)
>         return _root
>     def add(self, parent_id, **fields): return self.add_last_child
> (parent_id, **fields)
>     def add_last_child(self, parent_id, **fields):
>         _parent = self.dbtable[parent_id]
>         q1 = self.dbtable.rgt >= _parent.rgt
>         q2 = self.dbtable.lft >= _parent.rgt
>         q3 = self.dbtable.root_id == _parent.root_id
>         self.db(q1)(q3).update(rgt=self.dbtable.rgt+2)
>         self.db(q2)(q3).update(lft=self.dbtable.lft+2)
>         return self.dbtable.insert(
>             parent_id = parent_id,
>             lft = _parent.rgt,
>             rgt = _parent.rgt+1,
>             level = _parent.level+1,
>             root_id = _parent.root_id,
>             **fields
>         )
>     def delete(self, id): return self.remove(id)
>     def remove(self, id):
>         node = self.dbtable[id]
>         delta = node.rgt - node.lft + 1
>         q1 = self.dbtable.lft >= node.lft
>         q2 = self.dbtable.rgt <= node.rgt
>         self.db(q1)(q2).delete()
>         self.db(self.dbtable.lft > node.rgt).update(lft =
> self.dbtable.lft - delta)
>         self.db(self.dbtable.rgt > node.rgt).update(rgt =
> self.dbtable.rgt - delta)
>         return node
>     def remove_descendants(self, id):
>         node = self.dbtable[id]
>         delta = node.rgt - node.lft + 1
>         q1 = self.dbtable.lft > node.lft
>         q2 = self.dbtable.rgt < node.rgt
>         self.db(q1)(q2).delete()
>         self.db(self.dbtable.lft > node.rgt).update(lft =
> self.dbtable.lft - delta)
>         self.db(self.dbtable.rgt > node.rgt).update(rgt =
> self.dbtable.rgt - delta)
>     def remove_tree(self, id):
>         self.db(self.dbtable.root_id == id).delete()
>     #
>     #  Methods for retrieving nodes
>     #
>     def roots(self): return self.db(self.dbtable.lft == 1).select()
>     def tree(self, root_id): return self.db(self.dbtable.root_id ==
> root_id).select(orderby = self.dbtable.lft)
>     def ancestors(self, id):
>         node = self.dbtable[id]
>         q1 = self.dbtable.lft < nod

[web2py:34910] Re: T2 and Empty Flash Messages

2009-11-08 Thread mdipierro



On Nov 8, 4:43 pm, jensk_dk  wrote:
> I just tried using T2 by adding the plugin as an application tarball
> and I got a minor, but very odd problem. I have instantiated T2 but
> not even used it yet. In the db.py, I copied the following code from
> the T2 manual:
>
> from applications.plugin_t2.modules.t2 import T2
> t2=T2(request,response,session,cache,T,db)
>
> But now I get empty flash popups with all pages. I'm sure there's a
> perfectly natural explanation but I cannot think of one and I cannot
> see any suspicious from the code. Can anyone tell me what's happening
> here?
>
> By the way, is T2 still being maintained?

No. Sorry. Something better coming out soon.

> Everything I can find is
> almost a year old. Has development stopped or is it just considered
> done?
>
> Thanks,
> Jens Kristian Jensen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34905] Nested Sets implementation

2009-11-08 Thread elffikk

Hi,

I started a nested sets implementation
Just sharing the code. I welcome any thoughts you have

2 files - nstree_controller (just quick and dirty tests of the model),
and nstree_model

[nstree_controller :]

t1 = nstree(db, db.tree1)

def index():
return dict(message="Version " + nstree.version)

def test_path():
_id = 33
return dict(message = " > ".join([node.name for node in t1.path
(_id)]))

def test_removetree():
_id = request.vars.id if request.vars.id else 3
t1.remove_tree(_id)
return dict(message="Success")

def test_delete():
_id = request.vars.id if request.vars.id else 19
node = t1.delete(_id)
return dict(message= node.name + " deleted ")

def test_get():
_id = request.vars.id if request.vars.id else 15
#nodes = t1.ancestors(_id)
#nodes = t1.descendants(_id)
nodes = t1.children(_id)
return dict(message= ", ".join([node.name for node in nodes]))

def test_gettree():
root_id = request.vars.root_id if request.vars.root_id else 1
nodes = t1.tree(root_id)
return dict(message="Count "+str(len(nodes)))

def test_add():
root_id = request.vars.root_id if request.vars.root_id else
t1.roots()[0].id
r1 = t1.add(root_id, name='1')
r2 = t1.add(root_id, name='2')
r3 = t1.add(root_id, name='3')
t1.add(r1, name='11')
t1.add(r1, name='12')
return dict(message="Success")

def test_create_roots():
'''
t1.create_root(name='root1')
t1.create_root(name='root2')
t1.create_root(name='root3')
t1.create_root(name='root4')
'''
roots = t1.roots()
return dict(message="Roots count : " + str(len(roots)))


[nstree_model:]

db.define_table('tree1',
SQLField('name', "string", 128),
SQLField('lft','integer'),
SQLField('rgt','integer'),
SQLField('level','integer'),
SQLField('root_id','integer'),
SQLField('parent_id','reference tree1'),
)
#
#  A Nested Sets implementation
#  need to pass a table with following fields:
#  lft, rgt, level, parent_id, root_id - all fields of type int
#  ---
#  Notes:
#  - table can contain multiple roots
#
class nstree:
version = "1.0.0.04"
def __init__(self, db, dbtable):
self.db = db
self.dbtable = dbtable
#self.lft = dbtable.lft
#self.rgt = dbtable.rgt
#self.level = dbtable.level
#self.parent_id = dbtable.parent_id
#self.root_id = dbtable.root_id
#
#  Methods for building tree (create, delete nodes)
#
def create_root(self, **fields):
_id = self.dbtable.insert(lft=1, rgt=2, level=0, **fields)
_root = self.dbtable[_id]
_root.update_record(root_id  = _id)
return _root
def add(self, parent_id, **fields): return self.add_last_child
(parent_id, **fields)
def add_last_child(self, parent_id, **fields):
_parent = self.dbtable[parent_id]
q1 = self.dbtable.rgt >= _parent.rgt
q2 = self.dbtable.lft >= _parent.rgt
q3 = self.dbtable.root_id == _parent.root_id
self.db(q1)(q3).update(rgt=self.dbtable.rgt+2)
self.db(q2)(q3).update(lft=self.dbtable.lft+2)
return self.dbtable.insert(
parent_id = parent_id,
lft = _parent.rgt,
rgt = _parent.rgt+1,
level = _parent.level+1,
root_id = _parent.root_id,
**fields
)
def delete(self, id): return self.remove(id)
def remove(self, id):
node = self.dbtable[id]
delta = node.rgt - node.lft + 1
q1 = self.dbtable.lft >= node.lft
q2 = self.dbtable.rgt <= node.rgt
self.db(q1)(q2).delete()
self.db(self.dbtable.lft > node.rgt).update(lft =
self.dbtable.lft - delta)
self.db(self.dbtable.rgt > node.rgt).update(rgt =
self.dbtable.rgt - delta)
return node
def remove_descendants(self, id):
node = self.dbtable[id]
delta = node.rgt - node.lft + 1
q1 = self.dbtable.lft > node.lft
q2 = self.dbtable.rgt < node.rgt
self.db(q1)(q2).delete()
self.db(self.dbtable.lft > node.rgt).update(lft =
self.dbtable.lft - delta)
self.db(self.dbtable.rgt > node.rgt).update(rgt =
self.dbtable.rgt - delta)
def remove_tree(self, id):
self.db(self.dbtable.root_id == id).delete()
#
#  Methods for retrieving nodes
#
def roots(self): return self.db(self.dbtable.lft == 1).select()
def tree(self, root_id): return self.db(self.dbtable.root_id ==
root_id).select(orderby = self.dbtable.lft)
def ancestors(self, id):
node = self.dbtable[id]
q1 = self.dbtable.lft < node.lft
q2 = self.dbtable.rgt > node.rgt
q3 = self.dbtable.root_id == node.root_id
return self.db(q1)(q2)(q3).select(orderby = self.dbtable.lft)
def path(self, id):
node = self.dbtable[id]
q1 = self.dbtable.lft <= node.lft
q2 = self.dbtable.rgt >= node.rgt
q3 = self.dbtable.root_id == node.root_id
return self.

[web2py:34904] Re: Join web2py wave

2009-11-08 Thread hcvst

Hi Richard,

in fact you can write at
http://wavedirectory.appspot.com/init/default/wave/676f6f676c65776176652e636f6d21772b4450734a6167675941
too. Unfortunately you need to be logged into wave (to read or write).
The embed mechanism (an iframe) requires
that.

HC



On Nov 8, 11:41 pm, Richard  wrote:
> there is already a web2py wave - see if this link 
> works:https://wave.google.com/wave/#restored:wave:googlewave.com%2521w%252B...
> And if you don't have your invite yet there is a readonly version
> here:http://wavedirectory.appspot.com/init/default/wave/676f6f676c65776176...
>
> On Nov 8, 11:00 am, Thadeus Burgess  wrote:
>
> > I think we should all start a public web2py wave! :)
>
> > -Thadeus
>
> > On Sat, Nov 7, 2009 at 3:54 PM, mdipierro  wrote:
>
> > > I have account. I just have not figured out what I am supposed to do
> > > with it.
>
> > > On Nov 7, 3:08 pm, Nicolás de la Torre  wrote:
> > > > Invited:
>
> > > > debe...@yahoo.com
> > > > kuo...@gmail.com
> > > > murxun...@googlemail.com
> > > > jorgeh...@gmail.com
>
> > > > I have 5 invites left. Just ask.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34903] Re: Chapter 1 from 2nd edition web2py book in Spanish

2009-11-08 Thread mdipierro

You have been busy! This is great Denes. We have to think of a good
way to advertise this.



On Nov 8, 10:00 am, DenesL  wrote:
> Chapter 1 from 2nd edition web2py book in Spanish
> Capítulo 1 del manual web2py 2da edición en Español
>
> http://drop.io/web2py_DenesL/asset/web2py-libro2-cap1-pdf
>
> Want to help in translating other chapters?
> ¿Quiere ayudar con la traducción de otros capítulos?
>
> Contact me.
> Contácteme.
>
> Denes.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34902] Re: Charsets and Includes. Or why do my accented words get screwed in includes.

2009-11-08 Thread mdipierro

I do not know but could it be you have a

meta http-equiv

in the html head?

On Nov 8, 4:07 pm, Benigno  wrote:
> hmmm,
>
>     But why does it interpret it differently when the text is in an
> include than when the text is in the layout.html?  If I copy and paste
> the texts into the layout they appear correctly, whereas if they are
> in the index.html (which is the one that extends layout), then the
> don't.
>
> On Nov 8, 5:20 pm, Jonathan Lundell  wrote:
>
> > On Nov 8, 2009, at 7:33 AM, Benigno wrote:
>
> > > I didnt explain myself correctly. I am setting the  > > equiv="Content-Type" content="text/html; charset=iso-8859-1" />
> > > dinamically when in spanish. However, the accented words still show
> > > badly.
>
> > The character set specified by the http header takes precedence over  
> > the meta tag, and web2py does this:
>
> > class HTTP(BaseException):
> >      ...
> >      def to(self, responder):
> >          ...
> >          if not 'Content-Type' in self.headers:
> >              self.headers['Content-Type'] = 'text/html; charset=UTF-8'
>
> > It can be overridden, as you see, but I don't know what all the  
> > implications of that would be. Sticking to utf-8 might be a better  
> > choice.
>
> > > Massimo:
> > >   I dont understand exactly what you mean, whats the correct way to
> > > do this then?.
>
> > > On Nov 8, 4:06 pm, salingrosso  wrote:
> > >> 2009/11/8 mdipierro 
>
> > >>> You do not have the option of using latin1. utf8 is set by web2py in
> > >>> the http header.
>
> > >> But in layout.html I see:
> > >>   
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34901] Re: Weird behaviour of translation and routes.py (possible bug or dumb me)

2009-11-08 Thread mdipierro

This is (was) a bug. It is now fixed in trunk. Thanks for reporting
it.

Massimo

On Nov 6, 2:50 pm, Benigno  wrote:
> Ok,
>
>    Problem still there without routes.py.
>
>    Removed routes.py, but left on db.py the following:
>
> # Rerouting of language
> if request.vars._language: T.force(request.vars._language)
>
>    I change en.py, but as soon as I go 
> tohttp://127.0.0.1:8000/AlbenDas/default/index?_language=es
>    the en.py file gets modified (default value containing the spanish
> T elements).
>
>    I am sending you the app by mail.
>
> On Nov 6, 6:18 pm, mdipierro  wrote:
>
> > Do you have the problem only when you use routes?
>
> > On Nov 6, 10:43 am, Benigno  wrote:
>
> > > Hello,
>
> > >     I have the following code in my index view:
>
> > > (exceprt from layout.html):
> > >  > > {{=request.vars._language.upper()}}" "http://www.w3.org/TR/xhtml1/DTD/
> > > xhtml1-transitional.dtd">
> > > {{T.current_languages=['es','es-es']}}
> > > http://www.w3.org/1999/xhtml";
> > > xml:lang="{{=T.accepted_language or 'en'}}">
>
> > > And then in Index.html:
>
> > >       {{response.write(T('
> > >         AlbenDas  tiene
> > > clientes ... 
> > >       '),escape=False)}}
>
> > > I do this this way to translate blocks of text with different tags
> > > (bolds etc) as they differ a bit betweenlanguages.
>
> > > Also, I have this in routes.py:
> > > routes_in = (('/AlbenDas/static/(?P.*)','/AlbenDas/static/$any'),
> > >              ('/AlbenDas/$language/(?P.*)','/AlbenDas/default/
> > > $any?_language=$language'),
> > >              ('.*:/favicon.ico', '/examples/static/favicon.ico'),
> > >              ('.*:/robots.txt', '/examples/static/robots.txt'))
> > > routes_out=()
>
> > > Now, I do all the translation. I check 
> > > URL:http://127.0.0.1:8000/AlbenDas/en/index
> > > And it all appears in english nice and dandy.
> > > Next I 
> > > checkhttp://127.0.0.1:8000/AlbenDas/es/index (orhttp://127.0.0.1:8000/AlbenDas/default/index)
> > >  and I get the page in
> > > Spanish as it should.
>
> > > Now it comes the funny thing, I check again the English one, and its
> > > is in Spanish, and the real weird thing (to me at least) is that if I
> > > go to check translation file en.py the translated block is there, but
> > > with all the translated text back to Spanish.
>
> > > How is that translation file (en.py) being overwriten back to
> > > Spanish?.
>
> > > Thanks for your help,
> > > Benigno.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34900] Re: Charsets and Includes. Or why do my accented words get screwed in includes.

2009-11-08 Thread Benigno

hmmm,

But why does it interpret it differently when the text is in an
include than when the text is in the layout.html?  If I copy and paste
the texts into the layout they appear correctly, whereas if they are
in the index.html (which is the one that extends layout), then the
don't.



On Nov 8, 5:20 pm, Jonathan Lundell  wrote:
> On Nov 8, 2009, at 7:33 AM, Benigno wrote:
>
>
>
> > I didnt explain myself correctly. I am setting the  > equiv="Content-Type" content="text/html; charset=iso-8859-1" />
> > dinamically when in spanish. However, the accented words still show
> > badly.
>
> The character set specified by the http header takes precedence over  
> the meta tag, and web2py does this:
>
> class HTTP(BaseException):
>      ...
>      def to(self, responder):
>          ...
>          if not 'Content-Type' in self.headers:
>              self.headers['Content-Type'] = 'text/html; charset=UTF-8'
>
> It can be overridden, as you see, but I don't know what all the  
> implications of that would be. Sticking to utf-8 might be a better  
> choice.
>
>
>
> > Massimo:
> >   I dont understand exactly what you mean, whats the correct way to
> > do this then?.
>
> > On Nov 8, 4:06 pm, salingrosso  wrote:
> >> 2009/11/8 mdipierro 
>
> >>> You do not have the option of using latin1. utf8 is set by web2py in
> >>> the http header.
>
> >> But in layout.html I see:
> >>   
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34899] Re: Join web2py wave

2009-11-08 Thread Richard

there is already a web2py wave - see if this link works:
https://wave.google.com/wave/#restored:wave:googlewave.com%2521w%252BDPsJaggYA
And if you don't have your invite yet there is a readonly version
here: 
http://wavedirectory.appspot.com/init/default/wave/676f6f676c65776176652e636f6d21772b4450734a6167675941



On Nov 8, 11:00 am, Thadeus Burgess  wrote:
> I think we should all start a public web2py wave! :)
>
> -Thadeus
>
>
>
> On Sat, Nov 7, 2009 at 3:54 PM, mdipierro  wrote:
>
> > I have account. I just have not figured out what I am supposed to do
> > with it.
>
> > On Nov 7, 3:08 pm, Nicolás de la Torre  wrote:
> > > Invited:
>
> > > debe...@yahoo.com
> > > kuo...@gmail.com
> > > murxun...@googlemail.com
> > > jorgeh...@gmail.com
>
> > > I have 5 invites left. Just ask.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34898] Re: Join web2py wave

2009-11-08 Thread Richard

yeah! - can invite again.

Have invited:
denes1...@yahoo.ca
roger.gicq...@gmail.com
mbelle...@gmail.com
whalb...@gmail.com
debe...@yahoo.com
digitalcry...@gmail.com
maxu...@gmail.com



On Nov 9, 2:35 am, Marat Maksumov  wrote:
> I am very interested in receiving an invitation to Google Wave...
>
> On Nov 7, 10:44 am, Nicolás de la Torre  wrote:
>
>
>
> > i have sent invites to:
>
> > vinc...@vincentdavis.com
> > thade...@thadeusb.com
> > szims...@gmail.com
> > boris.manojlo...@gmail.com
> > richard_gor...@verizon.net
> > chris.st...@gmail.com
> > m.grit...@gmail.com
> > lapcc...@gmail.com
> > obutov...@googlemail.com
>
> > Pls tell me if someone is missing.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34897] Re: SQLTABLE

2009-11-08 Thread DenesL

http://web2py.com/examples/static/epydoc/web2py.gluon.sqlhtml.SQLTABLE-class.html
or the source itself.

On 8 nov, 15:24, leone  wrote:
> Where can I find documentation about SQLTABLE?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34896] SQLTABLE

2009-11-08 Thread leone

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



[web2py:34895] Re: pjamas or any

2009-11-08 Thread dbb

Thanks Massim. This week and next I am focusing on  RPC in different
flavors
for the work I am doing

On Nov 8, 2:33 pm, mdipierro  wrote:
> there are two parts of Pyjamas.
>
> 1) the script that takes Python code and generates JS. web2py does not
> include it but if you have it installed you can use it. You can also
> call it from web2py as you would call any other module but most
> likely  you would generate js outside of web2py.
>
> 2) the ability of web2py to expose methods as jsonrpc so that they can
> be called by Pyjamas. that is easy. define a function in a model or
> controller and decorate it with
>
> @service.jsonrpc
> def myfunction(a,b,c): return a+b+c
>
> And you can call it from pyjamas. There is a section in the web2py
> book on this topic written by the creators of Pyjamas.
>
> Massimo
>
> On Nov 8, 12:58 pm, dbb  wrote:
>
>
>
> > sorry I men pyjamas not pjamas
>
> > On Nov 8, 12:57 pm, dbb  wrote:
>
> > > Do we have the ability to call pjamas from web2py (or incorporated in
> > > gluon) or do we have a similar function in web2py; the functions I am
> > > looking is to get data remotely and to post data remotely and the
> > > remote side to have intelligence( to know) to update the data when the
> > > data is accessed and also to know who accessed the data, e.g., I have
> > > a set of attributes x, y,z to send , and get results w, m, k from the
> > > remote site related x, y,z. The other side my use C++, python, java,
> > > javascript etc, on my side I have web2py- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34894] Re: Using web2py with jython

2009-11-08 Thread mdipierro

jython does not seem to support socket option no_delay. In gluon/
wsgiserver.py replace

 nodelay = True

with

 nodelay = False


Massimo


On Nov 8, 1:48 pm, Nik  wrote:
> Hi folks,
>
> For testing web2py with jython I have started it
> by executing  "jython web2py.py" and got the following
> error message:
>
> ==
> saturn:web2py_1.71.2 nik$ jython web2py.py
> WARNING:root:no file locking
> WARNING:root:unable to import dbhash
> WARNING:root:GUI not available because Tk library is not installed
> default applications appear to be installed already
> web2py Enterprise Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2009
> Version 1.71.2 (2009-11-04 15:48:54)
> Database drivers available:
> Starting cron...
> choose a password:
> please visit:
>        http://127.0.0.1:8000
> use "kill -SIGTERM 949" to shutdown the web2py server
> Traceback (most recent call last):
>   File "web2py.py", line 20, in 
>     gluon.widget.start(cron=True)
>   File "/Users/nik/work/web/web2py_1.71.2/gluon/widget.py", line 852,
> in start
>     server.start()
>   File "/Users/nik/work/web/web2py_1.71.2/gluon/widget.py", line 852,
> in start
>     server.start()
>   File "/Users/nik/work/web/web2py_1.71.2/gluon/main.py", line 710, in
> start
>     self.server.start()
>   File "/Users/nik/work/web/web2py_1.71.2/gluon/wsgiserver.py", line
> 1884, in start
>     self.socket.listen(self.request_queue_size)
>   File "", line 1, in listen
>   File "/Users/nik/Applications/jython2.5.1/Lib/socket.py", line 824,
> in listen
>     self._config()
>   File "/Users/nik/Applications/jython2.5.1/Lib/socket.py", line 824,
> in listen
>     self._config()
>   File "/Users/nik/Applications/jython2.5.1/Lib/socket.py", line 763,
> in _config
>     self.sock_impl.setsockopt(level, optname, self.pending_options
> [ (level, optname) ])
>   File "/Users/nik/Applications/jython2.5.1/Lib/socket.py", line 282,
> in setsockopt
>     raise error(errno.ENOPROTOOPT, "Socket option '%s' (level '%s')
> not supported on socket(%s)" % (_constant_to_name(option),
> _constant_to_name(level), str(self.jsocket)))
> socket.error: (42, "Socket option 'TCP_NODELAY' (level 'IPPROTO_TCP')
> not supported on socket(ServerSocket[addr=/
> 127.0.0.1,localport=8000])")
> ==
>
> Am I missing something here?
>
> Regards
> Nik
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34893] Using web2py with jython

2009-11-08 Thread Nik

Hi folks,

For testing web2py with jython I have started it
by executing  "jython web2py.py" and got the following
error message:

==
saturn:web2py_1.71.2 nik$ jython web2py.py
WARNING:root:no file locking
WARNING:root:unable to import dbhash
WARNING:root:GUI not available because Tk library is not installed
default applications appear to be installed already
web2py Enterprise Web Framework
Created by Massimo Di Pierro, Copyright 2007-2009
Version 1.71.2 (2009-11-04 15:48:54)
Database drivers available:
Starting cron...
choose a password:
please visit:
http://127.0.0.1:8000
use "kill -SIGTERM 949" to shutdown the web2py server
Traceback (most recent call last):
  File "web2py.py", line 20, in 
gluon.widget.start(cron=True)
  File "/Users/nik/work/web/web2py_1.71.2/gluon/widget.py", line 852,
in start
server.start()
  File "/Users/nik/work/web/web2py_1.71.2/gluon/widget.py", line 852,
in start
server.start()
  File "/Users/nik/work/web/web2py_1.71.2/gluon/main.py", line 710, in
start
self.server.start()
  File "/Users/nik/work/web/web2py_1.71.2/gluon/wsgiserver.py", line
1884, in start
self.socket.listen(self.request_queue_size)
  File "", line 1, in listen
  File "/Users/nik/Applications/jython2.5.1/Lib/socket.py", line 824,
in listen
self._config()
  File "/Users/nik/Applications/jython2.5.1/Lib/socket.py", line 824,
in listen
self._config()
  File "/Users/nik/Applications/jython2.5.1/Lib/socket.py", line 763,
in _config
self.sock_impl.setsockopt(level, optname, self.pending_options
[ (level, optname) ])
  File "/Users/nik/Applications/jython2.5.1/Lib/socket.py", line 282,
in setsockopt
raise error(errno.ENOPROTOOPT, "Socket option '%s' (level '%s')
not supported on socket(%s)" % (_constant_to_name(option),
_constant_to_name(level), str(self.jsocket)))
socket.error: (42, "Socket option 'TCP_NODELAY' (level 'IPPROTO_TCP')
not supported on socket(ServerSocket[addr=/
127.0.0.1,localport=8000])")
==

Am I missing something here?

Regards
Nik



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



[web2py:34892] Re: pjamas or any

2009-11-08 Thread mdipierro

there are two parts of Pyjamas.

1) the script that takes Python code and generates JS. web2py does not
include it but if you have it installed you can use it. You can also
call it from web2py as you would call any other module but most
likely  you would generate js outside of web2py.

2) the ability of web2py to expose methods as jsonrpc so that they can
be called by Pyjamas. that is easy. define a function in a model or
controller and decorate it with

@service.jsonrpc
def myfunction(a,b,c): return a+b+c

And you can call it from pyjamas. There is a section in the web2py
book on this topic written by the creators of Pyjamas.

Massimo

On Nov 8, 12:58 pm, dbb  wrote:
> sorry I men pyjamas not pjamas
>
> On Nov 8, 12:57 pm, dbb  wrote:
>
> > Do we have the ability to call pjamas from web2py (or incorporated in
> > gluon) or do we have a similar function in web2py; the functions I am
> > looking is to get data remotely and to post data remotely and the
> > remote side to have intelligence( to know) to update the data when the
> > data is accessed and also to know who accessed the data, e.g., I have
> > a set of attributes x, y,z to send , and get results w, m, k from the
> > remote site related x, y,z. The other side my use C++, python, java,
> > javascript etc, on my side I have web2py
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34891] Re: Pass class to widgets

2009-11-08 Thread mr.freeze

Nice!

On Nov 8, 12:47 pm, Thadeus Burgess  wrote:
> Thanks for the suggestions.
>
> I do like replacing the SQLFORM widgets because now it allows me to replace
> them with some of Freeze's widgets :)
>
> Now I can have input boxes that look themed along side my jquery ui css.
>
> jqueryui_content = "ui-widget ui-widget-content ui-corner-all"
> class UIStringWidget(StringWidget):
>     @staticmethod
>     def widget(field, value, **attributes):
>         return StringWidget.widget(field, value, _class=jqueryui_content,
> **attributes)
>
> SQLFORM.widgets.string = UIStringWidget
>
> -Thadeus
>
> On Sun, Nov 8, 2009 at 11:49 AM, mdipierro  wrote:
>
> > why not?
>
> > On Nov 8, 10:35 am, Thadeus Burgess  wrote:
> > > What about just replacing SQLFORM.widgets with my own in db.py?
>
> > > -Thadeus
>
> > > On Sun, Nov 8, 2009 at 8:47 AM, mr.freeze  wrote:
>
> > > > Doh! He did say "every web2py form helper" though :)
>
> > > > On Nov 8, 8:45 am, mdipierro  wrote:
> > > > > Do not do this:
>
> > > > > gluon.sqlhtml.FormWidget._attributes = _attributes
>
> > > > > It would change the widget for all applications called concurrently.
>
> > > > > Instead do
>
> > > > > db.table.field.widget = lambda field: FormWidget(field,_attributes =
> > > > > _attributes)
>
> > > > > On Nov 8, 8:18 am, "mr.freeze"  wrote:
>
> > > > > > If you want to append a class to every widget, you can replace the
> > > > > > _attributes static method of sqlhtml.FormWidget. Try this in your
> > > > > > model:
> > > > > > ...
> > > > > > @staticmethod
> > > > > > def _attributes(field, widget_attributes, **attributes):
> > > > > >     attr = dict(
> > > > > >         _id = '%s_%s' % (field._tablename, field.name),
> > > > > >         _class = field.type,
> > > > > >         _name = field.name,
> > > > > >         requires = field.requires,
> > > > > >         )
> > > > > >     attr.update(widget_attributes)
> > > > > >     attr.update(attributes)
> > > > > >     attr.update(_class=attr['_class'] + ' myclass') #<-NEW
> > > > > >     return attr
>
> > > > > > import gluon.sqlhtml
> > > > > > gluon.sqlhtml.FormWidget._attributes = _attributes
>
> > > > > > Or were you wanting to actually do it at the helper level?
>
> > > > > > On Nov 8, 1:58 am, Thadeus Burgess  wrote:
>
> > > > > > > But I don't want the labels to have this class, just the actual
> > form
> > > > > > > elements
>
> > > > > > > -Thadeus
>
> > > > > > > On Sun, Nov 8, 2009 at 1:56 AM, Thadeus Burgess <
> > > > thade...@thadeusb.com>wrote:
>
> > > > > > > > What would be the best way to automatically pass a certain
> > class to
> > > > every
> > > > > > > > web2py form helper? (INPUT, TEXTAREA, etc..)
>
> > > > > > > > -Thadeus
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34890] Re: pjamas or any

2009-11-08 Thread dbb

sorry I men pyjamas not pjamas

On Nov 8, 12:57 pm, dbb  wrote:
> Do we have the ability to call pjamas from web2py (or incorporated in
> gluon) or do we have a similar function in web2py; the functions I am
> looking is to get data remotely and to post data remotely and the
> remote side to have intelligence( to know) to update the data when the
> data is accessed and also to know who accessed the data, e.g., I have
> a set of attributes x, y,z to send , and get results w, m, k from the
> remote site related x, y,z. The other side my use C++, python, java,
> javascript etc, on my side I have web2py
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34889] Re: Pass class to widgets

2009-11-08 Thread Thadeus Burgess
Thanks for the suggestions.

I do like replacing the SQLFORM widgets because now it allows me to replace
them with some of Freeze's widgets :)

Now I can have input boxes that look themed along side my jquery ui css.

jqueryui_content = "ui-widget ui-widget-content ui-corner-all"
class UIStringWidget(StringWidget):
@staticmethod
def widget(field, value, **attributes):
return StringWidget.widget(field, value, _class=jqueryui_content,
**attributes)

SQLFORM.widgets.string = UIStringWidget

-Thadeus




On Sun, Nov 8, 2009 at 11:49 AM, mdipierro  wrote:

>
> why not?
>
> On Nov 8, 10:35 am, Thadeus Burgess  wrote:
> > What about just replacing SQLFORM.widgets with my own in db.py?
> >
> > -Thadeus
> >
> > On Sun, Nov 8, 2009 at 8:47 AM, mr.freeze  wrote:
> >
> > > Doh! He did say "every web2py form helper" though :)
> >
> > > On Nov 8, 8:45 am, mdipierro  wrote:
> > > > Do not do this:
> >
> > > > gluon.sqlhtml.FormWidget._attributes = _attributes
> >
> > > > It would change the widget for all applications called concurrently.
> >
> > > > Instead do
> >
> > > > db.table.field.widget = lambda field: FormWidget(field,_attributes =
> > > > _attributes)
> >
> > > > On Nov 8, 8:18 am, "mr.freeze"  wrote:
> >
> > > > > If you want to append a class to every widget, you can replace the
> > > > > _attributes static method of sqlhtml.FormWidget. Try this in your
> > > > > model:
> > > > > ...
> > > > > @staticmethod
> > > > > def _attributes(field, widget_attributes, **attributes):
> > > > > attr = dict(
> > > > > _id = '%s_%s' % (field._tablename, field.name),
> > > > > _class = field.type,
> > > > > _name = field.name,
> > > > > requires = field.requires,
> > > > > )
> > > > > attr.update(widget_attributes)
> > > > > attr.update(attributes)
> > > > > attr.update(_class=attr['_class'] + ' myclass') #<-NEW
> > > > > return attr
> >
> > > > > import gluon.sqlhtml
> > > > > gluon.sqlhtml.FormWidget._attributes = _attributes
> >
> > > > > Or were you wanting to actually do it at the helper level?
> >
> > > > > On Nov 8, 1:58 am, Thadeus Burgess  wrote:
> >
> > > > > > But I don't want the labels to have this class, just the actual
> form
> > > > > > elements
> >
> > > > > > -Thadeus
> >
> > > > > > On Sun, Nov 8, 2009 at 1:56 AM, Thadeus Burgess <
> > > thade...@thadeusb.com>wrote:
> >
> > > > > > > What would be the best way to automatically pass a certain
> class to
> > > every
> > > > > > > web2py form helper? (INPUT, TEXTAREA, etc..)
> >
> > > > > > > -Thadeus
> >
> >
> >
>

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



[web2py:34888] pjamas or any

2009-11-08 Thread dbb

Do we have the ability to call pjamas from web2py (or incorporated in
gluon) or do we have a similar function in web2py; the functions I am
looking is to get data remotely and to post data remotely and the
remote side to have intelligence( to know) to update the data when the
data is accessed and also to know who accessed the data, e.g., I have
a set of attributes x, y,z to send , and get results w, m, k from the
remote site related x, y,z. The other side my use C++, python, java,
javascript etc, on my side I have web2py
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34887] Re: Pass class to widgets

2009-11-08 Thread mdipierro

why not?

On Nov 8, 10:35 am, Thadeus Burgess  wrote:
> What about just replacing SQLFORM.widgets with my own in db.py?
>
> -Thadeus
>
> On Sun, Nov 8, 2009 at 8:47 AM, mr.freeze  wrote:
>
> > Doh! He did say "every web2py form helper" though :)
>
> > On Nov 8, 8:45 am, mdipierro  wrote:
> > > Do not do this:
>
> > > gluon.sqlhtml.FormWidget._attributes = _attributes
>
> > > It would change the widget for all applications called concurrently.
>
> > > Instead do
>
> > > db.table.field.widget = lambda field: FormWidget(field,_attributes =
> > > _attributes)
>
> > > On Nov 8, 8:18 am, "mr.freeze"  wrote:
>
> > > > If you want to append a class to every widget, you can replace the
> > > > _attributes static method of sqlhtml.FormWidget. Try this in your
> > > > model:
> > > > ...
> > > > @staticmethod
> > > > def _attributes(field, widget_attributes, **attributes):
> > > >     attr = dict(
> > > >         _id = '%s_%s' % (field._tablename, field.name),
> > > >         _class = field.type,
> > > >         _name = field.name,
> > > >         requires = field.requires,
> > > >         )
> > > >     attr.update(widget_attributes)
> > > >     attr.update(attributes)
> > > >     attr.update(_class=attr['_class'] + ' myclass') #<-NEW
> > > >     return attr
>
> > > > import gluon.sqlhtml
> > > > gluon.sqlhtml.FormWidget._attributes = _attributes
>
> > > > Or were you wanting to actually do it at the helper level?
>
> > > > On Nov 8, 1:58 am, Thadeus Burgess  wrote:
>
> > > > > But I don't want the labels to have this class, just the actual form
> > > > > elements
>
> > > > > -Thadeus
>
> > > > > On Sun, Nov 8, 2009 at 1:56 AM, Thadeus Burgess <
> > thade...@thadeusb.com>wrote:
>
> > > > > > What would be the best way to automatically pass a certain class to
> > every
> > > > > > web2py form helper? (INPUT, TEXTAREA, etc..)
>
> > > > > > -Thadeus
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34886] Re: anybody seen this?

2009-11-08 Thread Robin B

You should also see this:

http://www.extjs.com/deploy/dev/examples/desktop/desktop.html

Robin

On Nov 8, 1:02 am, mdipierro  wrote:
> Really nice.
>
> On Nov 7, 11:01 pm, Wes James  wrote:
>
> > Massimo,
>
> > I thought I'd try some web2py with that site below:
>
> >http://db.nr.usu.edu/qpacn
>
> > Notice in the search box, as you type, it does the search as you type ;)
>
> > -wes
>
> > On Sat, Oct 3, 2009 at 3:54 PM, mdipierro  wrote:
>
> > >http://desktop.sonspring.com/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34885] Re: You are going to love this

2009-11-08 Thread Christopher Steel

I am starting to get the impression that it is raining candy here...

; )



On Nov 8, 10:23 am, Johann Spies  wrote:
> 2009/11/8 mdipierro :
>
>
>
> > you must run web2py with --upgrade=yes this will upgrade admin/welcome/
> > examples
>
> > or manually
>
> > cd applications/admin
> > tar zxvf ../../admin.w2p
>
> Thanks. I missed that somehow in my reading of the manual/documentation.
>
> Regards
> Johann
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34884] Re: Pass class to widgets

2009-11-08 Thread Thadeus Burgess
What about just replacing SQLFORM.widgets with my own in db.py?

-Thadeus




On Sun, Nov 8, 2009 at 8:47 AM, mr.freeze  wrote:

>
> Doh! He did say "every web2py form helper" though :)
>
> On Nov 8, 8:45 am, mdipierro  wrote:
> > Do not do this:
> >
> > gluon.sqlhtml.FormWidget._attributes = _attributes
> >
> > It would change the widget for all applications called concurrently.
> >
> > Instead do
> >
> > db.table.field.widget = lambda field: FormWidget(field,_attributes =
> > _attributes)
> >
> > On Nov 8, 8:18 am, "mr.freeze"  wrote:
> >
> > > If you want to append a class to every widget, you can replace the
> > > _attributes static method of sqlhtml.FormWidget. Try this in your
> > > model:
> > > ...
> > > @staticmethod
> > > def _attributes(field, widget_attributes, **attributes):
> > > attr = dict(
> > > _id = '%s_%s' % (field._tablename, field.name),
> > > _class = field.type,
> > > _name = field.name,
> > > requires = field.requires,
> > > )
> > > attr.update(widget_attributes)
> > > attr.update(attributes)
> > > attr.update(_class=attr['_class'] + ' myclass') #<-NEW
> > > return attr
> >
> > > import gluon.sqlhtml
> > > gluon.sqlhtml.FormWidget._attributes = _attributes
> >
> > > Or were you wanting to actually do it at the helper level?
> >
> > > On Nov 8, 1:58 am, Thadeus Burgess  wrote:
> >
> > > > But I don't want the labels to have this class, just the actual form
> > > > elements
> >
> > > > -Thadeus
> >
> > > > On Sun, Nov 8, 2009 at 1:56 AM, Thadeus Burgess <
> thade...@thadeusb.com>wrote:
> >
> > > > > What would be the best way to automatically pass a certain class to
> every
> > > > > web2py form helper? (INPUT, TEXTAREA, etc..)
> >
> > > > > -Thadeus
> >
>

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



[web2py:34883] Re: Charsets and Includes. Or why do my accented words get screwed in includes.

2009-11-08 Thread Jonathan Lundell

On Nov 8, 2009, at 7:33 AM, Benigno wrote:

>
> I didnt explain myself correctly. I am setting the  equiv="Content-Type" content="text/html; charset=iso-8859-1" />
> dinamically when in spanish. However, the accented words still show
> badly.

The character set specified by the http header takes precedence over  
the meta tag, and web2py does this:

class HTTP(BaseException):
 ...
 def to(self, responder):
 ...
 if not 'Content-Type' in self.headers:
 self.headers['Content-Type'] = 'text/html; charset=UTF-8'

It can be overridden, as you see, but I don't know what all the  
implications of that would be. Sticking to utf-8 might be a better  
choice.

>
> Massimo:
>   I dont understand exactly what you mean, whats the correct way to
> do this then?.
>
> On Nov 8, 4:06 pm, salingrosso  wrote:
>> 2009/11/8 mdipierro 
>>
>>
>>
>>> You do not have the option of using latin1. utf8 is set by web2py in
>>> the http header.
>>
>> But in layout.html I see:
>>   




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



[web2py:34882] Chapter 1 from 2nd edition web2py book in Spanish

2009-11-08 Thread DenesL

Chapter 1 from 2nd edition web2py book in Spanish
Capítulo 1 del manual web2py 2da edición en Español

http://drop.io/web2py_DenesL/asset/web2py-libro2-cap1-pdf

Want to help in translating other chapters?
¿Quiere ayudar con la traducción de otros capítulos?

Contact me.
Contácteme.

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



[web2py:34881] Re: Join web2py wave

2009-11-08 Thread Marat Maksumov

I am very interested in receiving an invitation to Google Wave...

On Nov 7, 10:44 am, Nicolás de la Torre  wrote:
> i have sent invites to:
>
> vinc...@vincentdavis.com
> thade...@thadeusb.com
> szims...@gmail.com
> boris.manojlo...@gmail.com
> richard_gor...@verizon.net
> chris.st...@gmail.com
> m.grit...@gmail.com
> lapcc...@gmail.com
> obutov...@googlemail.com
>
> Pls tell me if someone is missing.

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



[web2py:34880] Re: Charsets and Includes. Or why do my accented words get screwed in includes.

2009-11-08 Thread salingrosso
The problem can be in database. Tables of your database are
set in UT8 and when you try to change the charset in your
html it can't convert correctly accented words.

2009/11/8 Benigno 

>
> I didnt explain myself correctly. I am setting the  equiv="Content-Type" content="text/html; charset=iso-8859-1" />
> dinamically when in spanish. However, the accented words still show
> badly.
>
> Massimo:
>   I dont understand exactly what you mean, whats the correct way to
> do this then?.
>
> On Nov 8, 4:06 pm, salingrosso  wrote:
> > 2009/11/8 mdipierro 
> >
> >
> >
> > > You do not have the option of using latin1. utf8 is set by web2py in
> > > the http header.
> >
> > But in layout.html I see:
> >   
> >
>

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



[web2py:34879] Re: Charsets and Includes. Or why do my accented words get screwed in includes.

2009-11-08 Thread Benigno

I didnt explain myself correctly. I am setting the 
dinamically when in spanish. However, the accented words still show
badly.

Massimo:
   I dont understand exactly what you mean, whats the correct way to
do this then?.

On Nov 8, 4:06 pm, salingrosso  wrote:
> 2009/11/8 mdipierro 
>
>
>
> > You do not have the option of using latin1. utf8 is set by web2py in
> > the http header.
>
> But in layout.html I see:
>   
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34878] Re: You are going to love this

2009-11-08 Thread Johann Spies

2009/11/8 mdipierro :
>
> you must run web2py with --upgrade=yes this will upgrade admin/welcome/
> examples
>
> or manually
>
> cd applications/admin
> tar zxvf ../../admin.w2p
>

Thanks. I missed that somehow in my reading of the manual/documentation.

Regards
Johann

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



[web2py:34877] Re: Charsets and Includes. Or why do my accented words get screwed in includes.

2009-11-08 Thread salingrosso
2009/11/8 mdipierro 

>
> You do not have the option of using latin1. utf8 is set by web2py in
> the http header.
>
>
But in layout.html I see:
  

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



[web2py:34876] Re: Join web2py wave

2009-11-08 Thread David

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



[web2py:34875] Re: Pass class to widgets

2009-11-08 Thread mr.freeze

Doh! He did say "every web2py form helper" though :)

On Nov 8, 8:45 am, mdipierro  wrote:
> Do not do this:
>
> gluon.sqlhtml.FormWidget._attributes = _attributes
>
> It would change the widget for all applications called concurrently.
>
> Instead do
>
> db.table.field.widget = lambda field: FormWidget(field,_attributes =
> _attributes)
>
> On Nov 8, 8:18 am, "mr.freeze"  wrote:
>
> > If you want to append a class to every widget, you can replace the
> > _attributes static method of sqlhtml.FormWidget. Try this in your
> > model:
> > ...
> > @staticmethod
> > def _attributes(field, widget_attributes, **attributes):
> >     attr = dict(
> >         _id = '%s_%s' % (field._tablename, field.name),
> >         _class = field.type,
> >         _name = field.name,
> >         requires = field.requires,
> >         )
> >     attr.update(widget_attributes)
> >     attr.update(attributes)
> >     attr.update(_class=attr['_class'] + ' myclass') #<-NEW
> >     return attr
>
> > import gluon.sqlhtml
> > gluon.sqlhtml.FormWidget._attributes = _attributes
>
> > Or were you wanting to actually do it at the helper level?
>
> > On Nov 8, 1:58 am, Thadeus Burgess  wrote:
>
> > > But I don't want the labels to have this class, just the actual form
> > > elements
>
> > > -Thadeus
>
> > > On Sun, Nov 8, 2009 at 1:56 AM, Thadeus Burgess 
> > > wrote:
>
> > > > What would be the best way to automatically pass a certain class to 
> > > > every
> > > > web2py form helper? (INPUT, TEXTAREA, etc..)
>
> > > > -Thadeus
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34874] Re: web2py and keyed tables

2009-11-08 Thread mdipierro

Denese. You did a fanstatic job. This was needed for some time.

On Nov 8, 7:38 am, DenesL  wrote:
> A) What are they?
>
> Keyed tables are usually legacy tables that don't follow the
> traditional hidden 'id' field construct of web2py tables.
> Instead they define one or more fields as primary key.
> Currently web2py supports keyed tables on DB2, MS SQL, Ingres (thanks
> Chris Clark) and Informix (after pending patch, thanks Hans Murx).
> To add support for other DB engines see at the bottom of this info.
>
> B) How do you create keyed tables?
>
> Using the same define_table as before but with one difference, the
> table has a 'primarykey' attribute.
>
> db.define_table('kperson',
>     Field('name','string'),
>     primarykey=['name'],
>     migrate=False # for legacy tables
> )
>
> db.define_table('kdog',
>     Field('name','string'),
>     Field('owner','reference kperson.name'),
>     primarykey=['name'],
>     migrate=False # for legacy tables
> )
>
> Notes:
> 1) primarykey is a list of the field names that make up the primary
> key
> 2) all primarykey fields will have NOT NULL set even if not specified
> 3) references are to other keyed tables only
> 4) references must use tablename.fieldname format, as shown above
> 5) update_record function is not available
> 6) web2py rev.1354 (or higher) has appadmin support for keyed tables.
>
> C) How to use keyed tables?
>
> They behave almost the same way, the differences are explained below.
>
> >>> db.kperson.insert(name='Dave')
>
> {'name': 'Dave'}
>
> note: insert returns the primary key of the inserted record or None if
> the record was not inserted
>
> After some more inserts:
>
> >>> print db(db.kperson.name!='').select()
>
> kperson.name
> Anna
> Bart
> Cody
> Dave
>
> >>> db.kdog.insert(name='Rex',owner='Cody')
>
> {'name': 'Rex'}
>
> >>> db.kdog.insert(name='Fido',owner='Anna')
>
> {'name': 'Fido'}
>
> >>> db.kdog.insert(name='Rover',owner='Cody')
>
> {'name': 'Rover'}
>
> >>> print db(db.kdog.name!='').select()
>
> kdog.name,kdog.owner
> Fido,Anna
> Rex,Cody
> Rover,Cody
>
> >>> print db(db.kdog.owner=='Cody').select()
>
> kdog.name,kdog.owner
> Rex,Cody
> Rover,Cody
>
> >>> db.kdog.insert(name='Spot',owner='Bart')
>
> {'name': 'Spot'}
>
> >>> db(db.kdog.name=='Spot').delete()
>
> 1
>
> >>> db(db.kdog.name=='Lassie').delete()
>
> 0
>
> note: successful operations return 1, 0 otherwise
>
> >>> db(db.kdog.name=='Rover').update(owner='Bart')
>
> 1
>
> >>> print db(db.kdog.name!='').select()
>
> kdog.name,kdog.owner
> Fido,Anna
> Rex,Cody
> Rover,Bart
>
> >>> print 
> >>> db((db.kdog.owner==db.kperson.name)&(db.kdog.name.like('R%'))).select()
>
> kdog.name,kdog.owner,kperson.name
> Rex,Cody,Cody
> Rover,Bart,Bart
>
> D) About compound (multiple) keys.
>
> Compound keys can be defined and used in regular operations by passing
> a dictionary.
>
> db.define_table('mperson',
>   Field('name1'),
>   Field('name2'),
>   primarykey=['name1','name2'])
>
> >>> print db.mperson.insert(name1='Bart',name2='Simpson')
>
> {'name2': 'Simpson', 'name1': 'Bart'}
>
> or the equivalent>>> k={'name1': 'Lisa', 'name2':'Simpson'}
> >>> print db.mperson.insert(**k)
>
> {'name2': 'Simpson', 'name1': 'Lisa'}
>
> >>> print db(db.mperson.name1!='').select()
>
> mperson.name1,mperson.name2
> Bart,Simpson
> Lisa,Simpson
>
> But references are only to single key, for now.
> Field('x','reference mperson.name2')
>
> For selects you have to split the key manually.
> db((db.mperson.name1=='Bart')&(db.mperson.name2=='Simpson')).select()
>
> E) How can I add support for DB xxx?
>
> Glad to hear that you want to help, we can use your expertise on xxx.
> It is not that complicated.
>
> Step 1:
> In gluon/sql.py look for SQL_DIALECTS.
> It is a dictionary of command "translations" for all supported DBs.
> Now look for the key that represent the DB you want to help adding in.
> We need two new entries in there, one with key 'reference FK' for
> field level foreign key and another key 'reference TFK' for table
> level foreign key.
> Use the entries under 'mssql' as a guide.
>
> Step 2:
> In the same file look for the definition of the insert function for
> keyed tables (near line 2250 in the latest trunk).
> Add your DB to the list in the if statement and add an exception using
> the ones already there as a reference.
>
> Step 3:
> Test, test, test...
>
> ** NOTE **: this is a work in progress.
> Please report any problems to the group.
> Ideas for improvement are welcome too.
>
> Denes.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34873] Re: Pass class to widgets

2009-11-08 Thread mr.freeze

Seems like you could do the same to DIV.xml (which most helpers derive
from I believe):

def xml(self):
(fa, co) = self._xml()
if 'class="' in fa:
fa = fa.replace('class="','class="myclass ')
if not self.tag:
return co
if self.tag[-1:] == '/':
return '<%s%s />' % (self.tag[:-1], fa)
return '<%s%s>%s' % (self.tag, fa, co, self.tag)

import gluon.html
gluon.html.DIV.xml = xml

On Nov 8, 8:18 am, "mr.freeze"  wrote:
> If you want to append a class to every widget, you can replace the
> _attributes static method of sqlhtml.FormWidget. Try this in your
> model:
> ...
> @staticmethod
> def _attributes(field, widget_attributes, **attributes):
>     attr = dict(
>         _id = '%s_%s' % (field._tablename, field.name),
>         _class = field.type,
>         _name = field.name,
>         requires = field.requires,
>         )
>     attr.update(widget_attributes)
>     attr.update(attributes)
>     attr.update(_class=attr['_class'] + ' myclass') #<-NEW
>     return attr
>
> import gluon.sqlhtml
> gluon.sqlhtml.FormWidget._attributes = _attributes
>
> Or were you wanting to actually do it at the helper level?
>
> On Nov 8, 1:58 am, Thadeus Burgess  wrote:
>
> > But I don't want the labels to have this class, just the actual form
> > elements
>
> > -Thadeus
>
> > On Sun, Nov 8, 2009 at 1:56 AM, Thadeus Burgess 
> > wrote:
>
> > > What would be the best way to automatically pass a certain class to every
> > > web2py form helper? (INPUT, TEXTAREA, etc..)
>
> > > -Thadeus
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34872] Re: Pass class to widgets

2009-11-08 Thread mdipierro

Do not do this:

gluon.sqlhtml.FormWidget._attributes = _attributes

It would change the widget for all applications called concurrently.

Instead do

db.table.field.widget = lambda field: FormWidget(field,_attributes =
_attributes)

On Nov 8, 8:18 am, "mr.freeze"  wrote:
> If you want to append a class to every widget, you can replace the
> _attributes static method of sqlhtml.FormWidget. Try this in your
> model:
> ...
> @staticmethod
> def _attributes(field, widget_attributes, **attributes):
>     attr = dict(
>         _id = '%s_%s' % (field._tablename, field.name),
>         _class = field.type,
>         _name = field.name,
>         requires = field.requires,
>         )
>     attr.update(widget_attributes)
>     attr.update(attributes)
>     attr.update(_class=attr['_class'] + ' myclass') #<-NEW
>     return attr
>
> import gluon.sqlhtml
> gluon.sqlhtml.FormWidget._attributes = _attributes
>
> Or were you wanting to actually do it at the helper level?
>
> On Nov 8, 1:58 am, Thadeus Burgess  wrote:
>
> > But I don't want the labels to have this class, just the actual form
> > elements
>
> > -Thadeus
>
> > On Sun, Nov 8, 2009 at 1:56 AM, Thadeus Burgess 
> > wrote:
>
> > > What would be the best way to automatically pass a certain class to every
> > > web2py form helper? (INPUT, TEXTAREA, etc..)
>
> > > -Thadeus
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34871] Re: Charsets and Includes. Or why do my accented words get screwed in includes.

2009-11-08 Thread mdipierro

You do not have the option of using latin1. utf8 is set by web2py in
the http header.

On Nov 8, 7:30 am, Doxaliber  wrote:
> You could try to change tha charset dinamically.
> Use iso-8859-1 for Spanish
> and utf8 for english.
>
> On 8 Nov, 12:13, Benigno  wrote:
>
> > Salingrosso:    Yes to both of your questions.
>
> > I had not had this issue before, as translated text with T('') gets
> > translated taking this into account. So I ussually wrote the program
> > in english, and translated to spanish using the translation files.
>
> > In this occasion, I am writing in spanish and translating to english,
> > thats why its only now that I am noticing this behaviour.
>
> > On Nov 8, 10:28 am, salingrosso  wrote:
>
> > > If you see the source code of index.html generated by
> > > the server do you see:
> > >  ?
>
> > > Do you use this syntax to insert layout.html in your index.html?
> > > {{extend 'layout.html'}}
>
> > > 2009/11/8 Benigno 
>
> > > > Hello,
>
> > > >    There may be some very easy solution to this or something I am
> > > > doing wrong that I am not aware of, but when I have a layout.html with
> > > > the tag:
>
> > > >    
>
> > > >    And then I have an include, like index.html, when I write accented
> > > > words on the included file, they do not get correctly "parsed" and I
> > > > get the funny symbols.
>
> > > >   The same code, if writen straight in the layout.html, outputs
> > > > everything correctly.
>
> > > >   Is there anything I can add to my index.html file so that it uses
> > > > the same meta tag as in the layout it is included in?.
>
> > > > Thanks again,
> > > > Benigno.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34870] Re: web2py and keyed tables

2009-11-08 Thread mr.freeze

Two words: freakin sweet.  This opens up a whole new range of
applications that I can use web2py for at work. Thanks!

On Nov 8, 7:38 am, DenesL  wrote:
> A) What are they?
>
> Keyed tables are usually legacy tables that don't follow the
> traditional hidden 'id' field construct of web2py tables.
> Instead they define one or more fields as primary key.
> Currently web2py supports keyed tables on DB2, MS SQL, Ingres (thanks
> Chris Clark) and Informix (after pending patch, thanks Hans Murx).
> To add support for other DB engines see at the bottom of this info.
>
> B) How do you create keyed tables?
>
> Using the same define_table as before but with one difference, the
> table has a 'primarykey' attribute.
>
> db.define_table('kperson',
>     Field('name','string'),
>     primarykey=['name'],
>     migrate=False # for legacy tables
> )
>
> db.define_table('kdog',
>     Field('name','string'),
>     Field('owner','reference kperson.name'),
>     primarykey=['name'],
>     migrate=False # for legacy tables
> )
>
> Notes:
> 1) primarykey is a list of the field names that make up the primary
> key
> 2) all primarykey fields will have NOT NULL set even if not specified
> 3) references are to other keyed tables only
> 4) references must use tablename.fieldname format, as shown above
> 5) update_record function is not available
> 6) web2py rev.1354 (or higher) has appadmin support for keyed tables.
>
> C) How to use keyed tables?
>
> They behave almost the same way, the differences are explained below.
>
> >>> db.kperson.insert(name='Dave')
>
> {'name': 'Dave'}
>
> note: insert returns the primary key of the inserted record or None if
> the record was not inserted
>
> After some more inserts:
>
> >>> print db(db.kperson.name!='').select()
>
> kperson.name
> Anna
> Bart
> Cody
> Dave
>
> >>> db.kdog.insert(name='Rex',owner='Cody')
>
> {'name': 'Rex'}
>
> >>> db.kdog.insert(name='Fido',owner='Anna')
>
> {'name': 'Fido'}
>
> >>> db.kdog.insert(name='Rover',owner='Cody')
>
> {'name': 'Rover'}
>
> >>> print db(db.kdog.name!='').select()
>
> kdog.name,kdog.owner
> Fido,Anna
> Rex,Cody
> Rover,Cody
>
> >>> print db(db.kdog.owner=='Cody').select()
>
> kdog.name,kdog.owner
> Rex,Cody
> Rover,Cody
>
> >>> db.kdog.insert(name='Spot',owner='Bart')
>
> {'name': 'Spot'}
>
> >>> db(db.kdog.name=='Spot').delete()
>
> 1
>
> >>> db(db.kdog.name=='Lassie').delete()
>
> 0
>
> note: successful operations return 1, 0 otherwise
>
> >>> db(db.kdog.name=='Rover').update(owner='Bart')
>
> 1
>
> >>> print db(db.kdog.name!='').select()
>
> kdog.name,kdog.owner
> Fido,Anna
> Rex,Cody
> Rover,Bart
>
> >>> print 
> >>> db((db.kdog.owner==db.kperson.name)&(db.kdog.name.like('R%'))).select()
>
> kdog.name,kdog.owner,kperson.name
> Rex,Cody,Cody
> Rover,Bart,Bart
>
> D) About compound (multiple) keys.
>
> Compound keys can be defined and used in regular operations by passing
> a dictionary.
>
> db.define_table('mperson',
>   Field('name1'),
>   Field('name2'),
>   primarykey=['name1','name2'])
>
> >>> print db.mperson.insert(name1='Bart',name2='Simpson')
>
> {'name2': 'Simpson', 'name1': 'Bart'}
>
> or the equivalent>>> k={'name1': 'Lisa', 'name2':'Simpson'}
> >>> print db.mperson.insert(**k)
>
> {'name2': 'Simpson', 'name1': 'Lisa'}
>
> >>> print db(db.mperson.name1!='').select()
>
> mperson.name1,mperson.name2
> Bart,Simpson
> Lisa,Simpson
>
> But references are only to single key, for now.
> Field('x','reference mperson.name2')
>
> For selects you have to split the key manually.
> db((db.mperson.name1=='Bart')&(db.mperson.name2=='Simpson')).select()
>
> E) How can I add support for DB xxx?
>
> Glad to hear that you want to help, we can use your expertise on xxx.
> It is not that complicated.
>
> Step 1:
> In gluon/sql.py look for SQL_DIALECTS.
> It is a dictionary of command "translations" for all supported DBs.
> Now look for the key that represent the DB you want to help adding in.
> We need two new entries in there, one with key 'reference FK' for
> field level foreign key and another key 'reference TFK' for table
> level foreign key.
> Use the entries under 'mssql' as a guide.
>
> Step 2:
> In the same file look for the definition of the insert function for
> keyed tables (near line 2250 in the latest trunk).
> Add your DB to the list in the if statement and add an exception using
> the ones already there as a reference.
>
> Step 3:
> Test, test, test...
>
> ** NOTE **: this is a work in progress.
> Please report any problems to the group.
> Ideas for improvement are welcome too.
>
> Denes.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34869] Re: Pass class to widgets

2009-11-08 Thread mr.freeze

If you want to append a class to every widget, you can replace the
_attributes static method of sqlhtml.FormWidget. Try this in your
model:
...
@staticmethod
def _attributes(field, widget_attributes, **attributes):
attr = dict(
_id = '%s_%s' % (field._tablename, field.name),
_class = field.type,
_name = field.name,
requires = field.requires,
)
attr.update(widget_attributes)
attr.update(attributes)
attr.update(_class=attr['_class'] + ' myclass') #<-NEW
return attr

import gluon.sqlhtml
gluon.sqlhtml.FormWidget._attributes = _attributes

Or were you wanting to actually do it at the helper level?


On Nov 8, 1:58 am, Thadeus Burgess  wrote:
> But I don't want the labels to have this class, just the actual form
> elements
>
> -Thadeus
>
> On Sun, Nov 8, 2009 at 1:56 AM, Thadeus Burgess wrote:
>
> > What would be the best way to automatically pass a certain class to every
> > web2py form helper? (INPUT, TEXTAREA, etc..)
>
> > -Thadeus
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34868] web2py help & resources

2009-11-08 Thread DenesL

Primary source of help: web2py groups
-
http://groups.google.com/group/web2py/topics
http://groups.google.com/group/web2py-developers/topics
http://groups.google.com/group/web2py-users-brazil/topics

Tips on searching the users group
-
The search inside the group does not work very well, use these
instead:
http://www.google.ca/advanced_search?q=site:groups.google.com/group/web2py&hl=en
http://dir.gmane.org/gmane.comp.python.web2py

Resources
-

web site   http://www.web2py.com
docs   http://web2py.com/examples/default/docs (check the links)
DALhttp://web2py.com/examples/default/dal
APIhttp://web2py.com/examples/default/api
examples   http://www.web2py.com/examples/default/examples
auth,  http://web2py.com/examples/default/tools
CRUD,
services
Cron   http://web2py.com/examples/default/cron

   ** all links above also work on your local copy of web2py
**

FAQhttp://www.web2py.com/AlterEgo
wiki   http://wiki.web2py.com
book 2ed   http://www.lulu.com/content/4968879
   http://www.scribd.com/doc/19211452/Web2py-Manual
slices http://www.web2pyslices.com/main/default/index
chat   http://web2pychat.com
videos http://vimeo.com/videos/search:web2py
slides http://www.scribd.com/doc/16085263/web2py-slides-version-1644
   http://www.web2py.com/examples/static/pyworks.pdf
   http://www.web2py.com/examples/static/web2py_presentacion_es.pdf
epydocshttp://web2py.com/examples/static/epydoc/index.html
cheatsheet http://www.web2py.com/examples/static/web2py_cheatsheet.pdf
free apps  http://www.web2py.com/appliances


Downloads
-
(Win, Mac, source, latest development)
http://www.web2py.com/examples/default/download

Professional support

http://www.web2py.com/examples/default/support

Running on GAE notes

http://www.futurelogic.com/init/default/wiki/GAEDeploy

Who is using it?

http://appliedstacks.com/NewestFirst/web2py

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



[web2py:34867] Re: Join web2py wave

2009-11-08 Thread dbb

I am in

On Nov 7, 7:00 pm, Thadeus Burgess  wrote:
> I think we should all start a public web2py wave! :)
>
> -Thadeus
>
>
>
> On Sat, Nov 7, 2009 at 3:54 PM, mdipierro  wrote:
>
> > I have account. I just have not figured out what I am supposed to do
> > with it.
>
> > On Nov 7, 3:08 pm, Nicolás de la Torre  wrote:
> > > Invited:
>
> > > debe...@yahoo.com
> > > kuo...@gmail.com
> > > murxun...@googlemail.com
> > > jorgeh...@gmail.com
>
> > > I have 5 invites left. Just ask.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34866] web2py and keyed tables

2009-11-08 Thread DenesL

A) What are they?

Keyed tables are usually legacy tables that don't follow the
traditional hidden 'id' field construct of web2py tables.
Instead they define one or more fields as primary key.
Currently web2py supports keyed tables on DB2, MS SQL, Ingres (thanks
Chris Clark) and Informix (after pending patch, thanks Hans Murx).
To add support for other DB engines see at the bottom of this info.



B) How do you create keyed tables?

Using the same define_table as before but with one difference, the
table has a 'primarykey' attribute.

db.define_table('kperson',
Field('name','string'),
primarykey=['name'],
migrate=False # for legacy tables
)

db.define_table('kdog',
Field('name','string'),
Field('owner','reference kperson.name'),
primarykey=['name'],
migrate=False # for legacy tables
)

Notes:
1) primarykey is a list of the field names that make up the primary
key
2) all primarykey fields will have NOT NULL set even if not specified
3) references are to other keyed tables only
4) references must use tablename.fieldname format, as shown above
5) update_record function is not available
6) web2py rev.1354 (or higher) has appadmin support for keyed tables.



C) How to use keyed tables?

They behave almost the same way, the differences are explained below.

>>> db.kperson.insert(name='Dave')
{'name': 'Dave'}

note: insert returns the primary key of the inserted record or None if
the record was not inserted

After some more inserts:

>>> print db(db.kperson.name!='').select()
kperson.name
Anna
Bart
Cody
Dave

>>> db.kdog.insert(name='Rex',owner='Cody')
{'name': 'Rex'}

>>> db.kdog.insert(name='Fido',owner='Anna')
{'name': 'Fido'}

>>> db.kdog.insert(name='Rover',owner='Cody')
{'name': 'Rover'}

>>> print db(db.kdog.name!='').select()
kdog.name,kdog.owner
Fido,Anna
Rex,Cody
Rover,Cody

>>> print db(db.kdog.owner=='Cody').select()
kdog.name,kdog.owner
Rex,Cody
Rover,Cody

>>> db.kdog.insert(name='Spot',owner='Bart')
{'name': 'Spot'}

>>> db(db.kdog.name=='Spot').delete()
1

>>> db(db.kdog.name=='Lassie').delete()
0

note: successful operations return 1, 0 otherwise

>>> db(db.kdog.name=='Rover').update(owner='Bart')
1

>>> print db(db.kdog.name!='').select()
kdog.name,kdog.owner
Fido,Anna
Rex,Cody
Rover,Bart

>>> print 
>>> db((db.kdog.owner==db.kperson.name)&(db.kdog.name.like('R%'))).select()
kdog.name,kdog.owner,kperson.name
Rex,Cody,Cody
Rover,Bart,Bart



D) About compound (multiple) keys.

Compound keys can be defined and used in regular operations by passing
a dictionary.

db.define_table('mperson',
  Field('name1'),
  Field('name2'),
  primarykey=['name1','name2'])

>>> print db.mperson.insert(name1='Bart',name2='Simpson')
{'name2': 'Simpson', 'name1': 'Bart'}

or the equivalent
>>> k={'name1': 'Lisa', 'name2':'Simpson'}
>>> print db.mperson.insert(**k)
{'name2': 'Simpson', 'name1': 'Lisa'}

>>> print db(db.mperson.name1!='').select()
mperson.name1,mperson.name2
Bart,Simpson
Lisa,Simpson


But references are only to single key, for now.
Field('x','reference mperson.name2')

For selects you have to split the key manually.
db((db.mperson.name1=='Bart')&(db.mperson.name2=='Simpson')).select()



E) How can I add support for DB xxx?

Glad to hear that you want to help, we can use your expertise on xxx.
It is not that complicated.

Step 1:
In gluon/sql.py look for SQL_DIALECTS.
It is a dictionary of command "translations" for all supported DBs.
Now look for the key that represent the DB you want to help adding in.
We need two new entries in there, one with key 'reference FK' for
field level foreign key and another key 'reference TFK' for table
level foreign key.
Use the entries under 'mssql' as a guide.

Step 2:
In the same file look for the definition of the insert function for
keyed tables (near line 2250 in the latest trunk).
Add your DB to the list in the if statement and add an exception using
the ones already there as a reference.

Step 3:
Test, test, test...


** NOTE **: this is a work in progress.
Please report any problems to the group.
Ideas for improvement are welcome too.


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



[web2py:34865] Re: Charsets and Includes. Or why do my accented words get screwed in includes.

2009-11-08 Thread Doxaliber

You could try to change tha charset dinamically.
Use iso-8859-1 for Spanish
and utf8 for english.

On 8 Nov, 12:13, Benigno  wrote:
> Salingrosso:    Yes to both of your questions.
>
> I had not had this issue before, as translated text with T('') gets
> translated taking this into account. So I ussually wrote the program
> in english, and translated to spanish using the translation files.
>
> In this occasion, I am writing in spanish and translating to english,
> thats why its only now that I am noticing this behaviour.
>
> On Nov 8, 10:28 am, salingrosso  wrote:
>
> > If you see the source code of index.html generated by
> > the server do you see:
> >  ?
>
> > Do you use this syntax to insert layout.html in your index.html?
> > {{extend 'layout.html'}}
>
> > 2009/11/8 Benigno 
>
> > > Hello,
>
> > >    There may be some very easy solution to this or something I am
> > > doing wrong that I am not aware of, but when I have a layout.html with
> > > the tag:
>
> > >    
>
> > >    And then I have an include, like index.html, when I write accented
> > > words on the included file, they do not get correctly "parsed" and I
> > > get the funny symbols.
>
> > >   The same code, if writen straight in the layout.html, outputs
> > > everything correctly.
>
> > >   Is there anything I can add to my index.html file so that it uses
> > > the same meta tag as in the layout it is included in?.
>
> > > Thanks again,
> > > Benigno.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34864] Re: experimental externalization of auth, crud and mail settings

2009-11-08 Thread mr.freeze

I'll see what I can do.  Any specific tips?

On Nov 8, 4:54 am, Mengu  wrote:
> Not related but a suggestion for the web site. web2pyslices is one of
> the best resources on web2py and I think when people search for
> web2py, you should come in the first page. So, why don't you make
> things more seo'd?
>
> On Nov 8, 12:22 am, "mr.freeze"  wrote:
>
> > I put this together to let non-developer admins manage settings
> > through appadmin.  It basically puts all settings that are string,
> > int, double or boolean in the database.  I would like feedback on the
> > perils/merits of doing this.
>
> >http://www.web2pyslices.com/main/slices/take_slice/26
>
> > Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34863] Re: Charsets and Includes. Or why do my accented words get screwed in includes.

2009-11-08 Thread Benigno

Salingrosso:Yes to both of your questions.

I had not had this issue before, as translated text with T('') gets
translated taking this into account. So I ussually wrote the program
in english, and translated to spanish using the translation files.

In this occasion, I am writing in spanish and translating to english,
thats why its only now that I am noticing this behaviour.

On Nov 8, 10:28 am, salingrosso  wrote:
> If you see the source code of index.html generated by
> the server do you see:
>  ?
>
> Do you use this syntax to insert layout.html in your index.html?
> {{extend 'layout.html'}}
>
> 2009/11/8 Benigno 
>
>
>
> > Hello,
>
> >    There may be some very easy solution to this or something I am
> > doing wrong that I am not aware of, but when I have a layout.html with
> > the tag:
>
> >    
>
> >    And then I have an include, like index.html, when I write accented
> > words on the included file, they do not get correctly "parsed" and I
> > get the funny symbols.
>
> >   The same code, if writen straight in the layout.html, outputs
> > everything correctly.
>
> >   Is there anything I can add to my index.html file so that it uses
> > the same meta tag as in the layout it is included in?.
>
> > Thanks again,
> > Benigno.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34862] Re: limit number of characters displayed.

2009-11-08 Thread Mengu

{{ = post.body[:156] }}

On Nov 8, 12:15 pm, annet  wrote:
> In order to not mess up my layout, I would like to limit the number of
> lines displayed from a textarea to three, measured in characters that
> is: 156 characters. The last word should be followed bij three dots.
> Is there a way to code this in the view, or am I better off putting a
> length validator on the field of type text?
>
> Kind regards,
>
> Annet.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34861] Re: experimental externalization of auth, crud and mail settings

2009-11-08 Thread Mengu

Not related but a suggestion for the web site. web2pyslices is one of
the best resources on web2py and I think when people search for
web2py, you should come in the first page. So, why don't you make
things more seo'd?

On Nov 8, 12:22 am, "mr.freeze"  wrote:
> I put this together to let non-developer admins manage settings
> through appadmin.  It basically puts all settings that are string,
> int, double or boolean in the database.  I would like feedback on the
> perils/merits of doing this.
>
> http://www.web2pyslices.com/main/slices/take_slice/26
>
> Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34860] Re: Join web2py wave

2009-11-08 Thread Mengu

Count me for that too. I have a wave account but don't know how it
works. I joined to web2py wave by the way.

On Nov 7, 11:54 pm, mdipierro  wrote:
> I have account. I just have not figured out what I am supposed to do
> with it.
>
> On Nov 7, 3:08 pm, Nicolás de la Torre  wrote:
>
> > Invited:
>
> > debe...@yahoo.com
> > kuo...@gmail.com
> > murxun...@googlemail.com
> > jorgeh...@gmail.com
>
> > I have 5 invites left. Just ask.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34859] Re: Join web2py wave

2009-11-08 Thread Massimiliano
I would love to receive an invite

Thank you
Massimiliano

On Sun, Nov 8, 2009 at 7:15 AM, Roger Gicquel wrote:

>
> +1 pls.
>
> On Nov 8, 4:37 am, DenesL  wrote:
> > I will take one. Thank you.
> >
> > On 7 nov, 16:08, Nicolás de la Torre  wrote:
> >
> > > Invited:
> >
> > > debe...@yahoo.com
> > > kuo...@gmail.com
> > > murxun...@googlemail.com
> > > jorgeh...@gmail.com
> >
> > > I have 5 invites left. Just ask.
>
> >
>


-- 
Massimiliano

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



[web2py:34858] limit number of characters displayed.

2009-11-08 Thread annet

In order to not mess up my layout, I would like to limit the number of
lines displayed from a textarea to three, measured in characters that
is: 156 characters. The last word should be followed bij three dots.
Is there a way to code this in the view, or am I better off putting a
length validator on the field of type text?

Kind regards,

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



[web2py:34857] Re: You are going to love this

2009-11-08 Thread Peterle

these things are welcome.

-
On 8 Nov, 08:58, mdipierro  wrote:
> you must run web2py with --upgrade=yes this will upgrade admin/welcome/
> examples
>
> or manually
>
> cd applications/admin
> tar zxvf ../../admin.w2p
>
> A lot of people seem to complain about this process. It is there
> because I always thought people were going to modify admin. This never
> happened. Should we make admin upgrade by default?
>
> On Nov 8, 1:46 am, Johann Spies  wrote:
>
> > 2009/11/7 mdipierro :
>
> > > And if you do not see that it is because you must upgrade the admin
> > > interface.
>
> > No it is not there.
>
> > This is confusing.  I have unzipped the new web2py_src.zip and thought
> > this is the way to upgrade.  Is upgrading the amin interface then
> > another process?
>
> > It seems to me I must export the application, delete my web2py
> > installation, install the new package and then import my application.
>
> > Regards
> > Johann
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:34856] Re: Charsets and Includes. Or why do my accented words get screwed in includes.

2009-11-08 Thread salingrosso
If you see the source code of index.html generated by
the server do you see:
 ?

Do you use this syntax to insert layout.html in your index.html?
{{extend 'layout.html'}}

2009/11/8 Benigno 

>
> Hello,
>
>There may be some very easy solution to this or something I am
> doing wrong that I am not aware of, but when I have a layout.html with
> the tag:
>
>
>
>And then I have an include, like index.html, when I write accented
> words on the included file, they do not get correctly "parsed" and I
> get the funny symbols.
>
>   The same code, if writen straight in the layout.html, outputs
> everything correctly.
>
>   Is there anything I can add to my index.html file so that it uses
> the same meta tag as in the layout it is included in?.
>
> Thanks again,
> Benigno.
> >
>

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



[web2py:34855] Charsets and Includes. Or why do my accented words get screwed in includes.

2009-11-08 Thread Benigno

Hello,

There may be some very easy solution to this or something I am
doing wrong that I am not aware of, but when I have a layout.html with
the tag:



And then I have an include, like index.html, when I write accented
words on the included file, they do not get correctly "parsed" and I
get the funny symbols.

   The same code, if writen straight in the layout.html, outputs
everything correctly.

   Is there anything I can add to my index.html file so that it uses
the same meta tag as in the layout it is included in?.

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



[web2py:34854] Re: You are going to love this

2009-11-08 Thread salingrosso
> A lot of people seem to complain about this process. It is there
> because I always thought people were going to modify admin. This never
> happened. Should we make admin upgrade by default?
>
>
No, I think the manual method is better. Perhaps we could
insert an advise similar to the one used on the right to
annouce  the availability of new versions of web2py.

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