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
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
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
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
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
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=...)
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
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
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
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',
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
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
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
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",
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
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
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
But that only works for web forms. I want the same for programmatic access.
(db.table.insert() call etc)
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
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
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
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
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
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)
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
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
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
why static_method is used to define this? not better to have some @lazy
decorator?
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
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
I prefer compass (sass) and blueprint :)
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
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.
>
>
>
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?
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
def user()
if request.args(0) == 'profile':
db.auth_user.email.readable = db.auth_user.email.writable = False
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
37 matches
Mail list logo