[web2py] scheduler task is queued but not running

2014-01-08 Thread peter
I have a scheduler task marked as queued. I have an active working with 
living heartbeats. They both have the same group name, the time for the 
task to run is in the past. The task is not being executed. Does anyone 
have any idea what might cause the problem. Web2py version 2.8.2
Thanks
Peter

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: GAE: defaults on _tableobj

2014-01-08 Thread Quint
Here is a patch.


On Tuesday, January 7, 2014 9:03:48 AM UTC+1, Massimo Di Pierro wrote:

 Thank you. I will take care of this asap. Can you submit a patch?

 On Friday, 3 January 2014 04:10:11 UTC-6, Quint wrote:

 I created an issue for this:

 https://code.google.com/p/web2py/issues/detail?id=1842

 On Thursday, January 2, 2014 6:45:59 PM UTC+1, Quint wrote:

 Hello everybody,

 Happy New Year!

 I'm using GAE and sometimes a need to call some GAE datastore functions 
 directly.

 (For instance when I want to supply a key_name when I put() an entity 
 so I can have better performance to get() that entity from db.
 Or when I want to use put_multi())

 Anyway, I can use the *_tableobj* property of the web2py table to 
 access the GAE model class.

 But, this class does not have the defaults applied to it's properties 
 while the Fields on the web2py table do.
 This means that when I put() my _tableobj instance (using GAE API) , 
 the defaults are not set in the database record.

 At the moment a call this function in my db model after each table 
 definition:


 @classmethod
 def set_defaults(cls, table):
 
 Takes a web2py table and sets the defaults of all Fields and sets
 those defaults on the associated properties of the tableobj
 (tableobj = the GAE model class associated with the web2py table)
 
 for propname, prop in table._tableobj._properties.iteritems():
 field = getattr(table, propname, None)
 if None != field and isinstance(field, Field):
 prop._default = field.default

 Can this (or something like this) be integrated in the create_table() 
 method of GoogleDatastoreAdapter() so it's done when the table gets created?

 Thanks,

 Regards

 Quint



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Index: E:/repositories/Mercurial/web2py/gluon/dal.py
===
--- E:/repositories/Mercurial/web2py/gluon/dal.py	(revision 5706:f691e2676f64)
+++ E:/repositories/Mercurial/web2py/gluon/dal.py	(revision 5706+:f691e2676f64+)
@@ -4941,6 +4941,16 @@
 table._tableobj = classobj(table._tablename, (polymodel._tableobj, ), myfields)
 else:
 raise SyntaxError(polymodel must be None, True, a table or a tablename)
+
+# Set defaults on the GAE model class (tableobj)
+for propname, prop in table._tableobj._properties.iteritems():
+field = getattr(table, propname, None)
+if None != field and isinstance(field, Field):
+if self.use_ndb:
+prop._default = field.default
+else:
+prop.default = field.default
+
 return None
 
 def expand(self,expression,field_type=None):


[web2py] GAE: insert using key_name

2014-01-08 Thread Quint
Hi,

In GAE it's possibe to supply a key_name when you insert an entity. This 
is a string that you can then use as an id to efficiently fetch an entity 
from db.
(
https://developers.google.com/appengine/docs/python/datastore/entities#Python_Kinds_and_identifiers
)

I would like to be able to do this using web2py. I could also choose to use 
the GAE API directly to do this but then a could not make use thing like 
calculated Fields etc in my web2py tables.

I made the following modification to the GoogleDatastoreAdapter insert() 
function:

 def insert(self,table,fields):
dfields=dict((f.name,self.represent(v,f.type)) for f,v in fields)
# table._db['_lastsql'] = self._insert(table,fields)
# Field name 'gae_key_name' can be used insert using key_name for 
both DB and NDB.
keyname = None





*if 'gae_key_name' in dfields:keyname = 
dfields['gae_key_name']if self.use_ndb:
dfields['id'] = dfields.pop('gae_key_name')else:
dfields['key_name'] = dfields.pop('gae_key_name')*
tmp = table._tableobj(**dfields)
tmp.put()
key = tmp.key if self.use_ndb else tmp.key()
rid = Reference(key.id())
(rid._table, rid._record, rid._gaekey) = (table, None, key)
return rid

Now one can insert using a field name 'gae_key_name'. 
DB and NDB expect different parameter names for the model constructors to 
supply a key_name. 'key_name vs 'id''.

Now the only problem is that _listify() in Table required that all fields 
are defined in the Table.
We can now choose to define a Field gae_key_name in every Table that we 
want to use this feature for.
Another option is to modify the _listify function a bit to accomodate this:

def _listify(self,fields,update=False):
new_fields = {} # format: new_fields[name] = (field,value)


# store all fields passed as input in new_fields
# 'gae_key_name' is GAE specific and should not be defined in the 
table.
for name in fields:
if not name in self.fields:







*if name not in ['id', 'gae_key_name']:raise 
SyntaxError('Field %s does not belong to the table' 
% name)if name == 'gae_key_name':# 
Create stub Field for 'gae_key_name' so it can be included  
  # without being defined in the model.field = 
Field('gae_key_name', 'string')
new_fields['gae_key_name'] = field, fields['gae_key_name']*
else:
field = self[name]
value = fields[name]
if field.filter_in:
value = field.filter_in(value)
new_fields[name] = (field,value)

The last option feels a bit hacky but removes the requirement to define a 
Field 'gae_key_name' in every Table.

What to you think?

I attached a patch that includes both changes.

Regards,

Quint



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Index: E:/repositories/Mercurial/web2py/gluon/dal.py
===
--- E:/repositories/Mercurial/web2py/gluon/dal.py	(revision 5706:f691e2676f64)
+++ E:/repositories/Mercurial/web2py/gluon/dal.py	(revision 5706+:f691e2676f64+)
@@ -5300,6 +5300,15 @@
 def insert(self,table,fields):
 dfields=dict((f.name,self.represent(v,f.type)) for f,v in fields)
 # table._db['_lastsql'] = self._insert(table,fields)
+# Field name 'gae_key_name' can be used insert using key_name for both DB and NDB.
+keyname = None
+if 'gae_key_name' in dfields:
+keyname = dfields['gae_key_name']
+if self.use_ndb:
+dfields['id'] = dfields.pop('gae_key_name')
+else:
+dfields['key_name'] = dfields.pop('gae_key_name')
+
 tmp = table._tableobj(**dfields)
 tmp.put()
 key = tmp.key if self.use_ndb else tmp.key()
@@ -9035,11 +9044,17 @@
 new_fields = {} # format: new_fields[name] = (field,value)
 
 # store all fields passed as input in new_fields
+# 'gae_key_name' is GAE specific and should not be defined in the table.
 for name in fields:
 if not name in self.fields:
-if name != 'id':
+if name not in ['id', 'gae_key_name']:
 raise SyntaxError(
 'Field %s does not belong to the table' % name)
+if name == 

[web2py] Re: GAE: insert using key_name

2014-01-08 Thread Alan Etkin


 I would like to be able to do this using web2py. I could also choose to 
 use the GAE API directly to do this but then a could not make use thing 
 like calculated Fields etc in my web2py tables.


One issue about forcing key names is that there's no guarantee that the new 
key will provide a valid ID integer when retrieved, and the DAL api 
requires record insertions to provide that kind of value. Note that calls 
to Key.id() can return None, which is used by the insert method to create 
the db reference object. IIRC, the exception of that rule is the case of 
keyed tables, but I'm not if it is supported for gae nosql. In case it is 
supported, the patch could instead use keyed tables for storing entity key 
names.

From the datastore Python api:

