[web2py] UserGroups: Extend Auth_Group or Table Inheritance?

2011-08-20 Thread Anaconda
I am looking to allow users to create their own groups and have members. Which is more effecient: Table Inheritance: db.define_table('user_groups', db.auth_group, Field('name') ...ect...)) or Extend auth_group: db.define_table( auth.settings.table_user_group, Field('role', lengt

[web2py] Re: Issue with SQLFORM.factory() and IS_IN_SET()

2011-08-20 Thread TheSweetlink
Nevermind. Got it. There was a mismatch in # of fields between SQLFORM.factory and my custom form in the view. This caused the form to have errors rather than being accepted. I will be more careful in the future with my custom forms. Thank you Richard for your help. -David

[web2py] Re: How to get the referenced objects from a list:reference

2011-08-20 Thread Anthony
Does db.person.courses.represent(person.coures) work? See http://web2py.com/book/default/chapter/06#Many-to-Many,-list:,-and-contains . Anthony On Saturday, August 20, 2011 1:58:04 PM UTC-4, fishwebby wrote: > Hi, I'm trying to do something quite straightforward but can't seem to > work out h

Re: [web2py] Re: query quest

2011-08-20 Thread howesc
can you write the raw SQL for what you want to do? sounds like you need to do a sub-query with it's own grouping so that you can get the max start value, and then join those results into your outer query where you can group by something different. if you can write the SQL then we'll be certain

[web2py] Re: How to get the referenced objects from a list:reference

2011-08-20 Thread howesc
i have not found a way to do that without querying the referenced table, so if there is a way to do it i have missed it too. cfh

Re: [web2py] Re: built-in lazy virtual fields

2011-08-20 Thread Bruno Rocha
Massimo, As you are dealing with VirtualFields, consider including some standard properties such as: Label, Comment, Represent, and Type. Label is the more usable of them, specially to display headers=labels in SQLTABLE. In PowerTable I used something like: @virtualsettings(label=..., type=...)

Re: [web2py] request.now is in local time?

2011-08-20 Thread Jonathan Lundell
On Aug 20, 2011, at 10:04 AM, nick name wrote: > On Saturday, August 20, 2011 11:19:07 AM UTC-4, Jonathan Lundell wrote: > Yeah, it probably should have been utcnow. Nothing to stop you (or web2py, > for that matter) from setting request.utcnow, though. > > Yep, I am already doing that. It may d

[web2py] Re: Google datastore concepts - denormalising and list:reference fields

2011-08-20 Thread howesc
right, so when i need to do a belongs query for more than 30 items: items=db(db.my_table.end_user.belongs(id_list[0:30])).select() for i in range(30, len(id_list)+30, 30): items = items & \ db(db.my_table.end_user.belongs(id_list[i-30:i])).select() i'd say that w

[web2py] Re: GAE questions...

2011-08-20 Thread howesc
i use list fields (which now implemented using the GAE native list property and string list property) liberally. in places where i wish i had a join, i tend to use the web2py syntax that does the subquery for me: item.user.name where item is a Row, with a field user that is a reference to the

[web2py] How to get the referenced objects from a list:reference

2011-08-20 Thread fishwebby
Hi, I'm trying to do something quite straightforward but can't seem to work out how to do it: for a list:reference field, get all the items in the reference field (not just their IDs). For example, a person with many courses: db.define_table('course', Field('title')) db.define_table('person',

[web2py] Re: built-in lazy virtual fields

2011-08-20 Thread Carlos
Hi Massimo, Note also that my above proposal will improve polymorphism too, in the sense that we can assign the same virtual LAZY fields to any (or all) tables, and they will all use 'self' as the actual row, without even having to know any internals (like the table name). Let me know what you

Re: [web2py] request.now is in local time?

2011-08-20 Thread nick name
On Saturday, August 20, 2011 11:19:07 AM UTC-4, Jonathan Lundell wrote: > Yeah, it probably should have been utcnow. Nothing to stop you (or web2py, > for that matter) from setting request.utcnow, though. > Yep, I am already doing that. It may differ by a millisecond or 100 from the original re

[web2py] Re: request.now is in local time?

2011-08-20 Thread nick name
using local time puts you in a world of pain when you try to co-ordinate systems. Windows for years couldn't correctly do dst<->utc conversion other than the current year (if rules have changed; which they did in 2004). Not sure if they fixed that in 7 or not. When you stat having services (and

[web2py] Re: built-in lazy virtual fields

2011-08-20 Thread Massimo Di Pierro
This is all a proposal. I think we should discuss it some more. The all business of virtual fields has been mostly motivated by needs of the users. I have had very little use for them. On Aug 20, 11:33 am, Anthony wrote: > OK. When you said the old "normal" virtual fields were now "discouraged",

[web2py] Re: built-in lazy virtual fields

2011-08-20 Thread Carlos
Hi Massimo, So far this is great ! But, while we're on the lazy fields topic, can you implement the following specialized VirtualCommand (maybe named Virtual*Row*Command)?: class VirtualRowCommand(object): def __init__(self, method, row): self.method = method

[web2py] Re: built-in lazy virtual fields

2011-08-20 Thread Anthony
OK. When you said the old "normal" virtual fields were now "discouraged", I thought you were implying all virtual fields should be lazy, but sounds like we still want the lazy/non-lazy distinction, just with a new way of doing both (both internally and API). Thanks for clarifying. Anthony O

[web2py] Re: built-in lazy virtual fields

2011-08-20 Thread Massimo Di Pierro
I think we could deprecate the old virtual fields. Yet the new syntax (for now experimental) has two APIs: db.x.f = Field.Virtual(a.f) db.x.g = Field.Lazy(a.g) because one maps into row.x.f (an attribute, compute at the time of select) and one into row.x.g() (a method to be called later). I thin

Re: [web2py] Opposite of "required..." for field?

2011-08-20 Thread nick name
But that only works for web forms. I want the same for programmatic access. (db.table.insert() call etc)

[web2py] Re: built-in lazy virtual fields

2011-08-20 Thread Anthony
Is the plan to deprecate old style (non-lazy) virtual fields? If so, then maybe the new lazy virtual fields shouldn't be modified with "lazy" everywhere -- they should just be referred to as "virtual". So, the decorator could just be "@virtualfield", and Field.Virtual() could refer to the new l

Re: [web2py] request.now is in local time?

2011-08-20 Thread Jonathan Lundell
On Aug 19, 2011, at 2:11 PM, nick name wrote: > request.now is in local time, is that on purpose? > I think a "request.utcnow" would also be useful (now can be derived from > utcnow, but the other way around is not 1:1 on days when daylight saving time > changes) Yeah, it probably should have b

[web2py] Re: Passing around a list reference to view

2011-08-20 Thread Cliff
I think you need to revise your model a little. Get rid of the 'list:reference tag' and replace it with db.tag. Then add a db.data.tags.requires as described here: http://www.web2py.com/book/default/chapter/07#Validators Look for the IS_IN_DB validator. One clue that you have a model problem

[web2py] setting entity's parent in google appengine

2011-08-20 Thread Amnon Khen
Dear web2py community, I am wondering if it is possible to create entity groups & set an entity's parent entity when using web2py with GAE. Is this post by dlypka, http://groups.google.com/group/web2py/msg/880c1cbc0813dd50 , the best that is currently possible? Is there a more straight-forward wa

Re: [web2py] Re: query quest

2011-08-20 Thread Manuele
Hi! again about this old question... I tried to work around this not so easy problem but I always came back to it. the solution proposed by howesc runs but not resolves my needs. Now suppose I need to extract another value of the curve record corresponding to the max start value... how can I

[web2py] Re: built-in lazy virtual fields

2011-08-20 Thread Massimo Di Pierro
If couse one can also do class A(): def __init__(self,n): self,n=n f(self,row): return row.x.id+1+self.n g(self,row,a=1): return row.x.id+a+self.n h(self,row,a=1,b=2): return row.x.id+a+b+self.n a=A(7) db.define_table('x',) db.x.f = Field.Virtual(a.f) db.x.g = Field.Lazy(a.g)

[web2py] Re: built-in lazy virtual fields

2011-08-20 Thread Massimo Di Pierro
How about we just do this: db.define_table('x',Field('number','integer')) if db(db.x).isempty(): [db.x.insert(number=i) for i in range(10)] db.x.normal_shift = Field.Virtual(lambda row: row.x.number+1) db.x.lazy_shift = Field.Lazy(lambda row, delta=3: row.x.number+delta) for row in db(db.x).sele

[web2py] Re: built-in lazy virtual fields

2011-08-20 Thread Massimo Di Pierro
OK try: db=DAL() db.define_table('x',Field('number','integer')) if db(db.x).isempty(): [db.x.insert(number=i) for i in range(10)] from gluon.dal import lazy_virtualfield class MyVirtualFields(object): # normal virtual field def normal_shift(self): return self.x.number+1 # lazy virtua

[web2py] Re: built-in lazy virtual fields

2011-08-20 Thread Massimo Di Pierro
Yes but if we use lazy we have to define and import it from somewhere. There is another reason. Using staticmethod we can also do class A(): pass a=A() a.f=lambda(instance,row,*a,**b): return 'lazy value' a.g=lambda(instance,row,*a,**b): return 'lazy value' a.h=lambda(instance,row,*a,**b): return

Re: [web2py] Re: built-in lazy virtual fields

2011-08-20 Thread Bruno Rocha
why static_method is used to define this? not better to have some @lazy decorator?

[web2py] Re: built-in lazy virtual fields

2011-08-20 Thread Massimo Di Pierro
db.define_table('x',Field('number','integer')) if db(db.x).isempty(): [db.x.insert(number=i) for i in range(10)] class MyVirtualFields(object): # normal virtual field (backward compatible, discouraged) def normal_shift(self): return self.x.number +1

[web2py] Re: built-in lazy virtual fields

2011-08-20 Thread Massimo Di Pierro
I am still uneasy about this and I may still change the syntax about the lazy virtualfields On Aug 19, 7:32 pm, rochacbruno wrote: > Very good! Thank you

Re: [web2py] Slick new CSS framework from Twitter

2011-08-20 Thread rif
I prefer compass (sass) and blueprint :)

[web2py] Re: Best way to extend user profiles in web2py?

2011-08-20 Thread Anaconda
Wow, works wonderful, thanks Bruno and thank your for the quick reply!! On Aug 20, 12:12 am, Bruno Rocha wrote: > def user() >   if request.args(0) == 'profile': >       db.auth_user.email.readable = db.auth_user.email.writable = False

[web2py] Re: Best way to extend user profiles in web2py?

2011-08-20 Thread Anaconda
Just a side note, what about using table inheritance, creating a user_profile table that inherits from auth_table? I just saw it in the web2py book, it seems similar to the django abstract base class where other model classes may subclass from the abstract class inheriting all its fields. > > >

[web2py] Re: request.now is in local time?

2011-08-20 Thread pbreit
I'm guessing that for most projects, local time makes the most sense. I've seen a lot of advice to use Unix time but datetime.now seems fine to me, right?

[web2py] Re: web2py trunk [a bit OT]

2011-08-20 Thread pbreit
Not exactly. If you do "hg pull; hg update" you're going to get trunk, the most up-to-date version of the code. The "stable" tags vary (eg, R-1.97.1, R-1.98.1, etc). Go here and look at the "Tag" drop-down: https://code.google.com/p/web2py/source/list

Re: [web2py] Re: Best way to extend user profiles in web2py?

2011-08-20 Thread Bruno Rocha
def user() if request.args(0) == 'profile': db.auth_user.email.readable = db.auth_user.email.writable = False

[web2py] Re: Best way to extend user profiles in web2py?

2011-08-20 Thread Anaconda
Anthony, thanks for the help. I am still a new developer and i am struggling on how to change a databases field settings in my controller: def user() if request.args(0) == 'profile': #i need to call database here, select row and change readable/ writable to 'True' On Aug 19, 6:58