... The identifier may be either a *key name* string, assigned explicitly 
by the application when the instance is created, or an integer *numeric 
ID,*assigned automatically by App Engine when the instance is written (
puthttps://developers.google.com/appengine/docs/python/datastore/modelclass#Model_put)
 
to the Datastore ...

I have not tested the behavior but according to the above I think that the 
datastore api would return None instead of valid integer identifiers for 
the case of entities stored with manual key names.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Nested References in Smart Grid

2014-01-08 Thread MVolpes
Hi 

I have been using this framework for the last few days and I am in awe a 
fantastic framework. I have come from a strong .net and php framework back 
ground and wanted to learn python this has already taught me so much!!

I have a question that hopefully can be answered easily and maybe I am 
overlooking something.

I have the smart grid working well however i want to display a reference of 
a reference eg

Vehicle  Model  Make



Please bare in mind i am using a legacy db

Model
#
db.define_table('tblmake',
Field('MakeID','id'),
Field('Make','string'),
format=%(Make)s,
migrate=False)


#
db.define_table('tblmodels',
Field('Model','string'),
Field('ModelID','id'),
Field('MakeID','reference tblmake'),
format=%(Model)s,
migrate=False)


#
db.define_table('tblvehicles',
Field('VehicleID','id'),
Field('Registration','string'),
Field('Driver','string'),
Field('Model','reference tblmodels'),
migrate=False)

Controller

vehiclefields = [db.tblvehicles.Registration, db.tblvehicles.Driver, 
db.tblvehicles.Model]

vehiclelinks = [lambda row: A('View 
Post',_href=URL(search,test,args=[row.VehicleID]))]
vehicles = SQLFORM.smartgrid(db.tblvehicles, orderby=VehicleID Desc, 
fields=vehiclefields, formname=vehiclegrid,
 details=False, editable=False, 
deletable=False,links=vehiclelinks, linked_tables=False)

I would like to display the db.tblmake.Make field 

How can I do this?
Can I do this?

I have tried adding various combinations but with no luck

Any help would be greatly appreciated

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Microsoft SQL Server Migrate Trying to Create New Table instead of Editing Old One

2014-01-08 Thread PN
For future reference, verifying that this can be fixed using the 
fake_migrate feature (
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Fixing-broken-migrations
)

Summary of steps:
1. Set your model in define_table to the old model that matches existing 
database
2. Set fake_migrate to True in define_table(..., migrate=True, 
fake_migrate=True)
3. Run your app - this will create the migrate files
4. Remove the fake_migrate argument from define_table
5. Run your app again, this will do a migrate with an ALTER instead of a 
CREATE

On Thursday, October 3, 2013 3:45:17 PM UTC-4, PN wrote:

 So, in theory, will the following process fix the issue?

 1. Start web2py with old DAL definitions and migrate = True. This should 
 create the .table files as the old structure
 2. Then change the DAL to reflect the new database structure, migrate 
 still = True
 3. Restart web2py and my tables should get migrated?

 On Sunday, September 29, 2013 7:45:32 AM UTC-4, Niphlod wrote:

 probably your .table files weren't in sync with your model. web2py issues 
 a CREATE statement only if the corresponding .table file is not found into 
 the databases/ folder (implicating that that table doesn't exist on the 
 backend)

 On Sunday, September 29, 2013 2:06:50 AM UTC+2, PN wrote:

 Version: Using web2py 2.6.4

 Steps:
 
 1. I used web2py DAL to create a table in ms sql. This ran in production 
 for a while.

 2. I downloaded the web2py app to my development machine, and added a 
 column to the table in DAL.

 3. When I try to go to the table in web2py admin (database 
 administration) with migrate=True, I get an error message class 
 'pyodbc.ProgrammingError' ('42S01', [42S01] [Microsoft][ODBC SQL Server 
 Driver][SQL Server]There is already an object named 'BIG_Mapping' in the 
 database. (2714) (SQLExecDirectW))

 4. The error message shows that web2py is issuing a CREATE command, not 
 the ALTER command (in the error log)

 Any suggestions on further troubleshooting? I can alter the table 
 manually but wanted to test migrations through DAL so I understand them for 
 future reference.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Important New Year News: Edison Award

2014-01-08 Thread Mark Wachira
Good luck Massimo, excellent framework 

On Saturday, January 4, 2014 7:08:38 AM UTC+3, Massimo Di Pierro wrote:

 Web2py/me have been nominated for the Edison Award. Please wish web2py 
 (and me) good luck. :-)



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: intercept closing session

2014-01-08 Thread Anthony
On Wednesday, January 8, 2014 1:48:28 AM UTC-5, Giuseppe D'Amico wrote:

 I have to  connect to a database known only at runtime, I create the  
 model on the fly,


Do you have to create the database or a database table on the fly (or 
something else)?
 

 but it is not thread safe,


Why is it not thread safe?
 

 so I thought http://it.dicios.com/enit/thought that a possible solution 
 could be to give to the model the name of the session_id


Do you need a model per session or just per user? In any case, why does 
this require knowing when the user terminates the session -- do you have to 
destroy the data at that point?

Anthony



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: Why web2py and AnguljarJS?

2014-01-08 Thread Richard Vézina
There is also : AngularStrap (Angular + Bootstrap)

:)

Richard


On Tue, Jan 7, 2014 at 8:26 PM, Derek sp1d...@gmail.com wrote:

 Yea, there are a lot of similarities, I decided myself just to skip web2py
 and do most of the work in a client side template, where the webserver only
 serves static files and json, and the client framework handles everything
 else. It works pretty good on the desktop, but I haven't even tested in on
 mobile. There's room for both.


 On Sunday, January 5, 2014 3:06:43 PM UTC-7, Ruud Schroen wrote:

 I see more and more about using angularjs with web2py.

 But why? What would be an example of a benefit from using those two.
 Cause when i look at AngularJS, it already looks alot like web2py.

 Not saying that it's a bad idea, just wondering ;)

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: GAE: insert using key_name

2014-01-08 Thread Quint
Yes,

Your post reminds me, I forgot something. I thought that when a key_name is 
used, it could simply return that as an id.
But if you say that DAL requires that it returns an integer id, than yes, 
that would break it.
When you use a key_name, the records do not have an numeric id.
But does that mean you should not allow it to be inserted that way?
Nothing restricts users from operating (using web2py api) on rows inserted 
with GAE api


dfields=dict((f.name,self.represent(v,f.type)) for f,v in fields)
# table._db['_lastsql'] = self._insert(table,fields)
#quint
keyname = None
if 'gae_key_name' in dfields:
keyname = dfields['gae_key_name']
if self.use_ndb:
dfields['id'] = dfields.pop('gae_key_name')
else:
dfields['key_name'] = dfields.pop('gae_key_name')


tmp = table._tableobj(**dfields)
tmp.put()



*if keyname:return** keyname*


key = tmp.key if self.use_ndb else tmp.key()
rid = Reference(key.id() if self.use_ndb else key.id_or_name())
(rid._table, rid._record, rid._gaekey) = (table, None, key)
return rid


On Wednesday, January 8, 2014 2:18:53 PM UTC+1, Alan Etkin wrote:


 I would like to be able to do this using web2py. I could also choose to 
 use the GAE API directly to do this but then a could not make use thing 
 like calculated Fields etc in my web2py tables.


 One issue about forcing key names is that there's no guarantee that the 
 new key will provide a valid ID integer when retrieved, and the DAL api 
 requires record insertions to provide that kind of value. Note that calls 
 to Key.id() can return None, which is used by the insert method to create 
 the db reference object. IIRC, the exception of that rule is the case of 
 keyed tables, but I'm not if it is supported for gae nosql. In case it is 
 supported, the patch could instead use keyed tables for storing entity key 
 names.

 From the datastore Python api:

 ... The identifier may be either a *key name* string, assigned 
 explicitly by the application when the instance is created, or an integer 
 *numeric 
 ID,* assigned automatically by App Engine when the instance is written (
 puthttps://developers.google.com/appengine/docs/python/datastore/modelclass#Model_put)
  
 to the Datastore ...

 I have not tested the behavior but according to the above I think that the 
 datastore api would return None instead of valid integer identifiers for 
 the case of entities stored with manual key names.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Rows.compact and other Rows methods

2014-01-08 Thread Anthony
Let's discuss on the developers 
listhttps://groups.google.com/forum/?fromgroups=#!topic/web2py-developers/k2D6MVfBEYo
.

On Tuesday, January 7, 2014 9:52:16 PM UTC-5, Joe Barnhart wrote:

 Maybe the best answer is to change Row so that it always holds the full 
 set of keys (table:field) and change the __getitem__ method to look up the 
 key recursively if only one part is provided.  Here is a sample method 
 which implements this strategy of testing keys for dicts within dicts.  Our 
 case is a little simpler since we never recurse more than one level deep.

 def _finditem(obj, key):
 if key in obj: return obj[key]
 for k, v in obj.items():
 if isinstance(v,dict):
 item = _finditem(v, key)
 if item is not None:
 return item


 This has the advantage of working with existing code and preserving as 
 much information as possible in the Row object.  I have a feeling this 
 could make the internals of web2py a good deal more consistent.  Less 
 testing for special cases is always good!

 -- Joe B.

 On Tuesday, January 7, 2014 3:48:39 PM UTC-8, Anthony wrote:

 Note, same problem with .sort (it modifies the Row objects in 
 self.records), so we should probably fix that as well (will be a bit more 
 complicated).

 Anthony

 On Tuesday, January 7, 2014 11:03:56 AM UTC-5, Anthony wrote:

 The Rows.find() method does the following:

 for row in self:
 if f(row):
 if a=k: records.append(row)
 k += 1
 if k==b: break

 In a Rows object, there is self.records, which is a list of Row objects. 
 Each Row object has at least one top-level key with the table name, and the 
 record is stored in the value associated with that key:

 Row {'person': {'first_name': 'Bob', 'last_name': 'Smith'}}

 When .find() is called on a Rows object with compact=True, the __iter__ 
 method (called by the for row in self loop) returns a transformed version 
 of each Row object, removing the top-level table key:

 Row {'first_name': 'Bob', 'last_name': 'Smith'}

 I believe this is an unnecessary transformation, and it is what is 
 subsequently causing the .render() method to fail (the .render() method 
 expects the top-level table key to be there, whether or not compact=True). 
 I propose the following change to .find():

 for i, row in enumerate(self):
 if f(row):
 if a=k: records.append(self.records[i])
 k += 1
 if k==b: break

 The above code appends self.records[i] instead of row, which preserves 
 the original Row objects instead of including transformed objects. Anyone 
 see any problems with that change?

 Also, is there any reason all of the Rows methods (i.e., find, exclude, 
 __and__, __or__) should not be preserving the compact attribute of the 
 original Rows object? Perhaps we should change them all to do so. (Note, 
 this is a separate issue unrelated to the above problem with .find() and 
 .render().)

 Anthony

 On Tuesday, January 7, 2014 10:47:28 AM UTC-5, Anthony wrote:

 .render() works fine on Rows objects with compact=True, and it also 
 works fine on the results of .sort(), .exclude(), , and | operations. The 
 only problem is with the results of .find() operations when the original 
 Rows object has compact=True. The problem is that the .find() method 
 modifies the Row objects in self.records when compact=True, which it 
 probably should not due.

 Aside from this issue, perhaps the various Rows methods should preserve 
 the compact attribute -- not sure why they don't.

 Forwarding to the developers list for discussion.

 Anthony

 On Tuesday, January 7, 2014 3:10:00 AM UTC-5, Joe Barnhart wrote:

 I've been experimenting with the render method of the Rows class, and 
 I am very impressed.  But one drawback I found is that the Rows object 
 must 
 have its value set to compact=False to work properly with render().  It 
 isn't a problem if the Rows object is used directly without any 
 operators, 
 but I discovered that many, if not most, Rows methods do not preserve the 
 compact setting.

 For example. if you sort the Rows, it leaves compact=True.  Ditto, 
 if you use extract or find on the Rows object.  The  and | 
 operators also set the compact variable to True.  The upshot is that 
 you 
 can't use any of these operators on the Rows object and then use render 
 on the resulting object.

 It is a simple change to add the preservation of the compact flag 
 during any of these steps, but I'm unsure if this will break existing 
 code. 
  Other than coming up with a completely parallel set of methods, which 
 leave compact set the way it came in, I can't think of another approach 
 will be provably backwards-compatible.

 Here is an example:


 def __and__(self,other):
 if self.colnames!=other.colnames:
 raise Exception('Cannot  incompatible Rows objects')
 records = self.records+other.records

[web2py] Re: GAE: defaults on _tableobj

2014-01-08 Thread Alan Etkin
 (For instance when I want to supply a key_name when I put() an entity 
so I can have better performance to get() that entity from db.
 Or when I want to use put_multi())

put_multi is supported by DAL trough the bulk_insert method. How better is 
performance when using named keys? Do you have benchmarks?. Also, is the 
use of named keys supported by DAL? I think it is not: 

https://groups.google.com/d/msg/web2py/lFKiIGary0c/_sx0EoJkYk0J

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: GAE: insert using key_name

2014-01-08 Thread Alan Etkin
 But does that mean you should not allow it to be inserted that way?
 Nothing restricts users from operating (using web2py api) on rows 
inserted with GAE api

There's no restriction on the use of the datastore, since it is not a 
service reserved for web2py apps, although I belive storing records without 
id assignment would be restrictive for apps (and I doubt it will be 
actually compatible at all, with the exception of the keyed tables 
mentioned before, in case it is supported).

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: scheduler task is queued but not running

2014-01-08 Thread peter
I tried 'python scheduler.py -h' to get more information.

it blew up with an error no module named simplejson.

I have python2.6 after googling, I changed (in gluon/scheduler.py)

try:
from gluon.contrib.simplejson import loads, dumps
except:
from simplejson import loads, dumps

around line 84 to

try:
from gluon.contrib.simplejson import loads, dumps
except:
from json import loads, dumps

it now blows up with a different issue on 'python scheduler.py -h', however 
the scheduler now seems to work. The only other thing I changed was the 
write permission on web2py-scheduler-log.

This is the first time I have had problems with web2py and python2.6

maybe the above should be changed to 

try:
from gluon.contrib.simplejson import loads, dumps
except:
try:
from simplejson import loads, dumps
except
from json import loads, dumps


Peter


On Wednesday, 8 January 2014 10:23:11 UTC, peter wrote:

 I have a scheduler task marked as queued. I have an active working with 
 living heartbeats. They both have the same group name, the time for the 
 task to run is in the past. The task is not being executed. Does anyone 
 have any idea what might cause the problem. Web2py version 2.8.2
 Thanks
 Peter


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Rows.compact and other Rows methods

2014-01-08 Thread Anthony
This is an interesting idea. Instead of bothering with the compact 
attribute, we could make it so any Row object automatically works like a 
compact Row whenever it includes only one top-level key. So, if you have:

Row {'person': {'first_name': 'Bob', 'last_name': 'Smith'}}

you could do either row.person.first_name or row.first_name, regardless of 
the value of the compact attribute. The problem, though, is what happens 
if there is a field name that is the same as the table name. In that case, 
we would have to make the default to return either the full sub-record 
associated with the table, or just the field within the table, but neither 
approach would be fully backward compatible.

I suppose we could keep using the compact attribute, and simply pass it 
to the Row object, so the Row object itself knows whether it is compact or 
not. This would also be necessary for the Row.as_dict and related methods 
to remain backward compatible. But then the Row object needs to be able to 
hold a private attribute (e.g., __compact).

Thoughts on this?

Anthony

On Wednesday, January 8, 2014 9:41:19 AM UTC-5, Anthony wrote:

 Let's discuss on the developers 
 listhttps://groups.google.com/forum/?fromgroups=#!topic/web2py-developers/k2D6MVfBEYo
 .

 On Tuesday, January 7, 2014 9:52:16 PM UTC-5, Joe Barnhart wrote:

 Maybe the best answer is to change Row so that it always holds the full 
 set of keys (table:field) and change the __getitem__ method to look up the 
 key recursively if only one part is provided.  Here is a sample method 
 which implements this strategy of testing keys for dicts within dicts.  Our 
 case is a little simpler since we never recurse more than one level deep.

 def _finditem(obj, key):
 if key in obj: return obj[key]
 for k, v in obj.items():
 if isinstance(v,dict):
 item = _finditem(v, key)
 if item is not None:
 return item


 This has the advantage of working with existing code and preserving as 
 much information as possible in the Row object.  I have a feeling this 
 could make the internals of web2py a good deal more consistent.  Less 
 testing for special cases is always good!

 -- Joe B.

 On Tuesday, January 7, 2014 3:48:39 PM UTC-8, Anthony wrote:

 Note, same problem with .sort (it modifies the Row objects in 
 self.records), so we should probably fix that as well (will be a bit more 
 complicated).

 Anthony

 On Tuesday, January 7, 2014 11:03:56 AM UTC-5, Anthony wrote:

 The Rows.find() method does the following:

 for row in self:
 if f(row):
 if a=k: records.append(row)
 k += 1
 if k==b: break

 In a Rows object, there is self.records, which is a list of Row 
 objects. Each Row object has at least one top-level key with the table 
 name, and the record is stored in the value associated with that key:

 Row {'person': {'first_name': 'Bob', 'last_name': 'Smith'}}

 When .find() is called on a Rows object with compact=True, the __iter__ 
 method (called by the for row in self loop) returns a transformed 
 version 
 of each Row object, removing the top-level table key:

 Row {'first_name': 'Bob', 'last_name': 'Smith'}

 I believe this is an unnecessary transformation, and it is what is 
 subsequently causing the .render() method to fail (the .render() method 
 expects the top-level table key to be there, whether or not compact=True). 
 I propose the following change to .find():

 for i, row in enumerate(self):
 if f(row):
 if a=k: records.append(self.records[i])
 k += 1
 if k==b: break

 The above code appends self.records[i] instead of row, which preserves 
 the original Row objects instead of including transformed objects. Anyone 
 see any problems with that change?

 Also, is there any reason all of the Rows methods (i.e., find, exclude, 
 __and__, __or__) should not be preserving the compact attribute of the 
 original Rows object? Perhaps we should change them all to do so. (Note, 
 this is a separate issue unrelated to the above problem with .find() and 
 .render().)

 Anthony

 On Tuesday, January 7, 2014 10:47:28 AM UTC-5, Anthony wrote:

 .render() works fine on Rows objects with compact=True, and it also 
 works fine on the results of .sort(), .exclude(), , and | operations. 
 The 
 only problem is with the results of .find() operations when the original 
 Rows object has compact=True. The problem is that the .find() method 
 modifies the Row objects in self.records when compact=True, which it 
 probably should not due.

 Aside from this issue, perhaps the various Rows methods should 
 preserve the compact attribute -- not sure why they don't.

 Forwarding to the developers list for discussion.

 Anthony

 On Tuesday, January 7, 2014 3:10:00 AM UTC-5, Joe Barnhart wrote:

 I've been experimenting with the render method of the Rows class, and 
 I am very impressed.  But one 

[web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Brando
I'm trying to use 
jQuery-File-Uploadhttp://blueimp.github.io/jQuery-File-Upload/to implement 
multiple file uploads.  I'm using this 
tutorialhttp://in10min.blogspot.com/2013/04/web2py-implement-multiple-files-upload.html
 as 
well as this sample app 
HEREhttps://bitbucket.org/xavrenard/multiupload_module/src. 
 

Is there something in the standard web2py build that would be preventing 
the proper javascript or CSS from running?  The sample app should work 
right out of the box; however, no buttons are displayed. 

Has anyone successfully implemented this on web2py before?





-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Calvin Morrison
I  just wrote my own way to do it yesterday which worked great. I would
love it to go upstream.

It's just a standard file upload with the multiple attribute.

here's the entire thing: it spits out a form.

my db looks like this:

db.define_table('uploads',
Field('username', 'string'),
Field('filename', represent = lambda x, row: None if x == None else
x[:45]),
Field('up_file', 'upload', uploadseparate=True,
requires=IS_NOT_EMPTY()),
Field('up_date', 'datetime'),
Field('up_size', 'integer', represent= lambda x, row:
quikr_utils.sizeof_fmt(x) ),
Field('notes', 'text'))


my contorller

def submit():
  import datetime

  form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file',
_multiple=''), BR(), LABEL(Notes:), TEXTAREA(_name='notes'),
BR(),INPUT(_type='submit'))

  if form.accepts(request.vars, formname=form):

if hasattr(request.vars, 'up_files'):
  if len(request.vars.up_files)  0:

files = request.vars['up_files']
if not isinstance(files, list):
  files = [files]

for f in files:
  print f.filename
  up_file = db.uploads.up_file.store(f, f.filename)
  i = db.uploads.insert(notes=request.vars.notes,
up_file=up_file,filename=f.filename, username = auth.user.email, up_date=
datetime.datetime.now())
  db.commit()

redirect(URL('data', 'index'))
  else:
form.errors.up_files = No files selected

  return dict(form=form)


On 8 January 2014 10:14, Brando bhe...@trustcc.com wrote:

 I'm trying to use 
 jQuery-File-Uploadhttp://blueimp.github.io/jQuery-File-Upload/to implement 
 multiple file uploads.  I'm using this
 tutorialhttp://in10min.blogspot.com/2013/04/web2py-implement-multiple-files-upload.html
  as
 well as this sample app 
 HEREhttps://bitbucket.org/xavrenard/multiupload_module/src.


 Is there something in the standard web2py build that would be preventing
 the proper javascript or CSS from running?  The sample app should work
 right out of the box; however, no buttons are displayed.

 Has anyone successfully implemented this on web2py before?





  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Why web2py and AnguljarJS?

2014-01-08 Thread Ruud Schroen
So.. angularjs should be used when i want to create a website with lots of 
javascript/AJAX?

On Sunday, January 5, 2014 11:06:43 PM UTC+1, Ruud Schroen wrote:

 I see more and more about using angularjs with web2py.

 But why? What would be an example of a benefit from using those two.
 Cause when i look at AngularJS, it already looks alot like web2py.

 Not saying that it's a bad idea, just wondering ;)


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Brando
Calvin, you are awesome.  I will try this on my end and report back.





On Wednesday, January 8, 2014 7:18:28 AM UTC-8, Calvin Morrison wrote:

 I  just wrote my own way to do it yesterday which worked great. I would 
 love it to go upstream.

 It's just a standard file upload with the multiple attribute.

 here's the entire thing: it spits out a form.

 my db looks like this:

 db.define_table('uploads',
 Field('username', 'string'),
 Field('filename', represent = lambda x, row: None if x == None else 
 x[:45]),
 Field('up_file', 'upload', uploadseparate=True, 
 requires=IS_NOT_EMPTY()),
 Field('up_date', 'datetime'), 
 Field('up_size', 'integer', represent= lambda x, row: 
 quikr_utils.sizeof_fmt(x) ), 
 Field('notes', 'text'))


 my contorller

 def submit():
   import datetime

   form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file', 
 _multiple=''), BR(), LABEL(Notes:), TEXTAREA(_name='notes'), 
 BR(),INPUT(_type='submit'))

   if form.accepts(request.vars, formname=form):

 if hasattr(request.vars, 'up_files'):
   if len(request.vars.up_files)  0:

 files = request.vars['up_files']
 if not isinstance(files, list):
   files = [files]

 for f in files:
   print f.filename
   up_file = db.uploads.up_file.store(f, f.filename)
   i = db.uploads.insert(notes=request.vars.notes, 
 up_file=up_file,filename=f.filename, username = auth.user.email, up_date= 
 datetime.datetime.now())
   db.commit()

 redirect(URL('data', 'index'))
   else:
 form.errors.up_files = No files selected

   return dict(form=form)


 On 8 January 2014 10:14, Brando bhe...@trustcc.com javascript: wrote:

 I'm trying to use 
 jQuery-File-Uploadhttp://blueimp.github.io/jQuery-File-Upload/to implement 
 multiple file uploads.  I'm using this 
 tutorialhttp://in10min.blogspot.com/2013/04/web2py-implement-multiple-files-upload.html
  as 
 well as this sample app 
 HEREhttps://bitbucket.org/xavrenard/multiupload_module/src. 
  

 Is there something in the standard web2py build that would be preventing 
 the proper javascript or CSS from running?  The sample app should work 
 right out of the box; however, no buttons are displayed. 

 Has anyone successfully implemented this on web2py before?





  -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to web2py+un...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Calvin Morrison
:-) I was having a hell of a time trying to get all the AJAX examples to
work and well, none of it f***ing would. Yesterday I brewed an extra strong
pot of coffee and cranked this out.

Some of the code i would like review on, I am not sure how to properly
check for if there was an uploaded file or not, i have that weird is in
then len()  0 but i don't think it's the best.

Whoever is a maintainer/developer of web2py - could we integrate this
somehow?

Calvin


On 8 January 2014 10:40, Brando bhe...@trustcc.com wrote:

 Calvin, you are awesome.  I will try this on my end and report back.





 On Wednesday, January 8, 2014 7:18:28 AM UTC-8, Calvin Morrison wrote:

 I  just wrote my own way to do it yesterday which worked great. I would
 love it to go upstream.

 It's just a standard file upload with the multiple attribute.

 here's the entire thing: it spits out a form.

 my db looks like this:

 db.define_table('uploads',
 Field('username', 'string'),
 Field('filename', represent = lambda x, row: None if x == None else
 x[:45]),
 Field('up_file', 'upload', uploadseparate=True,
 requires=IS_NOT_EMPTY()),
 Field('up_date', 'datetime'),
 Field('up_size', 'integer', represent= lambda x, row:
 quikr_utils.sizeof_fmt(x) ),
 Field('notes', 'text'))


 my contorller

 def submit():
   import datetime

   form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file',
 _multiple=''), BR(), LABEL(Notes:), TEXTAREA(_name='notes'),
 BR(),INPUT(_type='submit'))

   if form.accepts(request.vars, formname=form):

 if hasattr(request.vars, 'up_files'):
   if len(request.vars.up_files)  0:

 files = request.vars['up_files']
 if not isinstance(files, list):
   files = [files]

 for f in files:
   print f.filename
   up_file = db.uploads.up_file.store(f, f.filename)
   i = db.uploads.insert(notes=request.vars.notes,
 up_file=up_file,filename=f.filename, username = auth.user.email,
 up_date= datetime.datetime.now())
   db.commit()

 redirect(URL('data', 'index'))
   else:
 form.errors.up_files = No files selected

   return dict(form=form)


 On 8 January 2014 10:14, Brando bhe...@trustcc.com wrote:

 I'm trying to use 
 jQuery-File-Uploadhttp://blueimp.github.io/jQuery-File-Upload/to 
 implement multiple file uploads.  I'm using this
 tutorialhttp://in10min.blogspot.com/2013/04/web2py-implement-multiple-files-upload.html
  as
 well as this sample app 
 HEREhttps://bitbucket.org/xavrenard/multiupload_module/src.


 Is there something in the standard web2py build that would be preventing
 the proper javascript or CSS from running?  The sample app should work
 right out of the box; however, no buttons are displayed.

 Has anyone successfully implemented this on web2py before?





  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google
 Groups web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to web2py+un...@googlegroups.com.

 For more options, visit https://groups.google.com/groups/opt_out.


  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Brando
Also, should it be possible to adapt this so that I could use 
SQLFORM.factory instead of FORM?  I notice this uploads the files to the 
db.  What would need to change so that I'm just pulling it to the local 
disk?







On Wednesday, January 8, 2014 7:18:28 AM UTC-8, Calvin Morrison wrote:

 I  just wrote my own way to do it yesterday which worked great. I would 
 love it to go upstream.

 It's just a standard file upload with the multiple attribute.

 here's the entire thing: it spits out a form.

 my db looks like this:

 db.define_table('uploads',
 Field('username', 'string'),
 Field('filename', represent = lambda x, row: None if x == None else 
 x[:45]),
 Field('up_file', 'upload', uploadseparate=True, 
 requires=IS_NOT_EMPTY()),
 Field('up_date', 'datetime'), 
 Field('up_size', 'integer', represent= lambda x, row: 
 quikr_utils.sizeof_fmt(x) ), 
 Field('notes', 'text'))


 my contorller

 def submit():
   import datetime

   form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file', 
 _multiple=''), BR(), LABEL(Notes:), TEXTAREA(_name='notes'), 
 BR(),INPUT(_type='submit'))

   if form.accepts(request.vars, formname=form):

 if hasattr(request.vars, 'up_files'):
   if len(request.vars.up_files)  0:

 files = request.vars['up_files']
 if not isinstance(files, list):
   files = [files]

 for f in files:
   print f.filename
   up_file = db.uploads.up_file.store(f, f.filename)
   i = db.uploads.insert(notes=request.vars.notes, 
 up_file=up_file,filename=f.filename, username = auth.user.email, up_date= 
 datetime.datetime.now())
   db.commit()

 redirect(URL('data', 'index'))
   else:
 form.errors.up_files = No files selected

   return dict(form=form)


 On 8 January 2014 10:14, Brando bhe...@trustcc.com javascript: wrote:

 I'm trying to use 
 jQuery-File-Uploadhttp://blueimp.github.io/jQuery-File-Upload/to implement 
 multiple file uploads.  I'm using this 
 tutorialhttp://in10min.blogspot.com/2013/04/web2py-implement-multiple-files-upload.html
  as 
 well as this sample app 
 HEREhttps://bitbucket.org/xavrenard/multiupload_module/src. 
  

 Is there something in the standard web2py build that would be preventing 
 the proper javascript or CSS from running?  The sample app should work 
 right out of the box; however, no buttons are displayed. 

 Has anyone successfully implemented this on web2py before?





  -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to web2py+un...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Calvin Morrison
instead of inserting it, you could write the file stream out to whereever
you want.

It's really just a python cgi module object. so you can use all
corresponding documentation to help

look at this SO answer

https://stackoverflow.com/questions/15947988/in-my-python-cgi-script-how-do-i-save-to-disk-a-file-uploaded-via-post-request


On 8 January 2014 10:44, Brando bhe...@trustcc.com wrote:

 Also, should it be possible to adapt this so that I could use
 SQLFORM.factory instead of FORM?  I notice this uploads the files to the
 db.  What would need to change so that I'm just pulling it to the local
 disk?







 On Wednesday, January 8, 2014 7:18:28 AM UTC-8, Calvin Morrison wrote:

 I  just wrote my own way to do it yesterday which worked great. I would
 love it to go upstream.

 It's just a standard file upload with the multiple attribute.

 here's the entire thing: it spits out a form.

 my db looks like this:

 db.define_table('uploads',
 Field('username', 'string'),
 Field('filename', represent = lambda x, row: None if x == None else
 x[:45]),
 Field('up_file', 'upload', uploadseparate=True,
 requires=IS_NOT_EMPTY()),
 Field('up_date', 'datetime'),
 Field('up_size', 'integer', represent= lambda x, row:
 quikr_utils.sizeof_fmt(x) ),
 Field('notes', 'text'))


 my contorller

 def submit():
   import datetime

   form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file',
 _multiple=''), BR(), LABEL(Notes:), TEXTAREA(_name='notes'),
 BR(),INPUT(_type='submit'))

   if form.accepts(request.vars, formname=form):

 if hasattr(request.vars, 'up_files'):
   if len(request.vars.up_files)  0:

 files = request.vars['up_files']
 if not isinstance(files, list):
   files = [files]

 for f in files:
   print f.filename
   up_file = db.uploads.up_file.store(f, f.filename)
   i = db.uploads.insert(notes=request.vars.notes,
 up_file=up_file,filename=f.filename, username = auth.user.email,
 up_date= datetime.datetime.now())
   db.commit()

 redirect(URL('data', 'index'))
   else:
 form.errors.up_files = No files selected

   return dict(form=form)


 On 8 January 2014 10:14, Brando bhe...@trustcc.com wrote:

 I'm trying to use 
 jQuery-File-Uploadhttp://blueimp.github.io/jQuery-File-Upload/to 
 implement multiple file uploads.  I'm using this
 tutorialhttp://in10min.blogspot.com/2013/04/web2py-implement-multiple-files-upload.html
  as
 well as this sample app 
 HEREhttps://bitbucket.org/xavrenard/multiupload_module/src.


 Is there something in the standard web2py build that would be preventing
 the proper javascript or CSS from running?  The sample app should work
 right out of the box; however, no buttons are displayed.

 Has anyone successfully implemented this on web2py before?





  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google
 Groups web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to web2py+un...@googlegroups.com.

 For more options, visit https://groups.google.com/groups/opt_out.


  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: Why web2py and AnguljarJS?

2014-01-08 Thread Richard Vézina
It could be one criteria with many others...

Richard


On Wed, Jan 8, 2014 at 10:34 AM, Ruud Schroen r...@formatics.nl wrote:

 So.. angularjs should be used when i want to create a website with lots of
 javascript/AJAX?


 On Sunday, January 5, 2014 11:06:43 PM UTC+1, Ruud Schroen wrote:

 I see more and more about using angularjs with web2py.

 But why? What would be an example of a benefit from using those two.
 Cause when i look at AngularJS, it already looks alot like web2py.

 Not saying that it's a bad idea, just wondering ;)

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Brando
Calvin, i stripped out a variable or two, but it appears to work great. 
 I'm getting a crazy twitch trying to figure out a javascript/ajax solution 
for this.  I second the idea of building this into Web2py, I would be more 
than happy to contribute, but I'm just starting out with web2py and I would 
probably make something burst into flames.  

Thanks for your help, I'll be sure to post my end code I use.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: GAE: defaults on _tableobj

2014-01-08 Thread Quint
Well, put_multi 'm not sure about, maybe the difference in this case is 
insignificant (didn't research it.)
But get_by_key_name() is less expensive than a fetch for a single record.


On Wednesday, January 8, 2014 3:53:05 PM UTC+1, Alan Etkin wrote:

  (For instance when I want to supply a key_name when I put() an entity 
 so I can have better performance to get() that entity from db.
  Or when I want to use put_multi())

 put_multi is supported by DAL trough the bulk_insert method. How better is 
 performance when using named keys? Do you have benchmarks?. Also, is the 
 use of named keys supported by DAL? I think it is not: 

 https://groups.google.com/d/msg/web2py/lFKiIGary0c/_sx0EoJkYk0J



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] web2py administrative interface issue

2014-01-08 Thread Richard Vézina
Did you upgrade web2py?

Do you try to restart web2py instance?

Did you upgrade your system?

Did you add code to your app that could have a bad consequence?
Particularly name of controller, models, modules, etc. and folder...

It very hard to say... Could you show the traceback if you have one?

Richard


On Tue, Jan 7, 2014 at 7:49 PM, sonu kumar sonu.bioinformat...@gmail.comwrote:

 Hi,

 Today I was trying to access my application via web2py administrative
 interface but one of my application was not opening on 'edit' click in
 'manage' button. It waits and throws a internal server error.
 Till yesterday it was working fine...
 Whereas other application like 'example' is opening after 'edit' click.

 Why it is happening?

 Thanks

 --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Scheduler repeat time drift

2014-01-08 Thread Brian M
Is there any way to keep the time at which recurring tasks run from 
drifting? I've got several daily tasks that over time go from running at 
say 10am to 10:30am - it seems like each consecutive run is 20 seconds or 
so behind the previous day's. Is this simply a matter of the next execution 
time being set based on the ending time of the current run rather than the 
starting time?  If I want to better enforce running at a certain time daily 
do I need to resort to having a maintenance task run say once a week and 
reset the next run time of the daily tasks so they don't drift too far? I 
suppose that this isn't too much of an issue for tasks that run on a more 
regular basis like once a minute to process constantly updated queues, but 
for things that you want to run at a certain set time it's a bit annoying.

Thanks
Brian

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: GAE: defaults on _tableobj

2014-01-08 Thread Quint


 Also, is the use of named keys supported by DAL? I think it is not


As long as it's not we will need to use GAE api directly then.. 


On Wednesday, January 8, 2014 3:53:05 PM UTC+1, Alan Etkin wrote:

  (For instance when I want to supply a key_name when I put() an entity 
 so I can have better performance to get() that entity from db.
  Or when I want to use put_multi())

 put_multi is supported by DAL trough the bulk_insert method. How better is 
 performance when using named keys? Do you have benchmarks?. Also, is the 
 use of named keys supported by DAL? I think it is not: 

 https://groups.google.com/d/msg/web2py/lFKiIGary0c/_sx0EoJkYk0J



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: GAE: insert using key_name

2014-01-08 Thread Quint
Sorry, I don't understand this line.

 although I belive storing records without id assignment would be 
 restrictive for apps


Do you mean web2py apps or GAE apps? What did you mean by restrictive

(and I doubt it will be actually compatible at all


Compatible with what?

Sure, when you would insert using a key_name, and without an numeric id, 
the will be web2py API functionalities that wont work anymore. (the ones 
that expect a numeric id returned)
But you would know that you don't need those functionalities if you would 
decide to use a key_name.


On Wednesday, January 8, 2014 3:52:18 PM UTC+1, Alan Etkin wrote:

  But does that mean you should not allow it to be inserted that way?
  Nothing restricts users from operating (using web2py api) on rows 
 inserted with GAE api

 There's no restriction on the use of the datastore, since it is not a 
 service reserved for web2py apps, although I belive storing records without 
 id assignment would be restrictive for apps (and I doubt it will be 
 actually compatible at all, with the exception of the keyed tables 
 mentioned before, in case it is supported).



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: Why web2py and AnguljarJS?

2014-01-08 Thread António Ramos
I never liked javascript but Angular changed my mind.!!

With Angular we code a lot less and only for good reasons.

2014/1/8 Ruud Schroen r...@formatics.nl

 So.. angularjs should be used when i want to create a website with lots of
 javascript/AJAX?


 On Sunday, January 5, 2014 11:06:43 PM UTC+1, Ruud Schroen wrote:

 I see more and more about using angularjs with web2py.

 But why? What would be an example of a benefit from using those two.
 Cause when i look at AngularJS, it already looks alot like web2py.

 Not saying that it's a bad idea, just wondering ;)

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: GAE: defaults on _tableobj

2014-01-08 Thread Quint


As long as it's not we will need to use GAE api directly then.. 

To put() the entity that is.
I would still prefer to use web2py to retreive it.

On Wednesday, January 8, 2014 5:14:14 PM UTC+1, Quint wrote:

 Also, is the use of named keys supported by DAL? I think it is not


 As long as it's not we will need to use GAE api directly then.. 


 On Wednesday, January 8, 2014 3:53:05 PM UTC+1, Alan Etkin wrote:

  (For instance when I want to supply a key_name when I put() an entity 
 so I can have better performance to get() that entity from db.
  Or when I want to use put_multi())

 put_multi is supported by DAL trough the bulk_insert method. How better 
 is performance when using named keys? Do you have benchmarks?. Also, is the 
 use of named keys supported by DAL? I think it is not: 

 https://groups.google.com/d/msg/web2py/lFKiIGary0c/_sx0EoJkYk0J



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: GAE: defaults on _tableobj

2014-01-08 Thread Quint


 I would still prefer to use web2py to retreive it.


by using it's  _tableobj I meant.. and then use GAE api

On Wednesday, January 8, 2014 5:34:05 PM UTC+1, Quint wrote:

 As long as it's not we will need to use GAE api directly then.. 

 To put() the entity that is.
 I would still prefer to use web2py to retreive it.

 On Wednesday, January 8, 2014 5:14:14 PM UTC+1, Quint wrote:

 Also, is the use of named keys supported by DAL? I think it is not


 As long as it's not we will need to use GAE api directly then.. 


 On Wednesday, January 8, 2014 3:53:05 PM UTC+1, Alan Etkin wrote:

  (For instance when I want to supply a key_name when I put() an 
 entity so I can have better performance to get() that entity from db.
  Or when I want to use put_multi())

 put_multi is supported by DAL trough the bulk_insert method. How better 
 is performance when using named keys? Do you have benchmarks?. Also, is the 
 use of named keys supported by DAL? I think it is not: 

 https://groups.google.com/d/msg/web2py/lFKiIGary0c/_sx0EoJkYk0J



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: [web2py-dev] Rows.compact and other Rows methods

2014-01-08 Thread Massimo DiPierro
The problem is speed. I believe the getitem should be as fast as possible. This 
was changed before so that the trasformation of the rows occurred only once and 
not every time a row column is accessed.

On Jan 8, 2014, at 8:41 AM, Anthony wrote:

 Let's discuss on the developers list.
 
 On Tuesday, January 7, 2014 9:52:16 PM UTC-5, Joe Barnhart wrote:
 Maybe the best answer is to change Row so that it always holds the full set 
 of keys (table:field) and change the __getitem__ method to look up the key 
 recursively if only one part is provided.  Here is a sample method which 
 implements this strategy of testing keys for dicts within dicts.  Our case is 
 a little simpler since we never recurse more than one level deep.
 
 def _finditem(obj, key):
 if key in obj: return obj[key]
 for k, v in obj.items():
 if isinstance(v,dict):
 item = _finditem(v, key)
 if item is not None:
 return item
 
 This has the advantage of working with existing code and preserving as much 
 information as possible in the Row object.  I have a feeling this could make 
 the internals of web2py a good deal more consistent.  Less testing for 
 special cases is always good!
 
 -- Joe B.
 
 On Tuesday, January 7, 2014 3:48:39 PM UTC-8, Anthony wrote:
 Note, same problem with .sort (it modifies the Row objects in self.records), 
 so we should probably fix that as well (will be a bit more complicated).
 
 Anthony
 
 On Tuesday, January 7, 2014 11:03:56 AM UTC-5, Anthony wrote:
 The Rows.find() method does the following:
 
 for row in self:
 if f(row):
 if a=k: records.append(row)
 k += 1
 if k==b: break
 
 In a Rows object, there is self.records, which is a list of Row objects. Each 
 Row object has at least one top-level key with the table name, and the record 
 is stored in the value associated with that key:
 
 Row {'person': {'first_name': 'Bob', 'last_name': 'Smith'}}
 
 When .find() is called on a Rows object with compact=True, the __iter__ 
 method (called by the for row in self loop) returns a transformed version 
 of each Row object, removing the top-level table key:
 
 Row {'first_name': 'Bob', 'last_name': 'Smith'}
 
 I believe this is an unnecessary transformation, and it is what is 
 subsequently causing the .render() method to fail (the .render() method 
 expects the top-level table key to be there, whether or not compact=True). I 
 propose the following change to .find():
 
 for i, row in enumerate(self):
 if f(row):
 if a=k: records.append(self.records[i])
 k += 1
 if k==b: break
 
 The above code appends self.records[i] instead of row, which preserves the 
 original Row objects instead of including transformed objects. Anyone see any 
 problems with that change?
 
 Also, is there any reason all of the Rows methods (i.e., find, exclude, 
 __and__, __or__) should not be preserving the compact attribute of the 
 original Rows object? Perhaps we should change them all to do so. (Note, this 
 is a separate issue unrelated to the above problem with .find() and 
 .render().)
 
 Anthony
 
 On Tuesday, January 7, 2014 10:47:28 AM UTC-5, Anthony wrote:
 .render() works fine on Rows objects with compact=True, and it also works 
 fine on the results of .sort(), .exclude(), , and | operations. The only 
 problem is with the results of .find() operations when the original Rows 
 object has compact=True. The problem is that the .find() method modifies the 
 Row objects in self.records when compact=True, which it probably should not 
 due.
 
 Aside from this issue, perhaps the various Rows methods should preserve the 
 compact attribute -- not sure why they don't.
 
 Forwarding to the developers list for discussion.
 
 Anthony
 
 On Tuesday, January 7, 2014 3:10:00 AM UTC-5, Joe Barnhart wrote:
 I've been experimenting with the render method of the Rows class, and I am 
 very impressed.  But one drawback I found is that the Rows object must have 
 its value set to compact=False to work properly with render().  It isn't a 
 problem if the Rows object is used directly without any operators, but I 
 discovered that many, if not most, Rows methods do not preserve the compact 
 setting.
 
 For example. if you sort the Rows, it leaves compact=True.  Ditto, if you 
 use extract or find on the Rows object.  The  and | operators also 
 set the compact variable to True.  The upshot is that you can't use any of 
 these operators on the Rows object and then use render on the resulting 
 object.
 
 It is a simple change to add the preservation of the compact flag during 
 any of these steps, but I'm unsure if this will break existing code.  Other 
 than coming up with a completely parallel set of methods, which leave compact 
 set the way it came in, I can't think of another approach will be provably 
 backwards-compatible.
 
 Here is an example:
 
 
 

[web2py] Re: [web2py-dev] Rows.compact and other Rows methods

2014-01-08 Thread Massimo DiPierro
This would be slow and confusing. What if there is a table in the join called 
first_name? What if both tables in a join have a column first_name?

On Jan 8, 2014, at 9:12 AM, Anthony wrote:

 This is an interesting idea. Instead of bothering with the compact 
 attribute, we could make it so any Row object automatically works like a 
 compact Row whenever it includes only one top-level key. So, if you have:
 
 Row {'person': {'first_name': 'Bob', 'last_name': 'Smith'}}
 
 you could do either row.person.first_name or row.first_name, regardless of 
 the value of the compact attribute. The problem, though, is what happens if 
 there is a field name that is the same as the table name. In that case, we 
 would have to make the default to return either the full sub-record 
 associated with the table, or just the field within the table, but neither 
 approach would be fully backward compatible.
 
 I suppose we could keep using the compact attribute, and simply pass it to 
 the Row object, so the Row object itself knows whether it is compact or not. 
 This would also be necessary for the Row.as_dict and related methods to 
 remain backward compatible. But then the Row object needs to be able to hold 
 a private attribute (e.g., __compact).
 
 Thoughts on this?
 
 Anthony
 
 On Wednesday, January 8, 2014 9:41:19 AM UTC-5, Anthony wrote:
 Let's discuss on the developers list.
 
 On Tuesday, January 7, 2014 9:52:16 PM UTC-5, Joe Barnhart wrote:
 Maybe the best answer is to change Row so that it always holds the full set 
 of keys (table:field) and change the __getitem__ method to look up the key 
 recursively if only one part is provided.  Here is a sample method which 
 implements this strategy of testing keys for dicts within dicts.  Our case is 
 a little simpler since we never recurse more than one level deep.
 
 def _finditem(obj, key):
 if key in obj: return obj[key]
 for k, v in obj.items():
 if isinstance(v,dict):
 item = _finditem(v, key)
 if item is not None:
 return item
 
 This has the advantage of working with existing code and preserving as much 
 information as possible in the Row object.  I have a feeling this could make 
 the internals of web2py a good deal more consistent.  Less testing for 
 special cases is always good!
 
 -- Joe B.
 
 On Tuesday, January 7, 2014 3:48:39 PM UTC-8, Anthony wrote:
 Note, same problem with .sort (it modifies the Row objects in self.records), 
 so we should probably fix that as well (will be a bit more complicated).
 
 Anthony
 
 On Tuesday, January 7, 2014 11:03:56 AM UTC-5, Anthony wrote:
 The Rows.find() method does the following:
 
 for row in self:
 if f(row):
 if a=k: records.append(row)
 k += 1
 if k==b: break
 
 In a Rows object, there is self.records, which is a list of Row objects. Each 
 Row object has at least one top-level key with the table name, and the record 
 is stored in the value associated with that key:
 
 Row {'person': {'first_name': 'Bob', 'last_name': 'Smith'}}
 
 When .find() is called on a Rows object with compact=True, the __iter__ 
 method (called by the for row in self loop) returns a transformed version 
 of each Row object, removing the top-level table key:
 
 Row {'first_name': 'Bob', 'last_name': 'Smith'}
 
 I believe this is an unnecessary transformation, and it is what is 
 subsequently causing the .render() method to fail (the .render() method 
 expects the top-level table key to be there, whether or not compact=True). I 
 propose the following change to .find():
 
 for i, row in enumerate(self):
 if f(row):
 if a=k: records.append(self.records[i])
 k += 1
 if k==b: break
 
 The above code appends self.records[i] instead of row, which preserves the 
 original Row objects instead of including transformed objects. Anyone see any 
 problems with that change?
 
 Also, is there any reason all of the Rows methods (i.e., find, exclude, 
 __and__, __or__) should not be preserving the compact attribute of the 
 original Rows object? Perhaps we should change them all to do so. (Note, this 
 is a separate issue unrelated to the above problem with .find() and 
 .render().)
 
 Anthony
 
 On Tuesday, January 7, 2014 10:47:28 AM UTC-5, Anthony wrote:
 .render() works fine on Rows objects with compact=True, and it also works 
 fine on the results of .sort(), .exclude(), , and | operations. The only 
 problem is with the results of .find() operations when the original Rows 
 object has compact=True. The problem is that the .find() method modifies the 
 Row objects in self.records when compact=True, which it probably should not 
 due.
 
 Aside from this issue, perhaps the various Rows methods should preserve the 
 compact attribute -- not sure why they don't.
 
 Forwarding to the developers list for discussion.
 
 Anthony
 
 On Tuesday, January 7, 2014 

[web2py] Re: GAE: insert using key_name

2014-01-08 Thread Alan Etkin


 Compatible with what?


With any web2py feature expecting entity keys (web2py records) with integer 
ids.

But you would know that you don't need those functionalities if you would 
 decide to use a key_name


I think this is usually called a corner case. I would't add the feature 
for the purpose for storing entities by name since it does not require much 
coding to implement it per-application using the gae api.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Validating list:string fields

2014-01-08 Thread curly
Hello,

I'm trying to validate a list:string field with is_alphanumeric and 
is_length - trying to ensure that names are no longer than 6 alphanumeric 
characters in length. (I'm running web2py 2.8.1 in ubuntu 12.04)

view:
liSample name *: {{=form.custom.widget.sample_name}}/li

controller:
form = SQLFORM(db.register,fields=[..,'sample_name',...])

if form.validate(onvalidation=validate_sample_name):
form.vars.id = db.register.insert(**dict(form.vars))
response.flash = 'Reg saved.'
redirect(URL('samples', 'default', 'index'))
elif form.errors:
response.flash = 'form has errors'  
return dict(form=form)

model:
db.define_table(
register,
.
Field('sample_name','list:string'),
)

def validate_sample_name(form):
for sample in form.vars.sample_name:
out,ers = IS_ALPHANUMERIC()(sample) and 
IS_LENGTH(maxsize=6)('sample')
if ers:
form.errors.sample_name = ers


The above does check for alphanumeric characters but doesn't seem to check 
for the length of each sample name.

Am I doing something wrong?

Many thanks.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: Why web2py and AnguljarJS?

2014-01-08 Thread Richard Vézina
But you need other techno, as far as I understand it, you need something to
talk with the db (web2py for instance)... To me the learning curve seems
much longer than with web2py... web2py manage a lot of complexity of web
development for you, it one of its strength.

:)

Richard


On Wed, Jan 8, 2014 at 11:25 AM, António Ramos ramstei...@gmail.com wrote:

 I never liked javascript but Angular changed my mind.!!

 With Angular we code a lot less and only for good reasons.

 2014/1/8 Ruud Schroen r...@formatics.nl

 So.. angularjs should be used when i want to create a website with lots
 of javascript/AJAX?


 On Sunday, January 5, 2014 11:06:43 PM UTC+1, Ruud Schroen wrote:

 I see more and more about using angularjs with web2py.

 But why? What would be an example of a benefit from using those two.
 Cause when i look at AngularJS, it already looks alot like web2py.

 Not saying that it's a bad idea, just wondering ;)

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: pyfilesystem support (store uploads in S3)

2014-01-08 Thread Diogo Munaro
Hey guys! I know this topic is old, but here it's *working great* with 
mysql or sqlite on web2py 2.7.4.

Just install:

pip install fs

Then on model:

import fs.s3fs
myfs = fs.s3fs.S3FS(bucket, prefix, aws_access_key, aws_secret_key)
db.define_table('image',Field('image','upload',uploadfs = myfs))

I'm using ubuntu 12.04 amd64 with python 2.7.3 virtualenv.

Thx for your help!

Em sábado, 2 de junho de 2012 19h19min57s UTC-3, c h escreveu:

 i bet we could do something similar using the boto library on GAE.

 On Thursday, May 31, 2012 10:56:47 AM UTC-7, Massimo Di Pierro wrote:

 Here is an example:

 easy_install pyfilesystem

  import fs.s3fs
  myfs = fs.s3fs.S3FS(bucket, prefix, aws_access_ke, aws_secret_key)
  db.define_table('test',Field('file','upload',uploadfs = myfs))

 Now all your uploaded files will go on S3.
 Here is a list of supported filesystems: 
 http://packages.python.org/fs/filesystems.html

 WARNINGS: 
 - needs testing. I have tested with OSFS and I am confident it works
 - I do not think with will work on GAE, should be tested
 - uploadfolder and uploadseparate are ignored when uploadfs is specified 
 (this should be changed, any takers?)

 Should be possible to wrap myfs into an encryption layer but I have not 
 done it yet.

 We may want a more comprehensive strategy and allow every web2py file 
 (including apps, sessions, tickets, etc) to go into a pyfilesystem. Is this 
 necessary? On linux one can mount filesystems in a folder anyway. Is this 
 more trouble than it is worth?

 Massimo







-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: Why web2py and AnguljarJS?

2014-01-08 Thread António Ramos
for me was the other way.
I learned angular (still learning) faster than web2py
about talking to db angular excels with ng-resource.
Very easy , it creates an object to use as REST resource


http://coder1.com/articles/consuming-rest-services-angularjs





2014/1/8 Richard Vézina ml.richard.vez...@gmail.com

 But you need other techno, as far as I understand it, you need something
 to talk with the db (web2py for instance)... To me the learning curve seems
 much longer than with web2py... web2py manage a lot of complexity of web
 development for you, it one of its strength.

 :)

 Richard


 On Wed, Jan 8, 2014 at 11:25 AM, António Ramos ramstei...@gmail.comwrote:

 I never liked javascript but Angular changed my mind.!!

 With Angular we code a lot less and only for good reasons.

 2014/1/8 Ruud Schroen r...@formatics.nl

 So.. angularjs should be used when i want to create a website with lots
 of javascript/AJAX?


 On Sunday, January 5, 2014 11:06:43 PM UTC+1, Ruud Schroen wrote:

 I see more and more about using angularjs with web2py.

 But why? What would be an example of a benefit from using those two.
 Cause when i look at AngularJS, it already looks alot like web2py.

 Not saying that it's a bad idea, just wondering ;)

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google
 Groups web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Nested References in Smart Grid

2014-01-08 Thread Massimo Di Pierro
You can do it:
db.tblvehicles.Model.represent = Lambda value,row: value.MakeID.Make

but unless you denormalize this is slow (two nested select per row).


On Tuesday, 7 January 2014 22:02:18 UTC-6, MVolpes wrote:

 Hi 

 I have been using this framework for the last few days and I am in awe a 
 fantastic framework. I have come from a strong .net and php framework back 
 ground and wanted to learn python this has already taught me so much!!

 I have a question that hopefully can be answered easily and maybe I am 
 overlooking something.

 I have the smart grid working well however i want to display a reference 
 of a reference eg

 Vehicle  Model  Make



 Please bare in mind i am using a legacy db

 Model
 #
 db.define_table('tblmake',
 Field('MakeID','id'),
 Field('Make','string'),
 format=%(Make)s,
 migrate=False)


 #
 db.define_table('tblmodels',
 Field('Model','string'),
 Field('ModelID','id'),
 Field('MakeID','reference tblmake'),
 format=%(Model)s,
 migrate=False)


 #
 db.define_table('tblvehicles',
 Field('VehicleID','id'),
 Field('Registration','string'),
 Field('Driver','string'),
 Field('Model','reference tblmodels'),
 migrate=False)

 Controller

 vehiclefields = [db.tblvehicles.Registration, db.tblvehicles.Driver, 
 db.tblvehicles.Model]

 vehiclelinks = [lambda row: A('View 
 Post',_href=URL(search,test,args=[row.VehicleID]))]
 vehicles = SQLFORM.smartgrid(db.tblvehicles, orderby=VehicleID Desc, 
 fields=vehiclefields, formname=vehiclegrid,
  details=False, editable=False, 
 deletable=False,links=vehiclelinks, linked_tables=False)

 I would like to display the db.tblmake.Make field 

 How can I do this?
 Can I do this?

 I have tried adding various combinations but with no luck

 Any help would be greatly appreciated



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Validating list:string fields

2014-01-08 Thread Massimo Di Pierro
You simply need in the model or in the action before SQLFORM

db. register.sample_name.requires=(IS_ALPHANUMERIC(),IS_LENGTH(maxsize=6))



On Wednesday, 8 January 2014 07:44:15 UTC-6, curly wrote:

 Hello,

 I'm trying to validate a list:string field with is_alphanumeric and 
 is_length - trying to ensure that names are no longer than 6 alphanumeric 
 characters in length. (I'm running web2py 2.8.1 in ubuntu 12.04)

 view:
 liSample name *: {{=form.custom.widget.sample_name}}/li

 controller:
 form = SQLFORM(db.register,fields=[..,'sample_name',...])

 if form.validate(onvalidation=validate_sample_name):
 form.vars.id = db.register.insert(**dict(form.vars))
 response.flash = 'Reg saved.'
 redirect(URL('samples', 'default', 'index'))
 elif form.errors:
 response.flash = 'form has errors'  
 return dict(form=form)
 
 model:
 db.define_table(
 register,
 .
 Field('sample_name','list:string'),
 )

 def validate_sample_name(form):
 for sample in form.vars.sample_name:
 out,ers = IS_ALPHANUMERIC()(sample) and 
 IS_LENGTH(maxsize=6)('sample')
 if ers:
 form.errors.sample_name = ers


 The above does check for alphanumeric characters but doesn't seem to check 
 for the length of each sample name.

 Am I doing something wrong?

 Many thanks.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: cpdb from sqlite to postgresql

2014-01-08 Thread Dave S
Martin  has sent the following:

On Tue, Jan 7, 2014 at 1:07 PM, Martin Weissenboeck mweis...@gmail.comwrote:

 Ok, I have found a solution.

 (1) I have to copy the whole directory /gluon to /scripts
 (2) Parameter -d of cpdb has to be an absolute path, e.g. -d 
 /home/www-data/web2py/gluon

 But I do not think that this is the best solution - maybe I habe to spend 
 some hours again.

 At the moment I do not understand why this works. 
 What I have found:
 - In dal.py the function find_driver expects 'pg8000' in globals() - but 
 it is not there.
 - Maybe there is a problem in def _getDal in file  cpdb.py ?

  
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: [web2py-dev] Rows.compact and other Rows methods

2014-01-08 Thread Anthony
OK, good point. In that case, I'll just send a patch for .find and .sort so 
they return the original self.records items so .render will work properly.

Anthony

On Wednesday, January 8, 2014 11:47:24 AM UTC-5, Massimo Di Pierro wrote:

 The problem is speed. I believe the getitem should be as fast as possible. 
 This was changed before so that the trasformation of the rows occurred only 
 once and not every time a row column is accessed.

 On Jan 8, 2014, at 8:41 AM, Anthony wrote:

 Let's discuss on the developers 
 listhttps://groups.google.com/forum/?fromgroups=#!topic/web2py-developers/k2D6MVfBEYo
 .

 On Tuesday, January 7, 2014 9:52:16 PM UTC-5, Joe Barnhart wrote:

 Maybe the best answer is to change Row so that it always holds the full 
 set of keys (table:field) and change the __getitem__ method to look up the 
 key recursively if only one part is provided.  Here is a sample method 
 which implements this strategy of testing keys for dicts within dicts.  Our 
 case is a little simpler since we never recurse more than one level deep.

 def _finditem(obj, key):
 if key in obj: return obj[key]
 for k, v in obj.items():
 if isinstance(v,dict):
 item = _finditem(v, key)
 if item is not None:
 return item


 This has the advantage of working with existing code and preserving as 
 much information as possible in the Row object.  I have a feeling this 
 could make the internals of web2py a good deal more consistent.  Less 
 testing for special cases is always good!

 -- Joe B.

 On Tuesday, January 7, 2014 3:48:39 PM UTC-8, Anthony wrote:

 Note, same problem with .sort (it modifies the Row objects in 
 self.records), so we should probably fix that as well (will be a bit more 
 complicated).

 Anthony

 On Tuesday, January 7, 2014 11:03:56 AM UTC-5, Anthony wrote:

 The Rows.find() method does the following:

 for row in self:
 if f(row):
 if a=k: records.append(row)
 k += 1
 if k==b: break

 In a Rows object, there is self.records, which is a list of Row 
 objects. Each Row object has at least one top-level key with the table 
 name, and the record is stored in the value associated with that key:

 Row {'person': {'first_name': 'Bob', 'last_name': 'Smith'}}

 When .find() is called on a Rows object with compact=True, the __iter__ 
 method (called by the for row in self loop) returns a transformed 
 version 
 of each Row object, removing the top-level table key:

 Row {'first_name': 'Bob', 'last_name': 'Smith'}

 I believe this is an unnecessary transformation, and it is what is 
 subsequently causing the .render() method to fail (the .render() method 
 expects the top-level table key to be there, whether or not compact=True). 
 I propose the following change to .find():

 for i, row in enumerate(self):
 if f(row):
 if a=k: records.append(self.records[i])
 k += 1
 if k==b: break

 The above code appends self.records[i] instead of row, which preserves 
 the original Row objects instead of including transformed objects. Anyone 
 see any problems with that change?

 Also, is there any reason all of the Rows methods (i.e., find, exclude, 
 __and__, __or__) should not be preserving the compact attribute of the 
 original Rows object? Perhaps we should change them all to do so. (Note, 
 this is a separate issue unrelated to the above problem with .find() and 
 .render().)

 Anthony

 On Tuesday, January 7, 2014 10:47:28 AM UTC-5, Anthony wrote:

 .render() works fine on Rows objects with compact=True, and it also 
 works fine on the results of .sort(), .exclude(), , and | operations. 
 The 
 only problem is with the results of .find() operations when the original 
 Rows object has compact=True. The problem is that the .find() method 
 modifies the Row objects in self.records when compact=True, which it 
 probably should not due.

 Aside from this issue, perhaps the various Rows methods should 
 preserve the compact attribute -- not sure why they don't.

 Forwarding to the developers list for discussion.

 Anthony

 On Tuesday, January 7, 2014 3:10:00 AM UTC-5, Joe Barnhart wrote:

 I've been experimenting with the render method of the Rows class, and 
 I am very impressed.  But one drawback I found is that the Rows object 
 must 
 have its value set to compact=False to work properly with render().  
 It 
 isn't a problem if the Rows object is used directly without any 
 operators, 
 but I discovered that many, if not most, Rows methods do not preserve 
 the 
 compact setting.

 For example. if you sort the Rows, it leaves compact=True.  Ditto, 
 if you use extract or find on the Rows object.  The  and | 
 operators also set the compact variable to True.  The upshot is that 
 you 
 can't use any of these operators on the Rows object and then use 
 render 
 on the resulting object.

 It is a simple change to add the 

[web2py] Re: [web2py-dev] Rows.compact and other Rows methods

2014-01-08 Thread Anthony
On Wednesday, January 8, 2014 11:48:30 AM UTC-5, Massimo Di Pierro wrote:

 This would be slow and confusing. What if there is a table in the join 
 called first_name? What if both tables in a join have a column first_name?


The idea was that the row.fieldname syntax would work only if there is a 
single top-level key (which would only be the case when querying a single 
table). In any case, since speed is a concern, we should probably stick 
with the current approach.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Validating list:string fields

2014-01-08 Thread Anthony
For a list:-type field, I think you can only use IS_IN_SET(..., 
multiple=True), IS_IN_DB(..., multiple=True), IS_NOT_EMPTY(), and 
IS_LIST_OF(), no?

IS_LIST_OF() takes only a single additional validator, so to apply multiple 
validators using it, you would probably have to create a custom validator 
that applies multiple validators.

Anthony

On Wednesday, January 8, 2014 1:04:36 PM UTC-5, Massimo Di Pierro wrote:

 You simply need in the model or in the action before SQLFORM

 db. register.sample_name.requires=(IS_ALPHANUMERIC(),IS_LENGTH(maxsize=6))



 On Wednesday, 8 January 2014 07:44:15 UTC-6, curly wrote:

 Hello,

 I'm trying to validate a list:string field with is_alphanumeric and 
 is_length - trying to ensure that names are no longer than 6 alphanumeric 
 characters in length. (I'm running web2py 2.8.1 in ubuntu 12.04)

 view:
 liSample name *: {{=form.custom.widget.sample_name}}/li

 controller:
 form = SQLFORM(db.register,fields=[..,'sample_name',...])

 if form.validate(onvalidation=validate_sample_name):
 form.vars.id = db.register.insert(**dict(form.vars))
 response.flash = 'Reg saved.'
 redirect(URL('samples', 'default', 'index'))
 elif form.errors:
 response.flash = 'form has errors'  
 return dict(form=form)
 
 model:
 db.define_table(
 register,
 .
 Field('sample_name','list:string'),
 )

 def validate_sample_name(form):
 for sample in form.vars.sample_name:
 out,ers = IS_ALPHANUMERIC()(sample) and 
 IS_LENGTH(maxsize=6)('sample')
 if ers:
 form.errors.sample_name = ers


 The above does check for alphanumeric characters but doesn't seem to 
 check for the length of each sample name.

 Am I doing something wrong?

 Many thanks.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Calvin Morrison
Yes I am getting that same problem here.

Like I said, I don't really know how to properly test if the variable has
been set.

Any input from more wise web2pyers would be great

Calvin


On 8 January 2014 14:03, Brando bhe...@trustcc.com wrote:

 Calvin, I'm getting this error when I select only 1 file to upload:



 Traceback (most recent call last):
  File /Volumes/BrandonsData/Google
 Drive/web2py/web2py.app/Contents/Resources/gluon/restricted.py, line 217,
 in restricted
  File /Volumes/BrandonsData/Google
 Drive/web2py/web2py.app/Contents/Resources/applications/calvinsmultiuploadfromgooggroup/controllers/default.pyhttp://127.0.0.1:8000/admin/default/edit/calvinsmultiuploadfromgooggroup/controllers/default.py
 , line 158, in module
  File /Volumes/BrandonsData/Google
 Drive/web2py/web2py.app/Contents/Resources/gluon/globals.py, line 372, in
 lambda
  File /Volumes/BrandonsData/Google
 Drive/web2py/web2py.app/Contents/Resources/applications/calvinsmultiuploadfromgooggroup/controllers/default.pyhttp://127.0.0.1:8000/admin/default/edit/calvinsmultiuploadfromgooggroup/controllers/default.py
 , line 116, in submit
  File cgi.pyc, line 591, in __len__
  File cgi.pyc, line 574, in keys
 TypeError: not indexable

 Which is coming from the highlighted line:
 def submit():
   import datetime

   form = FORM(LABEL(File(s):), INPUT(_name='up_files', 
 _type='file',_multiple
 =''), INPUT(_type='submit'))


   if form.accepts(request.vars, formname=form):

 if hasattr(request.vars, 'up_files'):
   if len(request.vars.up_files)  0:

 files = request.vars['up_files']
 if not isinstance(files, list):
   files = [files]

 for f in files:
   print f.filename
   up_file = db.uploads.up_file.store(f, f.filename)
   i = db.uploads.insert(notes=request.vars.notes, up_file=up_file,
 filename=f.filename, username = auth.user.email, up_date= datetime.
 datetime.now())
   db.commit()


 return form submitted #redirect(URL('data', 'index'))

   else:
 form.errors.up_files = No files selected

   return dict(form=form)





 Did you see that during your testing? Any thoughts on this?

 --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Brando
Calvin, I'm getting this error when I select only 1 file to upload:



Traceback (most recent call last):
 File /Volumes/BrandonsData/Google 
Drive/web2py/web2py.app/Contents/Resources/gluon/restricted.py, line 217, 
in restricted
 File /Volumes/BrandonsData/Google 
Drive/web2py/web2py.app/Contents/Resources/applications/calvinsmultiuploadfromgooggroup/controllers/default.pyhttp://127.0.0.1:8000/admin/default/edit/calvinsmultiuploadfromgooggroup/controllers/default.py
, line 158, in module
 File /Volumes/BrandonsData/Google 
Drive/web2py/web2py.app/Contents/Resources/gluon/globals.py, line 372, in 
lambda
 File /Volumes/BrandonsData/Google 
Drive/web2py/web2py.app/Contents/Resources/applications/calvinsmultiuploadfromgooggroup/controllers/default.pyhttp://127.0.0.1:8000/admin/default/edit/calvinsmultiuploadfromgooggroup/controllers/default.py
, line 116, in submit
 File cgi.pyc, line 591, in __len__
 File cgi.pyc, line 574, in keys
TypeError: not indexable

Which is coming from the highlighted line:
def submit():
  import datetime

  form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file',_multiple
=''), INPUT(_type='submit'))

  if form.accepts(request.vars, formname=form):

if hasattr(request.vars, 'up_files'):
  if len(request.vars.up_files)  0:

files = request.vars['up_files']
if not isinstance(files, list):
  files = [files]

for f in files:
  print f.filename
  up_file = db.uploads.up_file.store(f, f.filename)
  i = db.uploads.insert(notes=request.vars.notes, up_file=up_file,
filename=f.filename, username = auth.user.email, up_date= datetime.datetime.
now())
  db.commit()

return form submitted #redirect(URL('data', 'index'))
  else:
form.errors.up_files = No files selected

  return dict(form=form)





Did you see that during your testing? Any thoughts on this?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Brando
I removed that if loop completely and it works fine now:
def submit():
  import datetime

  form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file', 
_multiple=''),  BR(),INPUT(_type='submit'))
  
  # if hasattr(request.vars, 'up_files'):
  #   form.process()
  if form.accepts(request.vars, formname=form):

# if hasattr(request.vars, 'up_files'):
  # if len(request.vars.up_files)  0:
  # if request.vars.up_files:

files = request.vars['up_files']
if not isinstance(files, list):
  files = [files]
for f in files:
  print f.filename
  up_file = db.uploads.up_file.store(f, f.filename)
  i = db.uploads.insert(notes=request.vars.notes, up_file=up_file, 
filename=f.filename, up_date= datetime.datetime.now())
  db.commit()
return form submitted #redirect(URL('data', 'index'))
  # else:
  #   form.errors.up_files = No files selected

  return dict(form=form)


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] web2py administrative interface issue

2014-01-08 Thread Kumar Sonu
Hi Richard,
I didn't upgrade web2py.
Also not changed the name of controller, models, modules.
Although my application runs fine when I access via weblink but it is not
accessible via web2py administrative interface as I said.


On Wed, Jan 8, 2014 at 8:14 AM, Richard Vézina
ml.richard.vez...@gmail.comwrote:

 Did you upgrade web2py?

 Do you try to restart web2py instance?

 Did you upgrade your system?

 Did you add code to your app that could have a bad consequence?
 Particularly name of controller, models, modules, etc. and folder...

 It very hard to say... Could you show the traceback if you have one?

 Richard


 On Tue, Jan 7, 2014 at 7:49 PM, sonu kumar 
 sonu.bioinformat...@gmail.comwrote:

 Hi,

 Today I was trying to access my application via web2py administrative
 interface but one of my application was not opening on 'edit' click in
 'manage' button. It waits and throws a internal server error.
 Till yesterday it was working fine...
 Whereas other application like 'example' is opening after 'edit' click.

 Why it is happening?

 Thanks

 --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.

 For more options, visit https://groups.google.com/groups/opt_out.


  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/cn81jDxs-vY/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-
Sonu Kumar
Postdoctoral Associate
Infectious and Inflammatory Disease Center
Bioinformatics and System Biology
Sanford-Burnham Medical Research Institute
10901 North Torrey pines Rd
La Jolla, CA 92037

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Dave S
On Wednesday, January 8, 2014 11:07:03 AM UTC-8, Brando wrote:

 I removed that if loop completely and it works fine now:

 
The next obvious question:  did you test with no files?  To deal with those 
of us who click too fast?

/dps


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] web2py administrative interface issue

2014-01-08 Thread Dave S
On Wednesday, January 8, 2014 11:14:40 AM UTC-8, sonu kumar wrote:

 Hi Richard,
 I didn't upgrade web2py. 


Which version are you running?
 

 Also not changed the name of controller, models, modules.
 Although my application runs fine when I access via weblink but it is not 
 accessible via web2py administrative interface as I said.


And as Richard asks, is there a traceback or a ticket?

/dps
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Brando
I'm working on that now.

if anyone beats me to it please post the solution.


On Wednesday, January 8, 2014 11:23:21 AM UTC-8, Dave S wrote:

 On Wednesday, January 8, 2014 11:07:03 AM UTC-8, Brando wrote:

 I removed that if loop completely and it works fine now:

  
 The next obvious question:  did you test with no files?  To deal with 
 those of us who click too fast?

 /dps




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Brando
This works, added the requires statement for form validation:

def submit():
import datetime
form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file', 
_multiple='', requires=IS_NOT_EMPTY()),  BR(),INPUT(_type='submit'))
if form.accepts(request.vars, formname=form):
files = request.vars['up_files']
if not isinstance(files, list):
files = [files]
for f in files:
print f.filename
up_file = db.uploads.up_file.store(f, f.filename)
i = db.uploads.insert(notes=request.vars.notes, 
up_file=up_file, filename=f.filename, up_date= datetime.datetime.now())
db.commit()
return form submitted #redirect(URL('data', 'index'))
return dict(form=form)



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Brando
Question, how could I make it so I don't have to click the submit button. 
 How could i make it to where they choose the files and it auto submits it?



On Wednesday, January 8, 2014 11:35:44 AM UTC-8, Brando wrote:

 This works, added the requires statement for form validation:

 def submit():
 import datetime
 form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file', 
 _multiple='', requires=IS_NOT_EMPTY()),  BR(),INPUT(_type='submit'))
 if form.accepts(request.vars, formname=form):
 files = request.vars['up_files']
 if not isinstance(files, list):
 files = [files]
 for f in files:
 print f.filename
 up_file = db.uploads.up_file.store(f, f.filename)
 i = db.uploads.insert(notes=request.vars.notes, 
 up_file=up_file, filename=f.filename, up_date= datetime.datetime.now())
 db.commit()
 return form submitted #redirect(URL('data', 'index'))
 return dict(form=form)





-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: [web2py-dev] Rows.compact and other Rows methods

2014-01-08 Thread Massimo Di Pierro
Thank you. :-)

On Wednesday, 8 January 2014 12:28:18 UTC-6, Anthony wrote:

 OK, good point. In that case, I'll just send a patch for .find and .sort 
 so they return the original self.records items so .render will work 
 properly.

 Anthony

 On Wednesday, January 8, 2014 11:47:24 AM UTC-5, Massimo Di Pierro wrote:

 The problem is speed. I believe the getitem should be as fast as 
 possible. This was changed before so that the trasformation of the rows 
 occurred only once and not every time a row column is accessed.

 On Jan 8, 2014, at 8:41 AM, Anthony wrote:

 Let's discuss on the developers 
 listhttps://groups.google.com/forum/?fromgroups=#!topic/web2py-developers/k2D6MVfBEYo
 .

 On Tuesday, January 7, 2014 9:52:16 PM UTC-5, Joe Barnhart wrote:

 Maybe the best answer is to change Row so that it always holds the full 
 set of keys (table:field) and change the __getitem__ method to look up the 
 key recursively if only one part is provided.  Here is a sample method 
 which implements this strategy of testing keys for dicts within dicts.  Our 
 case is a little simpler since we never recurse more than one level deep.

 def _finditem(obj, key):
 if key in obj: return obj[key]
 for k, v in obj.items():
 if isinstance(v,dict):
 item = _finditem(v, key)
 if item is not None:
 return item


 This has the advantage of working with existing code and preserving as 
 much information as possible in the Row object.  I have a feeling this 
 could make the internals of web2py a good deal more consistent.  Less 
 testing for special cases is always good!

 -- Joe B.

 On Tuesday, January 7, 2014 3:48:39 PM UTC-8, Anthony wrote:

 Note, same problem with .sort (it modifies the Row objects in 
 self.records), so we should probably fix that as well (will be a bit more 
 complicated).

 Anthony

 On Tuesday, January 7, 2014 11:03:56 AM UTC-5, Anthony wrote:

 The Rows.find() method does the following:

 for row in self:
 if f(row):
 if a=k: records.append(row)
 k += 1
 if k==b: break

 In a Rows object, there is self.records, which is a list of Row 
 objects. Each Row object has at least one top-level key with the table 
 name, and the record is stored in the value associated with that key:

 Row {'person': {'first_name': 'Bob', 'last_name': 'Smith'}}

 When .find() is called on a Rows object with compact=True, the 
 __iter__ method (called by the for row in self loop) returns a 
 transformed version of each Row object, removing the top-level table key:

 Row {'first_name': 'Bob', 'last_name': 'Smith'}

 I believe this is an unnecessary transformation, and it is what is 
 subsequently causing the .render() method to fail (the .render() method 
 expects the top-level table key to be there, whether or not 
 compact=True). 
 I propose the following change to .find():

 for i, row in enumerate(self):
 if f(row):
 if a=k: records.append(self.records[i])
 k += 1
 if k==b: break

 The above code appends self.records[i] instead of row, which preserves 
 the original Row objects instead of including transformed objects. Anyone 
 see any problems with that change?

 Also, is there any reason all of the Rows methods (i.e., find, 
 exclude, __and__, __or__) should not be preserving the compact 
 attribute 
 of the original Rows object? Perhaps we should change them all to do so. 
 (Note, this is a separate issue unrelated to the above problem with 
 .find() 
 and .render().)

 Anthony

 On Tuesday, January 7, 2014 10:47:28 AM UTC-5, Anthony wrote:

 .render() works fine on Rows objects with compact=True, and it also 
 works fine on the results of .sort(), .exclude(), , and | operations. 
 The 
 only problem is with the results of .find() operations when the original 
 Rows object has compact=True. The problem is that the .find() method 
 modifies the Row objects in self.records when compact=True, which it 
 probably should not due.

 Aside from this issue, perhaps the various Rows methods should 
 preserve the compact attribute -- not sure why they don't.

 Forwarding to the developers list for discussion.

 Anthony

 On Tuesday, January 7, 2014 3:10:00 AM UTC-5, Joe Barnhart wrote:

 I've been experimenting with the render method of the Rows class, 
 and I am very impressed.  But one drawback I found is that the Rows 
 object 
 must have its value set to compact=False to work properly with 
 render(). 
  It isn't a problem if the Rows object is used directly without any 
 operators, but I discovered that many, if not most, Rows methods do not 
 preserve the compact setting.

 For example. if you sort the Rows, it leaves compact=True.  Ditto, 
 if you use extract or find on the Rows object.  The  and | 
 operators also set the compact variable to True.  The upshot is that 
 you 
 can't use any of these operators on the Rows object and 

Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Calvin Morrison
that'd be a Jquery thing.

jQuery(input#fileid).change(function () {
alert(jQuery(this).val())
});



On 8 January 2014 14:36, Brando bhe...@trustcc.com wrote:

 Question, how could I make it so I don't have to click the submit button.
  How could i make it to where they choose the files and it auto submits it?



 On Wednesday, January 8, 2014 11:35:44 AM UTC-8, Brando wrote:

 This works, added the requires statement for form validation:

 def submit():
 import datetime
 form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file',
 _multiple='', requires=IS_NOT_EMPTY()),  BR(),INPUT(_type='submit'))
 if form.accepts(request.vars, formname=form):
 files = request.vars['up_files']
 if not isinstance(files, list):
 files = [files]
 for f in files:
 print f.filename
 up_file = db.uploads.up_file.store(f, f.filename)
 i = db.uploads.insert(notes=request.vars.notes,
 up_file=up_file, filename=f.filename, up_date= datetime.datetime.now())
 db.commit()
 return form submitted #redirect(URL('data', 'index'))
 return dict(form=form)



  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Validating list:string fields

2014-01-08 Thread Massimo Di Pierro
Oops. I overlooked that this is a list field. I changed the IS_LIST_OF in 
trunk and now you can do:

db. 
register.sample_name.requires=IS_LIST_OF((IS_ALPHANUMERIC(),IS_LENGTH(maxsize=6)))

On Wednesday, 8 January 2014 12:48:24 UTC-6, Anthony wrote:

 For a list:-type field, I think you can only use IS_IN_SET(..., 
 multiple=True), IS_IN_DB(..., multiple=True), IS_NOT_EMPTY(), and 
 IS_LIST_OF(), no?

 IS_LIST_OF() takes only a single additional validator, so to apply 
 multiple validators using it, you would probably have to create a custom 
 validator that applies multiple validators.

 Anthony

 On Wednesday, January 8, 2014 1:04:36 PM UTC-5, Massimo Di Pierro wrote:

 You simply need in the model or in the action before SQLFORM

 db. register.sample_name.requires=(IS_ALPHANUMERIC(),IS_LENGTH(maxsize=6))



 On Wednesday, 8 January 2014 07:44:15 UTC-6, curly wrote:

 Hello,

 I'm trying to validate a list:string field with is_alphanumeric and 
 is_length - trying to ensure that names are no longer than 6 alphanumeric 
 characters in length. (I'm running web2py 2.8.1 in ubuntu 12.04)

 view:
 liSample name *: {{=form.custom.widget.sample_name}}/li

 controller:
 form = SQLFORM(db.register,fields=[..,'sample_name',...])

 if form.validate(onvalidation=validate_sample_name):
 form.vars.id = db.register.insert(**dict(form.vars))
 response.flash = 'Reg saved.'
 redirect(URL('samples', 'default', 'index'))
 elif form.errors:
 response.flash = 'form has errors'  
 return dict(form=form)
 
 model:
 db.define_table(
 register,
 .
 Field('sample_name','list:string'),
 )

 def validate_sample_name(form):
 for sample in form.vars.sample_name:
 out,ers = IS_ALPHANUMERIC()(sample) and 
 IS_LENGTH(maxsize=6)('sample')
 if ers:
 form.errors.sample_name = ers


 The above does check for alphanumeric characters but doesn't seem to 
 check for the length of each sample name.

 Am I doing something wrong?

 Many thanks.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] web2py administrative interface issue

2014-01-08 Thread Richard Vézina
Try to reboot you web2py instance and make sure there is no instance
remaining up and running...

Is this a dev local web2py app or a kind of production server?

We can't help you with the information you provide...

Richard


On Wed, Jan 8, 2014 at 2:25 PM, Dave S snidely@gmail.com wrote:

 On Wednesday, January 8, 2014 11:14:40 AM UTC-8, sonu kumar wrote:

 Hi Richard,
 I didn't upgrade web2py.


 Which version are you running?


 Also not changed the name of controller, models, modules.
 Although my application runs fine when I access via weblink but it is not
 accessible via web2py administrative interface as I said.


 And as Richard asks, is there a traceback or a ticket?

 /dps


 --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Validating list:string fields

2014-01-08 Thread Anthony
Nice.

On Wednesday, January 8, 2014 2:43:16 PM UTC-5, Massimo Di Pierro wrote:

 Oops. I overlooked that this is a list field. I changed the IS_LIST_OF in 
 trunk and now you can do:

 db. 
 register.sample_name.requires=IS_LIST_OF((IS_ALPHANUMERIC(),IS_LENGTH(maxsize=6)))

 On Wednesday, 8 January 2014 12:48:24 UTC-6, Anthony wrote:

 For a list:-type field, I think you can only use IS_IN_SET(..., 
 multiple=True), IS_IN_DB(..., multiple=True), IS_NOT_EMPTY(), and 
 IS_LIST_OF(), no?

 IS_LIST_OF() takes only a single additional validator, so to apply 
 multiple validators using it, you would probably have to create a custom 
 validator that applies multiple validators.

 Anthony

 On Wednesday, January 8, 2014 1:04:36 PM UTC-5, Massimo Di Pierro wrote:

 You simply need in the model or in the action before SQLFORM

 db. 
 register.sample_name.requires=(IS_ALPHANUMERIC(),IS_LENGTH(maxsize=6))



 On Wednesday, 8 January 2014 07:44:15 UTC-6, curly wrote:

 Hello,

 I'm trying to validate a list:string field with is_alphanumeric and 
 is_length - trying to ensure that names are no longer than 6 alphanumeric 
 characters in length. (I'm running web2py 2.8.1 in ubuntu 12.04)

 view:
 liSample name *: {{=form.custom.widget.sample_name}}/li

 controller:
 form = SQLFORM(db.register,fields=[..,'sample_name',...])

 if form.validate(onvalidation=validate_sample_name):
 form.vars.id = db.register.insert(**dict(form.vars))
 response.flash = 'Reg saved.'
 redirect(URL('samples', 'default', 'index'))
 elif form.errors:
 response.flash = 'form has errors'  
 return dict(form=form)
 
 model:
 db.define_table(
 register,
 .
 Field('sample_name','list:string'),
 )

 def validate_sample_name(form):
 for sample in form.vars.sample_name:
 out,ers = IS_ALPHANUMERIC()(sample) and 
 IS_LENGTH(maxsize=6)('sample')
 if ers:
 form.errors.sample_name = ers


 The above does check for alphanumeric characters but doesn't seem to 
 check for the length of each sample name.

 Am I doing something wrong?

 Many thanks.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Scheduler repeat time drift

2014-01-08 Thread Niphlod
I don't exactly get how you scheduled the tasks and how are you expecting 
them to run.
If you schedule a task to start at 10am and set a period of 24*60*60, the 
task will be requeued to be executed at 10am.
As the book says, 

*The time period is not calculated between the END of the first round and 
the START of the next, but from the START time of the first round to the 
START time of the next cycle)*



On Wednesday, January 8, 2014 5:10:38 PM UTC+1, Brian M wrote:

 Is there any way to keep the time at which recurring tasks run from 
 drifting? I've got several daily tasks that over time go from running at 
 say 10am to 10:30am - it seems like each consecutive run is 20 seconds or 
 so behind the previous day's. Is this simply a matter of the next execution 
 time being set based on the ending time of the current run rather than the 
 starting time?  If I want to better enforce running at a certain time daily 
 do I need to resort to having a maintenance task run say once a week and 
 reset the next run time of the daily tasks so they don't drift too far? I 
 suppose that this isn't too much of an issue for tasks that run on a more 
 regular basis like once a minute to process constantly updated queues, but 
 for things that you want to run at a certain set time it's a bit annoying.

 Thanks
 Brian


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: scheduler task is queued but not running

2014-01-08 Thread Niphlod
are you running the scheduler from where ? it should be in the gluon folder 
along with the other files from the framework, and hence not erroring on 
import.
If you're running from a standalone file then ok, with python2.6 you should 
have simplejson installed, and we'll fix in trunk to choose json over 
simplejson. 


On Wednesday, January 8, 2014 3:56:17 PM UTC+1, peter wrote:

 I tried 'python scheduler.py -h' to get more information.

 it blew up with an error no module named simplejson.

 I have python2.6 after googling, I changed (in gluon/scheduler.py)

 try:
 from gluon.contrib.simplejson import loads, dumps
 except:
 from simplejson import loads, dumps

 around line 84 to

 try:
 from gluon.contrib.simplejson import loads, dumps
 except:
 from json import loads, dumps

 it now blows up with a different issue on 'python scheduler.py -h', 
 however the scheduler now seems to work. The only other thing I changed was 
 the write permission on web2py-scheduler-log.

 This is the first time I have had problems with web2py and python2.6

 maybe the above should be changed to 

 try:
 from gluon.contrib.simplejson import loads, dumps
 except:
 try:
 from simplejson import loads, dumps
 except
 from json import loads, dumps


 Peter


 On Wednesday, 8 January 2014 10:23:11 UTC, peter wrote:

 I have a scheduler task marked as queued. I have an active working with 
 living heartbeats. They both have the same group name, the time for the 
 task to run is in the past. The task is not being executed. Does anyone 
 have any idea what might cause the problem. Web2py version 2.8.2
 Thanks
 Peter



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: scheduler task is queued but not running

2014-01-08 Thread Niphlod
whoops. my bad. definitely it should not give errors on import. The 
scheduler needs dal, utils and Storage so the only way to run it is from 
inside the gluon folder, along with the rest of the framework.

Also, please post the contents of your scheduler_task and scheduler_worker 
tables, so we figure out why it remains queued.

On Wednesday, January 8, 2014 9:07:26 PM UTC+1, Niphlod wrote:

 are you running the scheduler from where ? it should be in the gluon 
 folder along with the other files from the framework, and hence not 
 erroring on import.
 If you're running from a standalone file then ok, with python2.6 you 
 should have simplejson installed, and we'll fix in trunk to choose json 
 over simplejson. 


 On Wednesday, January 8, 2014 3:56:17 PM UTC+1, peter wrote:

 I tried 'python scheduler.py -h' to get more information.

 it blew up with an error no module named simplejson.

 I have python2.6 after googling, I changed (in gluon/scheduler.py)

 try:
 from gluon.contrib.simplejson import loads, dumps
 except:
 from simplejson import loads, dumps

 around line 84 to

 try:
 from gluon.contrib.simplejson import loads, dumps
 except:
 from json import loads, dumps

 it now blows up with a different issue on 'python scheduler.py -h', 
 however the scheduler now seems to work. The only other thing I changed was 
 the write permission on web2py-scheduler-log.

 This is the first time I have had problems with web2py and python2.6

 maybe the above should be changed to 

 try:
 from gluon.contrib.simplejson import loads, dumps
 except:
 try:
 from simplejson import loads, dumps
 except
 from json import loads, dumps


 Peter


 On Wednesday, 8 January 2014 10:23:11 UTC, peter wrote:

 I have a scheduler task marked as queued. I have an active working with 
 living heartbeats. They both have the same group name, the time for the 
 task to run is in the past. The task is not being executed. Does anyone 
 have any idea what might cause the problem. Web2py version 2.8.2
 Thanks
 Peter



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Nested References in Smart Grid

2014-01-08 Thread MVolpes
Thank you that worked however as pointed out its quite slow.

I ended up creating a view joining the tblmodels and tblmake and reference that

Thank you

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Different applications usiong same set of tables

2014-01-08 Thread Niphlod


On Wednesday, January 8, 2014 5:37:12 AM UTC+1, Jayadevan M wrote:

 Thank you. So fake_migrate=True will scan the structure defined for tables 
 defined under models in the .py files and create files under databases so 
 that the structure defined in the python files and in the databases folder 
 are same. It wil not really connect to the database at all.


it will connect, but it won't issue any DDL statement (change in structure 
of the underlying db). Also, one run of fake_migrate=True is enough, it's 
not meant to be left on.   
 

 If we set migrate=false, web2py will not do any checks at all, but 
 'assume' that the database table structure is in synch with those defined 
 under the models, and issue a ticket if there are issues.
 The files under database folder have no significance if migrate=False.


Yep, and that's why in production you **should** always set migrate=False: 
web2py won't have to diff models and .table files to see if there are any 
DDL statements to issue over and over.  

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: GAE: defaults on _tableobj

2014-01-08 Thread Alan Etkin
 

 by using it's  _tableobj I meant.. and then use GAE api


About using appengine property default values, the patch sets defaults for 
entity creation but I think that this would bypass the DAL interface, which 
uses it's own logic for setting default values. This could lead to web2py 
apps behaving unexpectedly when executing gae database commands due to 
parallel/concurrent ways of settings defaults.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: GAE: defaults on _tableobj

2014-01-08 Thread Alan Etkin


 About using appengine property default values, the patch sets defaults for 
 entity creation but I think that this would bypass the DAL interface,


I did not take in account that the patch just copies defaults, my bad. So I 
don't think the feature affects any previous implementation or leads to 
unexpected behavior, since it just passes model data to the backend 
configuration. However, a possible problem is when modifying field defaults 
after table creation, further changes would not be updated in _tableobj.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: GAE: defaults on _tableobj

2014-01-08 Thread Quint
Ok.

I will manage this myself then where I need it.

thanks anyway!

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Scheduler repeat time drift

2014-01-08 Thread Brian M
I've got it scheduled to repeat every 86400 seconds (24*60*60) so once a 
day.  I thought that it was supposed to keep the same start time like the 
book says but it has definitely been drifting - part of the task that's 
queued logs to a DB and I can see the timestamps there consistently 
drifting ~20 seconds later each day.  I had another task originally setup 
to send out a daily email at 9AM and it's drifted to going out around 
9:32AM over the last several months.

On Wednesday, January 8, 2014 1:52:31 PM UTC-6, Niphlod wrote:

 I don't exactly get how you scheduled the tasks and how are you expecting 
 them to run.
 If you schedule a task to start at 10am and set a period of 24*60*60, the 
 task will be requeued to be executed at 10am.
 As the book says, 

 *The time period is not calculated between the END of the first round and 
 the START of the next, but from the START time of the first round to the 
 START time of the next cycle)*



 On Wednesday, January 8, 2014 5:10:38 PM UTC+1, Brian M wrote:

 Is there any way to keep the time at which recurring tasks run from 
 drifting? I've got several daily tasks that over time go from running at 
 say 10am to 10:30am - it seems like each consecutive run is 20 seconds or 
 so behind the previous day's. Is this simply a matter of the next execution 
 time being set based on the ending time of the current run rather than the 
 starting time?  If I want to better enforce running at a certain time daily 
 do I need to resort to having a maintenance task run say once a week and 
 reset the next run time of the daily tasks so they don't drift too far? I 
 suppose that this isn't too much of an issue for tasks that run on a more 
 regular basis like once a minute to process constantly updated queues, but 
 for things that you want to run at a certain set time it's a bit annoying.

 Thanks
 Brian



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: GAE: insert using key_name

2014-01-08 Thread Alan Etkin
How about adding support in dal.py for the following:

# processes the field input and add defaults, computes, etc. (does not make 
actual insertion).
 values = db._insert(spam=alot, ...)
{spam: alot, ...}

So one can use the output for storing named keys (with app specific logic 
or maybe plugin for extended datastore functions).

AFAIK, the patch is trivial (it would need adding a _insert adapter method 
like the case of mongodb or imap)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Set Field Type Dynamically

2014-01-08 Thread MVolpes
Hi

I am loving the smart grid but the amount of references is killing 
itvery slow.

Removing the references and using multiple lefts is a workable option 
however I do want the goodness of references when editing a particular row 
in the edit field

Can I change the type dynmaically?

eg it is a integer I would set it to reference

I have tried 

db.tablename.field.type = reference othertable this changes it when I view

print db.tablename.field
reference othertable

but when applied to the gridnothing happens

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Best practices with sessions

2014-01-08 Thread Wonton
Hello everyone,

I'm trying to implement the web2py recipes to improve the efficiency and 
security of my backend.  I'm beggining with sessions and I have a couple of 
doubts:

- My site is over SSL and has user authentication, so I guess I should 
secure my sessions. The recipe sais In your applications, if they require 
authentication, you should make the session cookies secure 
with:session.secure(), 
but, where should I put that code?

- The number of session files of my server is growing quickly so I should 
use the sessions2trash.py script, but, how should I use that script? Should 
I create a cron task in my server that execute each day something like this 
python web2py.py -S app -M -R scripts/sessions2trash.py -A -o -x 3600 -f?

Thank you very much and kind regards!

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Alan Etkin


 I'm trying to use 
 jQuery-File-Uploadhttp://blueimp.github.io/jQuery-File-Upload/to implement 
 multiple file uploads.  I'm using this 
 tutorialhttp://in10min.blogspot.com/2013/04/web2py-implement-multiple-files-upload.html
  as 
 well as this sample app 
 HEREhttps://bitbucket.org/xavrenard/multiupload_module/src. 
  


I made a multiple upload demo for storing imap drafts here (using 
SQLFORM.factory and form customization)

http://www.web2pyslices.com/slice/show/1706/how-to-compose-a-multi-attachment-draftnormal-email-with-imapsmtp

I suppose it is possible to use it for any other app modifying the 
controller so it stores or processes the input however needed.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] android and web2py

2014-01-08 Thread Ismael Velandia

Hello list. 
How to connect android app with web2py through JSONRPC? Can someone help me 
with an example? 
Thanks from Colombia, 
Ismael Velandia

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Sharing fields across different tables in models?

2014-01-08 Thread Apple Mason
If we have a table full of products, but some products use slightly 
different fields, how should this be represented?

For example, if I sell clothing and furniture:

clothing and furniture share these fields:
 - price
 - description
 - stock
 - name

clothing have these special fields:
 - material/fabric
 - size

furniture have these special fields:
 - weight

Then, would this be a good way to handle it:

db.define_tables('product_fields', 
Field('price', 'double'),
Field('description', 'string'),
Field('stock', 'integer),
Field('name', 'string'))

db.define_tables('clothing_product',
Field('material_fabric', 'string'),
Field('size', 'string'),
Field('product_field', 'reference product_fields'))

db.define_tables('furniture_product',
Field('weight', 'double'),
Field('product_field', 'reference product_fields'))

The other way I can think of would be to have only two tables; 
'clothing_product' and 'furniture_product' but have the shared fields be 
replicated in both tables.

If I use the first approach, how would I resolve these problems:

1) How do I query all products at once, both clothing and furniture(and 
more if I add different products in the future)?

2) Because the tables are split for the products (ie, a clothing product 
stores its data in 'clothing_product' and 'product_fields' tables), how do 
I build forms for both tables and save them in one html page? I looked 
here: http://www.web2py.com/book/default/chapter/07#Multiple-forms-per-page but 
that has two submit buttons that submit two independent forms.  The only 
solution I can think of is to build my forms manually and then grab the 
values to insert into the db.

3) if I want to associate a product with a category, how should this be 
linked? For example:

db.define_tables('categories',
   Field('category_name', 'string'))

db.define_tables('categories_and_products',# Many to many relationship
   Field('category_id', 'reference categories'),
   Field('product_id', 'reference ???'))  # what table should I 
reference here ???


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Wiki.auth 401 error

2014-01-08 Thread waleedabu
Jim and Alan, 

I have the exact same problem, and exact same error.  my setup is simple: 
using the latest web2py_win (as of December 2013) and followed the book 
web2py_manual_5th.  The instructions in section 3.5 will guide you to use 
the built in wiki, and if you follow these instructions you will get the 
same error mentioned here.

I played around with it and I have not been able to figure out why.  A fix 
would be nice.please post an update if you figure it out.

Regards, 
Waleed 

On Sunday, December 22, 2013 1:54:25 PM UTC-6, jimbo wrote:

 This used to work, activate the built in wiki, then register, log in and I 
 got the wiki available. Now when I try to make a new wiki I get 401 even 
 though it lets me log on.

 Tried today and I get a 401 error when app accesses 
 /default/index/_create/index


 Thanks, Jimmy



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Wiki.auth 401 error

2014-01-08 Thread Alan Etkin


 Jim and Alan, 

 I have the exact same problem, and exact same error.  my setup is simple: 
 using the latest web2py_win (as of December 2013) and followed the book 
 web2py_manual_5th.  The instructions in section 3.5 will guide you to use 
 the built in wiki, and if you follow these instructions you will get the 
 same error mentioned here.


Could you try the example with trunk, i.e. the latest repo source code 
version? This way we can confirm it was fixed (or better, cannot be 
reproduced) in future versions. As of now, I cannot test the book howto 
with a win machine. Perhaps this is just reproducible with windows.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] auth.enable_record_versioning

2014-01-08 Thread Jayadevan M
A question about record versioning.  Is it possible to have this ON and 
still *not keep* deleted versions of the record in the original table? 2 
reasons - 
1) When there are tables with a number of deletes, the table will become 
huge 
2) If we are using hand-written SQLs in many places, we have to remember to 
add the filter to fetch only the valid records ( I am assuming when we 
write our SQLs, web2py will not automatically add a filter).

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Set Field Type Dynamically

2014-01-08 Thread Anthony
There's no need to change the field type. If you don't want to display the 
reference fields in the grid at all, just set the readable attribute to 
False. You can also pass a list of fields to the grid to display -- other 
fields will be excluded. If you do want to include the reference fields but 
want them to simply show the stored id values rather than doing recursive 
selects to retrieve values from the referenced table, just set 
db.tablename.field.represent = None.

Anthony

On Wednesday, January 8, 2014 4:40:36 PM UTC-5, MVolpes wrote:

 Hi

 I am loving the smart grid but the amount of references is killing 
 itvery slow.

 Removing the references and using multiple lefts is a workable option 
 however I do want the goodness of references when editing a particular row 
 in the edit field

 Can I change the type dynmaically?

 eg it is a integer I would set it to reference

 I have tried 

 db.tablename.field.type = reference othertable this changes it when I 
 view

 print db.tablename.field
 reference othertable

 but when applied to the gridnothing happens


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Sharing fields across different tables in models?

2014-01-08 Thread 黄祥
just a suggestion, why not create the table for category.
e.g.
db.define_tables('category', 
Field('name', 'string') )
db.define_tables('product', 
Field('price', 'double'),
Field('description', 'string'),
Field('stock', 'integer),
Field('name', 'string')
Field('material_fabric', 'string'),
Field('size', 'string'),
Field('weight', 'double'),
Field('category', 'reference category') )

then just use conditional method in view using jquery to show the field 
that match with category.

best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: ckeditor in appadmin

2014-01-08 Thread 黄祥
please check this discussion:
https://groups.google.com/forum/#!topic/web2py/OoZ1EI8OOmw

best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] REF: update_or_insert() confirming update

2014-01-08 Thread Teddy Nyambe
wanted to find out how to confirm that an update really took place
when using update_or_insert(), insert atleast returns the auto id but
a successful update seems to return none/null.

Any ideas?

-- 
...
Teddy Lubasi Nyambe
Opensource Zambia
Lusaka, ZAMBIA

Cell: +260 97 7760473
website: http://www.opensource.org.zm

~/
Human Knowledge belongs to the world! - AntiTrust

Man is a tool-using animal. Without tools he is nothing, with tools he
is all - Thomas Carlyle 1795-1881

/~

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] REF: DAL Catching errors

2014-01-08 Thread Teddy Nyambe
Hi,

I am trying to find out the best way to catch errors generated by
web2py especially those genereted by say DAL. Say forinstance if I
have a table:

db.define_table('test', Field('xyz', 'integer', unique=True)

If i insert a dublicate field will get the exception and ticket:

IntegrityError: (1062, uDuplicate entry 'X' for key 'xyz')

Now i want to catch such an error and send a better message to a user,
not the ticket etc.

Any ideas?

-- 
...
Teddy Lubasi Nyambe
Opensource Zambia
Lusaka, ZAMBIA

Cell: +260 97 7760473
website: http://www.opensource.org.zm

~/
Human Knowledge belongs to the world! - AntiTrust

Man is a tool-using animal. Without tools he is nothing, with tools he
is all - Thomas Carlyle 1795-1881

/~

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.