Re: [web2py] new feature in trunk: full auditing

2012-04-06 Thread szimszon
And there is still a archive_db parameter?

Like: 
db.table._archive_records(archive_db=other_db)

2012. április 6., péntek 3:28:40 UTC+2 időpontban Massimo Di Pierro a 
következőt írta:

 Please check it again. I did not change the API but changed the internal 
 logic so that one can do:

 db.table._archive_records()

 without using auth at all. This allows use with gluino too.



 On Thursday, 5 April 2012 18:19:17 UTC-5, rochacbruno wrote:

 great! I am testing

 On Thu, Apr 5, 2012 at 8:09 PM, Massimo Di Pierro 
 massimo.dipie...@gmail.com wrote:

 Now you can. ;-)

 auth.enable_record_versioning(db, archive_db=other_db)


 On Thursday, 5 April 2012 17:28:43 UTC-5, rochacbruno wrote:

 is it possible to redirect the archive to a separate database?

 On Thu, Apr 5, 2012 at 7:16 PM, Massimo Di Pierro 
 massimo.dipie...@gmail.com wrote:

 This is how it works:

 # define auth 
 auth = Auth(db, hmac_key=Auth.get_or_create_**key())
 auth.define_tables(username=**True,signature=True)

 # define your own tables like
 db.define_table('mything',**Field('name'),auth.signature)

  # than do:
 auth.enable_record_versioning(**db)

 how does it work? every table, including auth_user will have an 
 auth.signature including created_by, created_on, modified_by, 
 modified_on, 
 is_active fields. When a record of table mything (or any other table) is 
 modified, a copy of the previous record is copied into mything_archive 
 which references the current record. When a record is deleted, it is not 
 actually deleted but is_active is set to False, all records with 
 is_active==False are filtered out in searches except in appadmin.

 Pros:
 - your app will get full record archival for auditing purposes
 - could not be simpler. nothing else to do. Try with 
 SQLFORM.grid(db.mything) for example.
 - does not break references and there is no need for uuids
 - does not slow down searches because archive is done in separate 
 archive tables

 Cons:
 - uses lots of extra memory because every version of a record is 
 stored (it would be more efficient to store changes only but that would 
 make more difficult to do auditing).
 - slows down db(...).update(...) for multi record because it needs to 
 copy all records needing update from the original table to the archive 
 table. This requires selecting all the records.

 Comments? Suggestions?









 -- 

 Bruno Rocha
 [http://rochacbruno.com.br]




 -- 

 Bruno Rocha
 [http://rochacbruno.com.br]



Re: [web2py] Is there anyone using Linode to host Web2py??

2012-04-06 Thread pbreit
I don't think so. Try: apt-get install python-imaging

Re: [web2py] Is there anyone using Linode to host Web2py??

2012-04-06 Thread Kenny Chung
I just did it. :) thank you.

On Fri, Apr 6, 2012 at 12:10 AM, pbreit pbreitenb...@gmail.com wrote:

 I don't think so. Try: apt-get install python-imaging


[web2py] reference or list:reference

2012-04-06 Thread Annet
I defined the following tables:

db.define_table('Node',
Field('createdOn',type='datetime',writable=False,readable=False),
Field('modifiedOn',type='datetime',writable= False,readable=False),
migrate=False)

db.define_table('Keyword',
Field('word',length=128,default='',notnull=True,unique=True),
migrate=False)


db.define_table('NodeKeyword',

Field('nodeID',db.Node,default='',notnull=True,ondelete='CASCADE',writable=False,readable=False),
Field('word',length=128,default='',notnull=True,ondelete='CASCADE'),
migrate=False)

The table Keyword contains keywords like counselor, mediator, coach ...
The table NodeKeyword should contain ids and keywords:
1counselor
2counselor
3mediator

Is there a way to implement this in web2py? I now have a validator:

db.NodeKeyword.word.requires=[IS_IN_DB(db,'Keyword.word','%(word)s',zero='select
 
a value')]

and added the foreign key constraint to the postgres datbase manually.

I read about reference and list:reference in the book what exactly are they.


Kind regards,

Annet.



Re: [web2py] new feature in trunk: generic.map

2012-04-06 Thread Manuele Pesenti

+1

I think I'll propose generic_openlayers.map :-)

Manuele

Il 06/04/2012 01:54, Massimo Di Pierro ha scritto:

Example:

# model
db.define_table('point',
Field('name'),
Field('latitude','double'),
Field('longitude','double'))

#controller
def map():
return dict(
  googlemap_key='...',  # get this from google maps
  center_latitude = 41.878,
  center_longitude = -87.629,
  scale = 7,
  maker = lambda point: A(row.name,_href='...')
  points = db(db.point).select()
)

#in views/defaut/map.html:

{{extend 'layout.html'}}
center
h2My Map/h2
{{include 'generic.map'}}
/center





[web2py] Re: DataTables Help needed

2012-04-06 Thread Vineet


 Actually, it was a typo on my part...I did get it to work but now, working 
 on 23,500 records and it takes so long to process..is that jquery?? 



With that much of data to load, your best bet would be AJAX.
dataTables plugin provides for loading data with server-side ajax function.

You might also look into infinite scrolling feature of dataTables. 
In that, the data is rendered (DOM is manipulated) dynamically as you 
scroll.

You may visit their site  search for AJAX  infinite scroll.
I am using dataTables AJAX for my work.
If you need my code sample, do let me know on this list.

HTH

-- Vineet  


[web2py] IS_IN_DB with join

2012-04-06 Thread Manuele Pesenti
what are the possible record representation for the IS_IN_DB validator 
in this case?


join = (db.auth_membership.group_id==db.auth_group.id)\
(db.auth_membership.user_id==db.auth_user.id)

requires=IS_IN_DB(db(join), 'auth_group.id')

the string '%(auth_user.first_name)s' is not accepted as I expected and 
gave me the subsequent error:


Traceback (most recent call last):
  File 
/home/manuele/Dropbox/sviluppo/web2py-1.99.7/gluon/restricted.py, line 
205, in restricted

exec ccode in environment
  File 
/home/manuele/Dropbox/sviluppo/web2py-1.99.7/applications/dev_plugin_lookout/controllers/plugin_lookout.py, 
line 288, in module
  File /home/manuele/Dropbox/sviluppo/web2py-1.99.7/gluon/globals.py, 
line 173, in lambda

self._caller = lambda f: f()
  File /home/manuele/Dropbox/sviluppo/web2py-1.99.7/gluon/tools.py, 
line 2575, in f

return action(*a, **b)
  File 
/home/manuele/Dropbox/sviluppo/web2py-1.99.7/applications/dev_plugin_lookout/controllers/plugin_lookout.py, 
line 275, in share_data_with_users

Field('read_only', 'boolean')
  File /home/manuele/Dropbox/sviluppo/web2py-1.99.7/gluon/sqlhtml.py, 
line 1297, in factory

**attributes)
  File /home/manuele/Dropbox/sviluppo/web2py-1.99.7/gluon/sqlhtml.py, 
line 870, in __init__

inp = self.widgets.multiple.widget(field, default)
  File /home/manuele/Dropbox/sviluppo/web2py-1.99.7/gluon/sqlhtml.py, 
line 283, in widget

return OptionsWidget.widget(field, value, **attributes)
  File /home/manuele/Dropbox/sviluppo/web2py-1.99.7/gluon/sqlhtml.py, 
line 216, in widget

options = requires[0].options()
  File 
/home/manuele/Dropbox/sviluppo/web2py-1.99.7/gluon/validators.py, line 
465, in options

self.build_set()
  File 
/home/manuele/Dropbox/sviluppo/web2py-1.99.7/gluon/validators.py, line 
447, in build_set

fields = [table[k] for k in self.fields]
  File /home/manuele/Dropbox/sviluppo/web2py-1.99.7/gluon/dal.py, 
line 6714, in __getitem__

return dict.__getitem__(self, str(key))
KeyError: 'auth_user.first_name'


[web2py] How to install gluon in virtualenv?

2012-04-06 Thread Vincenzo Ampolo

Hi,

How can I install and use gluon in virtualenv ?

Thanks

--
Vincenzo Ampolo
http://vincenzo-ampolo.net
http://goshawknest.wordpress.com



[web2py] Re: new feature in trunk: better markmin

2012-04-06 Thread villas
Hi Massimo

I love to see improvements to Markmin,  it's great.

One thing that I do is substituting my own special 'tags' in my Markmin 
text with info from my 'Snippets' table which contains standard paragraphs.

For example...

My special tag in Markmin text is:  {id}   Or, more flexibly: 
 {mytable:myfield:id}

In controller,  something like this (pseudo code):  

# find all special tags
tags = re.findall('{[0-9]*}', markmintext)

# replace tags with lookups of the ids from 'snippets' table.
for t in tags:
markmintext = markmintext.replace(t,  db.snippets[t].paragraph)

This enables me to make up a page of content by simply listing a number of 
'tags' which pulls in paragraphs from my 'snippets' table.

Could something like this idea be included? 

Thanks,  David



[web2py] Trying to debug welcome with trunk

2012-04-06 Thread Alan Etkin
I pulled the last version and get an error when welcome starts:

Version 1.99.7 (2012-04-05 22:06:40) dev

Traceback (most recent call last):
  File /home/alan/web2py/web2py-hg/gluon/restricted.py, line 205, in 
restricted
exec ccode in environment
  File /home/alan/web2py/web2py-hg/applications/welcome/models/db.py 
http://127.0.0.1:8000/admin/default/edit/welcome/models/db.py, line 47, in 
module
auth.define_tables()
  File /home/alan/web2py/web2py-hg/gluon/tools.py, line 1381, in define_tables
format='%(first_name)s %(last_name)s (%(id)s)'))
  File /home/alan/web2py/web2py-hg/gluon/dal.py, line 6603, in define_table
common_filter=common_filter))
  File /home/alan/web2py/web2py-hg/gluon/dal.py, line 6872, in __init__
'define_table argument is not a Field or Table: %s' % field
SyntaxError: define_table argument is not a Field or Table: []


Something wrong with the auto table definitions for the auth object (see 
Line 47)

I think that the problem is that when creating auth, the auth settings 
extra_fields attribute is retrieved (tools.py line 1380) and it is returned 
as a list that cointains only an empty list ( [[]] ), but that inner list 
shouldn't be there, as it's supposed to be a sequence of Field instances to 
be added to the table fields (isn't it?). So at the loop for checking valid 
Field objects in dal.py, a syntax error is raised.

Has anyone else had this welcome app error?



Re: [web2py] Re: data source configuration

2012-04-06 Thread Alex
could you explain how this would look in detail?
So I would have a file called settings.py in the modules folder and the 
following content:
dbconnection = '...'

in my model files I could access the variable dbconnection, right? 
settings.py is only loaded once (I'm not that familiar with modules)? does 
this also work with compiled applications? and with (external) cron jobs?

Alex

Am Freitag, 6. April 2012 07:40:57 UTC+2 schrieb Anthony:

 Can't you just create a regular Python module, store the settings in 
 there, and import the module in your app code in order to access the 
 settings? If it's an app-level module (i.e., in the application's /module 
 folder), you can even create and edit it via the admin interface. To get 
 such modules to reload automatically upon changes, just add the following 
 to your app code:

 from gluon.custom_import import track_changes; track_changes(True)

 Anthony

 On Thursday, April 5, 2012 2:37:45 PM UTC-4, Alex wrote:

 First it must be decided if the configuration should be on the server or 
 on the application level. A configuration per application would be more 
 flexible so I'd prefer that. Basically all that's needed is a configuration 
 file which could be similar like the language translation file. The 
 settings should only be read once when web2py is started. It would be 
 convenient to edit the configuration in the admin interface (on an own page 
 like the database administration). In the admin interface the settings 
 could automatically be refreshed when they are changed so you would not 
 have to restart web2py in this case just to reload the configuration.

 In the application itself all you need is a method to read those settings 
 from the configuration. Maybe this could be added to the cache object but 
 I'm not really sure if this would fit in there. e.g.
 connection = cache.get_configuration_property('dbconnection')

 if not added to the cache a global application object would probably be 
 necessary.

 Am Donnerstag, 5. April 2012 00:48:24 UTC+2 schrieb Anthony:

 Do you have a proposal for how web2py should do this?

 On Wednesday, April 4, 2012 6:23:11 PM UTC-4, Alex wrote:

 each app is running in an own instance with an own webserver and of 
 course an own URL. But I cannot distinguish by the URL because this does 
 not work for cron jobs.

 I think the solution with reading a properties file and caching is fine 
 for me. Still, I think this feature is necessary for almost every real 
 world application and thus it would be good to have it in web2py. For 
 example in java application servers you can configure db connections in 
 the 
 admin console and access them via jndi. In grails there is an own 
 environment configuration so e.g. you can set different data sources, log 
 settings and so on for testing, development and production environment 
 (and 
 of course you could use your own environment, e.g. customer specific).

 Alex

 Am Mittwoch, 4. April 2012 04:04:08 UTC+2 schrieb Anthony:

 thanks for the cache info. I think that's the way to go for me. I'll 
 create a function to read the connection properties and add the cache 
 decorator for the function. It is still just a workaround but at least 
 it 
 should not have any performance penalties.

 I'm still wondering why such an essential feature is missing...


 How do you know which customer is accessing the app -- does something 
 in the URL distinguish customers? Whatever it is, can't you just create a 
 dictionary mapping the relevant request parameter to the appropriate data 
 source URI and either keep that dictionary in a model file or import it 
 from a module?

 Anthony 



[web2py] Re: reference or list:reference

2012-04-06 Thread Anthony


 db.define_table('Node',
 Field('createdOn',type='datetime',writable=False,readable=False),
 Field('modifiedOn',type='datetime',writable= False,readable=False),
 migrate=False)

 db.define_table('Keyword',
 Field('word',length=128,default='',notnull=True,unique=True),
 migrate=False)


 db.define_table('NodeKeyword',
 
 Field('nodeID',db.Node,default='',notnull=True,ondelete='CASCADE',writable=False,readable=False),
 Field('word',length=128,default='',notnull=True,ondelete='CASCADE'),
 migrate=False)

 db.NodeKeyword.word.requires=[IS_IN_DB(db,'Keyword.word','%(word)s',zero='select
  
 a value')]


Note, I don't think you need the '%(word)s' -- that will be used by default 
because it is simply the field used as the constraint (i.e., the second 
argument).
 

 I read about reference and list:reference in the book what exactly are 
 they.


You could make db.NodeKeyword.word a reference field to the db.Keyword 
table -- in that case, it will store the record id's (i.e., integers) of 
the associated keywords in the Keyword table. That will require an 
additional join between the NodeKeyword and Keyword table whenever you want 
the actual word text itself.

With a list:reference field, you wouldn't have the NodeKeyword table at 
all. Instead, you would add a word list:reference field to the Node table 
referencing the Keyword table. It would store a list of Keyword table 
record id's referencing a set of keywords. Simpler design and easier if you 
just need to display keywords per node, but less efficient if you need to 
search nodes by keyword (because you have to do a contains search on the 
list:reference field).

Anthony



[web2py] Re: Restful/Crud best practices?

2012-04-06 Thread rdodev
Bumping this discussion, because I'm really wondering how to avoid 
repetition of code when using restful requests (and in particular the crud 
wrapper). A follow up question perhaps is, should crud be used at all when 
implementing restful services? TIA.

On Thursday, April 5, 2012 4:41:24 PM UTC-4, rdodev wrote:

 Hey all,

 I'm building a crud-heavy app using web2py restful api/decorator. In a 
 non-restful context, it's easy (and cruft free) to create and grab forms 
 using the built-in crud wrapper. 
 However, in a restful context with separate GET/POST/PUT/DELETE methods, 
 what's the least repetitive and most web2py way of handling things?

 Thanks.



[web2py] Re: new feature in trunk: better markmin

2012-04-06 Thread Alan Etkin
I think this is groovy (i.e. one notch up from cool)

However, there's one thing: if @{hello} returns the output of the variable, 
shouldn't @{a/b/c} return the output of the call to the url?

On Friday, April 6, 2012 12:08:57 AM UTC-3, Massimo Di Pierro wrote:

 Consider this text

 text = 
 **bold**
 ''italic''
 ``code``
 [[anchor]]
 [[link to #anchor]]
 http://example/image.jpg (embeds the image)
 http://example/image.mp3 (embeds the audio)
 http://example/image.mp4 (embeds the video)
 @{hello}   (embeds the variable hello)
 @{controller/function/a/r/g/s.extension} (converts to the corresponding 
 full URL http:///app/controller/function/a/r/g/s.extension)
 

 print MARKMIN(text, url=True,environment=dict(hello='hello'))

 Can see the implications for use in CMS?
 Suggestions for improvements? This is experimental and I am not completely 
 sure about the syntax.

 Massimo



Re: [web2py] new feature in trunk: full auditing

2012-04-06 Thread Massimo Di Pierro
yes

On Friday, 6 April 2012 01:58:14 UTC-5, szimszon wrote:

 And there is still a archive_db parameter?

 Like: 
 db.table._archive_records(archive_db=other_db)

 2012. április 6., péntek 3:28:40 UTC+2 időpontban Massimo Di Pierro a 
 következőt írta:

 Please check it again. I did not change the API but changed the internal 
 logic so that one can do:

 db.table._archive_records()

 without using auth at all. This allows use with gluino too.



 On Thursday, 5 April 2012 18:19:17 UTC-5, rochacbruno wrote:

 great! I am testing

 On Thu, Apr 5, 2012 at 8:09 PM, Massimo Di Pierro 
 massimo.dipie...@gmail.com wrote:

 Now you can. ;-)

 auth.enable_record_versioning(db, archive_db=other_db)


 On Thursday, 5 April 2012 17:28:43 UTC-5, rochacbruno wrote:

 is it possible to redirect the archive to a separate database?

 On Thu, Apr 5, 2012 at 7:16 PM, Massimo Di Pierro 
 massimo.dipie...@gmail.com wrote:

 This is how it works:

 # define auth 
 auth = Auth(db, hmac_key=Auth.get_or_create_**key())
 auth.define_tables(username=**True,signature=True)

 # define your own tables like
 db.define_table('mything',**Field('name'),auth.signature)

  # than do:
 auth.enable_record_versioning(**db)

 how does it work? every table, including auth_user will have an 
 auth.signature including created_by, created_on, modified_by, 
 modified_on, 
 is_active fields. When a record of table mything (or any other table) is 
 modified, a copy of the previous record is copied into mything_archive 
 which references the current record. When a record is deleted, it is not 
 actually deleted but is_active is set to False, all records with 
 is_active==False are filtered out in searches except in appadmin.

 Pros:
 - your app will get full record archival for auditing purposes
 - could not be simpler. nothing else to do. Try with 
 SQLFORM.grid(db.mything) for example.
 - does not break references and there is no need for uuids
 - does not slow down searches because archive is done in separate 
 archive tables

 Cons:
 - uses lots of extra memory because every version of a record is 
 stored (it would be more efficient to store changes only but that would 
 make more difficult to do auditing).
 - slows down db(...).update(...) for multi record because it needs to 
 copy all records needing update from the original table to the archive 
 table. This requires selecting all the records.

 Comments? Suggestions?









 -- 

 Bruno Rocha
 [http://rochacbruno.com.br]




 -- 

 Bruno Rocha
 [http://rochacbruno.com.br]



Re: [web2py] Re: data source configuration

2012-04-06 Thread Anthony


 could you explain how this would look in detail?
 So I would have a file called settings.py in the modules folder and the 
 following content:
 dbconnection = '...'

 in my model files I could access the variable dbconnection, right?


Yes, but of course you have to import the settings module first. Maybe at 
the beginning of your first model file (they are executed alphabetically), 
do:

from gluon.custom_import import track_changes; track_changes(True)
import settings

Then subsequently in any model files, controllers, or views, you can access 
settings.dbconnection, etc.
 

 settings.py is only loaded once (I'm not that familiar with modules)?


Yes, it should be (though with track_changes(True) it will automatically be 
reloaded whenever it changes).
 

 does this also work with compiled applications?


It should.
 

 and with (external) cron jobs?


I believe so, as long as the job runs the application models (where the 
settings are imported). I suppose it could also import the settings 
directly.

Anthony


[web2py] Re: new feature in trunk: generic.map

2012-04-06 Thread Alan Etkin
Will the example mark db points in a google map? Are there any other uses 
possible provided by the Google API trough the web2py interface?

On Thursday, April 5, 2012 8:54:32 PM UTC-3, Massimo Di Pierro wrote:

 Example:

 # model
 db.define_table('point',
 Field('name'),
 Field('latitude','double'),
 Field('longitude','double'))

 #controller
 def map():
 return dict(
   googlemap_key='...',  # get this from google maps
   center_latitude = 41.878,
   center_longitude = -87.629,
   scale = 7,
   maker = lambda point: A(row.name,_href='...')
   points = db(db.point).select() 
 )

 #in views/defaut/map.html:

 {{extend 'layout.html'}}
 center
h2My Map/h2
 {{include 'generic.map'}}
 /center



[web2py] Re: Trying to debug welcome with trunk

2012-04-06 Thread Massimo Di Pierro
sorry. fixed.

On Friday, 6 April 2012 07:23:19 UTC-5, Alan Etkin wrote:

 I pulled the last version and get an error when welcome starts:

 Version 1.99.7 (2012-04-05 22:06:40) dev

 Traceback (most recent call last):
   File /home/alan/web2py/web2py-hg/gluon/restricted.py, line 205, in 
 restricted
 exec ccode in environment
   File /home/alan/web2py/web2py-hg/applications/welcome/models/db.py 
 http://127.0.0.1:8000/admin/default/edit/welcome/models/db.py, line 47, in 
 module
 auth.define_tables()
   File /home/alan/web2py/web2py-hg/gluon/tools.py, line 1381, in 
 define_tables
 format='%(first_name)s %(last_name)s (%(id)s)'))
   File /home/alan/web2py/web2py-hg/gluon/dal.py, line 6603, in define_table
 common_filter=common_filter))
   File /home/alan/web2py/web2py-hg/gluon/dal.py, line 6872, in __init__
 'define_table argument is not a Field or Table: %s' % field
 SyntaxError: define_table argument is not a Field or Table: []


 Something wrong with the auto table definitions for the auth object (see 
 Line 47)

 I think that the problem is that when creating auth, the auth settings 
 extra_fields attribute is retrieved (tools.py line 1380) and it is returned 
 as a list that cointains only an empty list ( [[]] ), but that inner list 
 shouldn't be there, as it's supposed to be a sequence of Field instances to 
 be added to the table fields (isn't it?). So at the loop for checking valid 
 Field objects in dal.py, a syntax error is raised.

 Has anyone else had this welcome app error?



[web2py] Re: new feature in trunk: better markmin

2012-04-06 Thread Massimo Di Pierro
Let me think about his.

On Friday, 6 April 2012 06:43:47 UTC-5, villas wrote:

 Hi Massimo

 I love to see improvements to Markmin,  it's great.

 One thing that I do is substituting my own special 'tags' in my Markmin 
 text with info from my 'Snippets' table which contains standard paragraphs.

 For example...

 My special tag in Markmin text is:  {id}   Or, more flexibly: 
  {mytable:myfield:id}

 In controller,  something like this (pseudo code):  

 # find all special tags
 tags = re.findall('{[0-9]*}', markmintext)

 # replace tags with lookups of the ids from 'snippets' table.
 for t in tags:
 markmintext = markmintext.replace(t,  db.snippets[t].paragraph)

 This enables me to make up a page of content by simply listing a number of 
 'tags' which pulls in paragraphs from my 'snippets' table.

 Could something like this idea be included? 

 Thanks,  David



[web2py] Re: new feature in trunk: better markmin

2012-04-06 Thread Massimo Di Pierro


On Friday, 6 April 2012 08:30:03 UTC-5, Alan Etkin wrote:

 I think this is groovy (i.e. one notch up from cool)

 However, there's one thing: if @{hello} returns the output of the 
 variable, shouldn't @{a/b/c} return the output of the call to the url?


Isn't that what it does?
 


 On Friday, April 6, 2012 12:08:57 AM UTC-3, Massimo Di Pierro wrote:

 Consider this text

 text = 
 **bold**
 ''italic''
 ``code``
 [[anchor]]
 [[link to #anchor]]
 http://example/image.jpg (embeds the image)
 http://example/image.mp3 (embeds the audio)
 http://example/image.mp4 (embeds the video)
 @{hello}   (embeds the variable hello)
 @{controller/function/a/r/g/s.extension} (converts to the corresponding 
 full URL http:///app/controller/function/a/r/g/s.extension)
 

 print MARKMIN(text, url=True,environment=dict(hello='hello'))

 Can see the implications for use in CMS?
 Suggestions for improvements? This is experimental and I am not 
 completely sure about the syntax.

 Massimo



[web2py] Uploads saving to DB, but not to file system

2012-04-06 Thread rdodev
I already searched thought this groups for uploads and found a bunch 
similar questions, but not exactly my case -- I apologize if this has been 
answered before.

I have a minimal RESTful web service defined as follows:

db.define_table('UPLOAD',
Field('custom_name' ,type='string',  length=40, required=True),
Field('file_name',  type='upload', required=True),
)

@request.restful()
def index():
def GET(upload_id=None):
if not upload_id:
form = SQLFORM(db. UPLOAD )
response.view = 'default/index.html'
return dict(form=form)
else: 
   ...
 def POST(*args,**vars):
return db.UPLOAD.validate_and_insert(**vars)

return locals()

when it posts, it does insert the file and and custom name, but it does not 
actually save the file to disk (or anywhere for that matter). Am I missing 
a step somewhere? Thanks.


[web2py] Re: new feature in trunk: better markmin

2012-04-06 Thread Alan Etkin
I should have tested it before posting. My guess was that it will return a 
link to an absolute URL. What I meant was that I expected the actual data 
returned by the controller function call (normally a dict), although I 
don't know how this should be rendered when processed by markmin.

Perhaps allow something like this:

@{my/u/r/l[a_div]}

On Friday, April 6, 2012 11:18:50 AM UTC-3, Massimo Di Pierro wrote:



 On Friday, 6 April 2012 08:30:03 UTC-5, Alan Etkin wrote:

 I think this is groovy (i.e. one notch up from cool)

 However, there's one thing: if @{hello} returns the output of the 
 variable, shouldn't @{a/b/c} return the output of the call to the url?


 Isn't that what it does?
  


 On Friday, April 6, 2012 12:08:57 AM UTC-3, Massimo Di Pierro wrote:

 Consider this text

 text = 
 **bold**
 ''italic''
 ``code``
 [[anchor]]
 [[link to #anchor]]
 http://example/image.jpg (embeds the image)
 http://example/image.mp3 (embeds the audio)
 http://example/image.mp4 (embeds the video)
 @{hello}   (embeds the variable hello)
 @{controller/function/a/r/g/s.extension} (converts to the corresponding 
 full URL http:///app/controller/function/a/r/g/s.extension)
 

 print MARKMIN(text, url=True,environment=dict(hello='hello'))

 Can see the implications for use in CMS?
 Suggestions for improvements? This is experimental and I am not 
 completely sure about the syntax.

 Massimo



[web2py] nice to introduce new button in grid

2012-04-06 Thread Manuele Pesenti
can you suggest a nice looking solution for easly introduce new buttons 
in grid and smartgrid when I'm in edit mode?

This are an example of a button to introduce:

my_extra_element_1 = FORM(INPUT(_type=submit, _value=T('Share data')), 
_action=URL('share_data_with_users', args=table_id))


I would like to align with other button such as back, edit or view

At the moment I use to do something like this:

orm.components += [my_extra_element_1]

but it's not a nice solution expecially if I got more than one element 
to introduce



Thanks a lot

Cheers

Manuele


[web2py] Re: new feature in trunk: better markmin

2012-04-06 Thread Alan Etkin
 @{controller/function/a/r/g/s.extension} (converts to the corresponding 
full URL http:///app/controller/function/a/r/g/s.extension)

The example as is didn't work for me: this instead did:
@{appname/controller/function.extension}

And as I posted elsewhere makes a link. Now for me this could be handy too:

@{appname/controller/function.extension element key}

The above sentence would tell markmin to retrieve the action dictionary and 
put the element's output in the page. Markmin would have also to store the 
action function call somewhere to avoid redundancy.

Another question.

Can we do @{request.now} for example? (without the need to pass environment 
to the markmin helper)


Re: [web2py] nice to introduce new button in grid

2012-04-06 Thread Jonathan Lundell
On Apr 6, 2012, at 8:15 AM, Manuele Pesenti wrote:
 
 can you suggest a nice looking solution for easly introduce new buttons in 
 grid and smartgrid when I'm in edit mode?
 This are an example of a button to introduce:
 
 my_extra_element_1 = FORM(INPUT(_type=submit, _value=T('Share data')), 
 _action=URL('share_data_with_users', args=table_id))
 
 I would like to align with other button such as back, edit or view
 
 At the moment I use to do something like this:
 
 orm.components += [my_extra_element_1]
 
 but it's not a nice solution expecially if I got more than one element to 
 introduce

On a related note, I was trying to do this, more or less, this morning, and I 
thought I might try to explore the structure of the grid by displaying it with 
BEAUTIFY. But of course (I guess of course) that gives me the presentation of 
the form/table itself, not a breakdown of its structure.

I wonder if it wouldn't be straightforward to have a version of BEAUTIFY 
(arguments? alternative version called DUMP?) that would suppress this behavior 
and give us a dump of the object down to lower-level structures: dicts, lists, 
etc? Or is there already some better way to explore the structure of a FORM or 
SQLTABLE or whatever?

[web2py] Re: Uploads saving to DB, but not to file system

2012-04-06 Thread Massimo Di Pierro
say you have a vars.file_name that contains the file to be uploaded. Before 
the insert you need to do (I think):

vars.file_name = 
db.UPLOAD.file_name.store(vars.file_name.file,filename=ars.file_name.filename)

Perhaps this can be automated a little but. Let me give it some thought. 
Please open an issue on google code.


On Friday, 6 April 2012 09:43:40 UTC-5, rdodev wrote:

 I already searched thought this groups for uploads and found a bunch 
 similar questions, but not exactly my case -- I apologize if this has been 
 answered before.

 I have a minimal RESTful web service defined as follows:

 db.define_table('UPLOAD',
 Field('custom_name' ,type='string',  length=40, required=True),
 Field('file_name',  type='upload', required=True),
 )

 @request.restful()
 def index():
 def GET(upload_id=None):
 if not upload_id:
 form = SQLFORM(db. UPLOAD )
 response.view = 'default/index.html'
 return dict(form=form)
 else: 
...
  def POST(*args,**vars):
 return db.UPLOAD.validate_and_insert(**vars)

 return locals()

 when it posts, it does insert the file and and custom name, but it does 
 not actually save the file to disk (or anywhere for that matter). Am I 
 missing a step somewhere? Thanks.



[web2py] Re: nice to introduce new button in grid

2012-04-06 Thread Massimo Di Pierro
I really think these buttons should go away in favor of a dropdown menu.

On Friday, 6 April 2012 10:15:30 UTC-5, Manuele wrote:

 can you suggest a nice looking solution for easly introduce new buttons 
 in grid and smartgrid when I'm in edit mode?
 This are an example of a button to introduce:

 my_extra_element_1 = FORM(INPUT(_type=submit, _value=T('Share data')), 
 _action=URL('share_data_with_users', args=table_id))

 I would like to align with other button such as back, edit or view

 At the moment I use to do something like this:

 orm.components += [my_extra_element_1]

 but it's not a nice solution expecially if I got more than one element 
 to introduce


 Thanks a lot

 Cheers

  Manuele



[web2py] Re: new feature in trunk: better markmin

2012-04-06 Thread Massimo Di Pierro
I will double check. You should be able to do

embed:@{}

which uses iframe.
perhaps we should also have a 

ajax:@{...}

This requires some more thought. What features would you like to see?


On Friday, 6 April 2012 10:34:17 UTC-5, Alan Etkin wrote:

  @{controller/function/a/r/g/s.extension} (converts to the corresponding 
 full URL http:///app/controller/function/a/r/g/s.extension)

 The example as is didn't work for me: this instead did:
 @{appname/controller/function.extension}

 And as I posted elsewhere makes a link. Now for me this could be handy too:

 @{appname/controller/function.extension element key}

 The above sentence would tell markmin to retrieve the action dictionary 
 and put the element's output in the page. Markmin would have also to store 
 the action function call somewhere to avoid redundancy.

 Another question.

 Can we do @{request.now} for example? (without the need to pass 
 environment to the markmin helper)



[web2py] Re: Uploads saving to DB, but not to file system

2012-04-06 Thread rdodev
Issue posted.

On Friday, April 6, 2012 11:47:29 AM UTC-4, Massimo Di Pierro wrote:

 say you have a vars.file_name that contains the file to be uploaded. 
 Before the insert you need to do (I think):

 vars.file_name = 
 db.UPLOAD.file_name.store(vars.file_name.file,filename=ars.file_name.filename)

 Perhaps this can be automated a little but. Let me give it some thought. 
 Please open an issue on google code.


 On Friday, 6 April 2012 09:43:40 UTC-5, rdodev wrote:

 I already searched thought this groups for uploads and found a bunch 
 similar questions, but not exactly my case -- I apologize if this has been 
 answered before.

 I have a minimal RESTful web service defined as follows:

 db.define_table('UPLOAD',
 Field('custom_name' ,type='string',  length=40, required=True),
 Field('file_name',  type='upload', required=True),
 )

 @request.restful()
 def index():
 def GET(upload_id=None):
 if not upload_id:
 form = SQLFORM(db. UPLOAD )
 response.view = 'default/index.html'
 return dict(form=form)
 else: 
...
  def POST(*args,**vars):
 return db.UPLOAD.validate_and_insert(**vars)

 return locals()

 when it posts, it does insert the file and and custom name, but it does 
 not actually save the file to disk (or anywhere for that matter). Am I 
 missing a step somewhere? Thanks.



[web2py] Re: new feature in trunk: generic.map

2012-04-06 Thread Cliff
+1

On Thursday, April 5, 2012 7:54:32 PM UTC-4, Massimo Di Pierro wrote:

 Example:

 # model
 db.define_table('point',
 Field('name'),
 Field('latitude','double'),
 Field('longitude','double'))

 #controller
 def map():
 return dict(
   googlemap_key='...',  # get this from google maps
   center_latitude = 41.878,
   center_longitude = -87.629,
   scale = 7,
   maker = lambda point: A(row.name,_href='...')
   points = db(db.point).select() 
 )

 #in views/defaut/map.html:

 {{extend 'layout.html'}}
 center
h2My Map/h2
 {{include 'generic.map'}}
 /center



[web2py] Re: new feature in trunk: better markmin

2012-04-06 Thread Alan Etkin
I like ajax:@... more than the iframe solution. iframe has not so good 
publicity AFAIK among some users. For example here:
http://stackoverflow.com/questions/755795/are-iframes-html-obsolete . I am 
not saying that I would not use iframe, just that there are users against 
it.

For suggesting other features, I'm afraid I don't have the enough 
experience with MARKMIN to post anything else by now.

On Friday, April 6, 2012 12:51:45 PM UTC-3, Massimo Di Pierro wrote:

 I will double check. You should be able to do

 embed:@{}

 which uses iframe.
 perhaps we should also have a 

 ajax:@{...}

 This requires some more thought. What features would you like to see?


 On Friday, 6 April 2012 10:34:17 UTC-5, Alan Etkin wrote:

  @{controller/function/a/r/g/s.extension} (converts to the corresponding 
 full URL http:///app/controller/function/a/r/g/s.extension)

 The example as is didn't work for me: this instead did:
 @{appname/controller/function.extension}

 And as I posted elsewhere makes a link. Now for me this could be handy 
 too:

 @{appname/controller/function.extension element key}

 The above sentence would tell markmin to retrieve the action dictionary 
 and put the element's output in the page. Markmin would have also to store 
 the action function call somewhere to avoid redundancy.

 Another question.

 Can we do @{request.now} for example? (without the need to pass 
 environment to the markmin helper)



[web2py] Re: How to install gluon in virtualenv?

2012-04-06 Thread Alan Etkin
I belive you can copy the entire web2py source folder and append the 
location to sys.path

On Friday, April 6, 2012 6:52:46 AM UTC-3, Vincenzo Ampolo wrote:

 Hi,

 How can I install and use gluon in virtualenv ?

 Thanks

 -- 
 Vincenzo Ampolo
 http://vincenzo-ampolo.net
 http://goshawknest.wordpress.com



[web2py] Re: new feature in trunk: generic.map

2012-04-06 Thread Massimo Di Pierro
I guess yes but I did not need them

On Friday, 6 April 2012 08:47:26 UTC-5, Alan Etkin wrote:

 Will the example mark db points in a google map? Are there any other uses 
 possible provided by the Google API trough the web2py interface?

 On Thursday, April 5, 2012 8:54:32 PM UTC-3, Massimo Di Pierro wrote:

 Example:

 # model
 db.define_table('point',
 Field('name'),
 Field('latitude','double'),
 Field('longitude','double'))

 #controller
 def map():
 return dict(
   googlemap_key='...',  # get this from google maps
   center_latitude = 41.878,
   center_longitude = -87.629,
   scale = 7,
   maker = lambda point: A(row.name,_href='...')
   points = db(db.point).select() 
 )

 #in views/defaut/map.html:

 {{extend 'layout.html'}}
 center
h2My Map/h2
 {{include 'generic.map'}}
 /center



[web2py] Re: new feature in trunk: better markmin

2012-04-06 Thread Massimo Di Pierro
The problem is that everything supported so far makes markmin 
self-sufficient. ajax:@{...} would require web2py.js


On Friday, 6 April 2012 11:31:47 UTC-5, Alan Etkin wrote:

 I like ajax:@... more than the iframe solution. iframe has not so good 
 publicity AFAIK among some users. For example here:
 http://stackoverflow.com/questions/755795/are-iframes-html-obsolete . I 
 am not saying that I would not use iframe, just that there are users 
 against it.

 For suggesting other features, I'm afraid I don't have the enough 
 experience with MARKMIN to post anything else by now.

 On Friday, April 6, 2012 12:51:45 PM UTC-3, Massimo Di Pierro wrote:

 I will double check. You should be able to do

 embed:@{}

 which uses iframe.
 perhaps we should also have a 

 ajax:@{...}

 This requires some more thought. What features would you like to see?


 On Friday, 6 April 2012 10:34:17 UTC-5, Alan Etkin wrote:

  @{controller/function/a/r/g/s.extension} (converts to the 
 corresponding full URL 
 http:///app/controller/function/a/r/g/s.extension)

 The example as is didn't work for me: this instead did:
 @{appname/controller/function.extension}

 And as I posted elsewhere makes a link. Now for me this could be handy 
 too:

 @{appname/controller/function.extension element key}

 The above sentence would tell markmin to retrieve the action dictionary 
 and put the element's output in the page. Markmin would have also to store 
 the action function call somewhere to avoid redundancy.

 Another question.

 Can we do @{request.now} for example? (without the need to pass 
 environment to the markmin helper)



Re: [web2py] Re: How to install gluon in virtualenv?

2012-04-06 Thread Bruno Rocha
Experimental:

You can do:

easy_install gluino

And you will get a minified web2py inside your virtual env.

On Fri, Apr 6, 2012 at 1:43 PM, Alan Etkin spame...@gmail.com wrote:

 I belive you can copy the entire web2py source folder and append the
 location to sys.path


 On Friday, April 6, 2012 6:52:46 AM UTC-3, Vincenzo Ampolo wrote:

 Hi,

 How can I install and use gluon in virtualenv ?

 Thanks

 --
 Vincenzo Ampolo
 http://vincenzo-ampolo.net
 http://goshawknest.wordpress.**com http://goshawknest.wordpress.com




-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] Re: data source configuration

2012-04-06 Thread Alex
thanks, Anthony.

In case that's the way to go: could this be added somewhere to the official 
documentation? I think that's really important and it is not obvious for 
non-python-experts (like me).

Alex

Am Freitag, 6. April 2012 15:44:43 UTC+2 schrieb Anthony:

 could you explain how this would look in detail?
 So I would have a file called settings.py in the modules folder and the 
 following content:
 dbconnection = '...'

 in my model files I could access the variable dbconnection, right?


 Yes, but of course you have to import the settings module first. Maybe at 
 the beginning of your first model file (they are executed alphabetically), 
 do:

 from gluon.custom_import import track_changes; track_changes(True)
 import settings

 Then subsequently in any model files, controllers, or views, you can 
 access settings.dbconnection, etc.
  

 settings.py is only loaded once (I'm not that familiar with modules)?


 Yes, it should be (though with track_changes(True) it will automatically 
 be reloaded whenever it changes).
  

 does this also work with compiled applications?


 It should.
  

 and with (external) cron jobs?


 I believe so, as long as the job runs the application models (where the 
 settings are imported). I suppose it could also import the settings 
 directly.

 Anthony



[web2py] AJAX form submission using CRUD in web2py

2012-04-06 Thread rahulserver

  
Is it possible to validate CRUD form fields using ajax without submitting 
the form in web2py?

I have gone through the web2py online doc and have seen this link: 
http://web2py.com/books/default/chapter/29/11#Ajax-form-submission So we 
may do it using custom html. But I want to do it using CRUD. Also in crud 
form,a field of type date shows calendar only after the validation fails 
and user begins to enter the correct date. Can it be showed on the first 
attempt itself??


Re: [web2py] new feature in trunk: better markmin

2012-04-06 Thread Martin Weissenboeck
Maybe we could get nested lists?
Something like

- item a
-- item aa
-- item ab
- item b

Martin
Am 06.04.2012 03:09 schrieb Massimo Di Pierro massimo.dipie...@gmail.com
:

 Consider this text

 text = 
 **bold**
 ''italic''
 ``code``
 [[anchor]]
 [[link to #anchor]]
 http://example/image.jpg (embeds the image)
 http://example/image.mp3 (embeds the audio)
 http://example/image.mp4 (embeds the video)
 @{hello}   (embeds the variable hello)
 @{controller/function/a/r/g/s.extension} (converts to the corresponding
 full URL http:///app/controller/function/a/r/g/s.extension)
 

 print MARKMIN(text, url=True,environment=dict(hello='hello'))

 Can see the implications for use in CMS?
 Suggestions for improvements? This is experimental and I am not completely
 sure about the syntax.

 Massimo




[web2py] auth_user reference to other table

2012-04-06 Thread BlueShadow
Hi,
i like to ask the user for his country. So I added a field country to the 
auth_user table. but I like it to be a referenz to db.country which I 
define later in the db.py file. for some reason I get an error message when 
trying to do that.


[web2py] Re: auth_user reference to other table

2012-04-06 Thread pbreit
I think you need to make sure the auth tables is created before the 
db.country table with this line:

auth.define_tables()


[web2py] Re: auth_user reference to other table

2012-04-06 Thread pbreit
Actually, I'm not sure that is the problem. Are you getting a specific 
error message? Can you show the auth_user and db.country code you are using?

On Friday, April 6, 2012 1:22:52 PM UTC-7, pbreit wrote:

 I think you need to make sure the auth tables is created before the 
 db.country table with this line:

 auth.define_tables()



Re: [web2py] new feature in trunk: better markmin

2012-04-06 Thread Massimo Di Pierro
This has been on the todo list for a while. It requires refactoring of the 
way markmin handles nested lists. If this is done, must be donefor both 
markmin2html and markmin2latex. I very much support this feature but it not 
a priority for me. If somebody wants to work on it, I will take a patch.

Massimo


On Friday, 6 April 2012 14:17:37 UTC-5, mweissen wrote:

 Maybe we could get nested lists?
 Something like

 - item a
 -- item aa
 -- item ab
 - item b

 Martin
 Am 06.04.2012 03:09 schrieb Massimo Di Pierro 
 massimo.dipie...@gmail.com:

 Consider this text

 text = 
 **bold**
 ''italic''
 ``code``
 [[anchor]]
 [[link to #anchor]]
 http://example/image.jpg (embeds the image)
 http://example/image.mp3 (embeds the audio)
 http://example/image.mp4 (embeds the video)
 @{hello}   (embeds the variable hello)
 @{controller/function/a/r/g/s.extension} (converts to the corresponding 
 full URL http:///app/controller/function/a/r/g/s.extension)
 

 print MARKMIN(text, url=True,environment=dict(hello='hello'))

 Can see the implications for use in CMS?
 Suggestions for improvements? This is experimental and I am not 
 completely sure about the syntax.

 Massimo



[web2py] Moda em rede Social

2012-04-06 Thread Ovidio Marinho
Esta caracterizado que existe um modismo em redes sociais. primeiro veio a
grande moda do Orkut , depois o Facebook, e tantas outras muito boas que
não decolaram , mas que podem decolar a qualquer momento dependendo da sua
oferta de facilidade e necessidade. No Android ja exite uma app que faz de
seu celular um radio , isso ta pegando.  O Movuca eh um grande candidato a
decolar no mundo pyhton com web2py. Falta um pouco de investimento na obra
de Bruno Rocha, que nas horas vagas tenta melhorar o excelente
produto.Talvez agora com web-sockets nativo no web2py o movuca possa trazer
novidades de video e chat on-line e funcionando bem na plataforma mobility.
Vamos abrir esta discursão.

This featured a fad that exists in social networks. came the first major
fashion Orkut, then Facebook, and many other very good that did not
pan out, but
that can take off at any time depending on your offer ease and necessity.
Android already exit in an app that makes your phone a radio, taking it ta.
The h Movuca a great candidate to take off in the world with web2py Python.
Lack of investment in a little work of Bruno Rocha, who in his spare time tries
to improve the excellent produto.Talvez now with web-native sockets in the
web2py movuca can bring news and video chat online and working well on the
platform mobility. Let's open this issue '.


   Ovidio Marinho Falcao Neto
Web Developer
 ovidio...@gmail.com
  ovidiomari...@itjp.net.br
 ITJP - itjp.net.br
   83   8826 9088 - Oi2py
   83   9334 0266 - Claro
Brasil


Re: [web2py] Improving scaffolding application

2012-04-06 Thread Hironori Kawano
Hi, Bruno

Thank you for your reply.
I have been reading your book and it's really great!
Hope to create a lot of services with web2py
I am using Safari Online to read it and just gave you a good review!

Thanks.

Hiro

On Tuesday, April 3, 2012 2:05:46 PM UTC+9, rochacbruno wrote:

 This is talking about your custom application, not the admin.

 Go to the create new simple application form on admin interface (or do 
 it by command line using $ python web2py.py -S mynewapp -M)

 inside your app you have to create the files needed.

 web2py/applications/*mynewapp*/models/0.py



 Hi, actually, I started reading *web2py Application Development Cookbook*
 *
 *
 It talks about improving default scaffolding application by writing 0.py 
 file.
 My question is, where do I touch to change scaffolding application?

 Am I to create 0.py in models in newly created application or is it 
 talking about 0.py file under *applications\admin\models* ?

 I know the questions sounds specific to a particular book but I would 
 like to know how I can override scaffolding app.

 Please help me with your expertise.

  




 -- 

 Bruno Rocha
 [http://rochacbruno.com.br]



[web2py] How to accept authentication from external service

2012-04-06 Thread JimK
I'm looking for a way to accept authentication from an external service 
within a web2py app.  Specifically, I'd like my app to accept 
authentication from a site like AppSumo or Groupon where they help sell the 
product for you, accept the payment and then redirect to my web2py app.  
Normally, my users register via Janrain and redirected to the payment page 
since they haven't paid yet.

Here's a use-case flow:
- User sees a deal for my app on AppSumo.
- User buys the deal on AppSumo.
- AppSumo redirects the user to my web2py app.
- A web2py user account is created as a paid customer (e.g. not redirected 
to the payment form).


Thanks in advance,

Jim


Re: [web2py] nice to introduce new button in grid

2012-04-06 Thread Anthony


 I wonder if it wouldn't be straightforward to have a version of BEAUTIFY 
 (arguments? alternative version called DUMP?) that would suppress this 
 behavior and give us a dump of the object down to lower-level structures: 
 dicts, lists, etc? Or is there already some better way to explore the 
 structure of a FORM or SQLTABLE or whatever?

I usually just look at the serialized HTML to figure out the structure. 
What kind of output do you suggest?

Anthony 


Re: [web2py] nice to introduce new button in grid

2012-04-06 Thread Jonathan Lundell
On Apr 6, 2012, at 6:14 PM, Anthony wrote:
 I wonder if it wouldn't be straightforward to have a version of BEAUTIFY 
 (arguments? alternative version called DUMP?) that would suppress this 
 behavior and give us a dump of the object down to lower-level structures: 
 dicts, lists, etc? Or is there already some better way to explore the 
 structure of a FORM or SQLTABLE or whatever?
 
 I usually just look at the serialized HTML to figure out the structure. What 
 kind of output do you suggest?
 

What BEAUTIFY would give you if it were fed a structure of dict/list/primitives 
without any special xml methods. Example: what you get when you beautify 
request  response. It might be enough to have an option to BEAUTIFY that 
suppressed calling .xml(), though it might be worth making exceptions in some 
cases.

My case: I'm using SQLFORM.grid to display a table that's cached by memcache 
for the client (not for the grid). I'd like to add a button to delete the item 
from the cache. Easy enough to make it separate, but it'd look better 
integrated with the other buttons that are already there.

[web2py] Re: auth_user reference to other table

2012-04-06 Thread Anthony


 i like to ask the user for his country. So I added a field country to the 
 auth_user table. but I like it to be a referenz to db.country which I 
 define later in the db.py file. for some reason I get an error message when 
 trying to do that.


Define it as Field('country', 'reference country') instead of 
Field('country', db.country) -- the latter won't work if db.country hasn't 
been defined yet.

Anthony 


[web2py] Re: AJAX form submission using CRUD in web2py

2012-04-06 Thread Anthony



   Is it possible to validate CRUD form fields using ajax without 
 submitting the form in web2py?

 I have gone through the web2py online doc and have seen this link: 
 http://web2py.com/books/default/chapter/29/11#Ajax-form-submission So we 
 may do it using custom html. But I want to do it using CRUD. Also in crud 
 form,a field of type date shows calendar only after the validation fails 
 and user begins to enter the correct date. Can it be showed on the first 
 attempt itself??


Yes, you can use custom HTML for Crud forms, but by default, Crud will 
insert hidden _formname and _formkey fields in the form (the latter is used 
to protect against CSRF attacks). Because Crud will expect those fields to 
be submitted with the form, the form has to be created via Crud, and the 
form object has to be passed to the view so you can include those fields. 
See here http://web2py.com/books/default/chapter/29/7#Custom-forms for 
details on creating custom HTML for forms.
Note, to make it easier to submit the form via Ajax, you might consider 
putting the form in an Ajax component via LOAD() (see 
herehttp://web2py.com/books/default/chapter/29/12#Components
).

Anthony 


[web2py] redis support in Web2py

2012-04-06 Thread cyan

Hi group,

Could someone please let me know how much support exists for redis in 
web2py? I've come across 
this: 
http://code.google.com/p/web2py/source/browse/gluon/contrib/redis_cache.py, 
but not sure if redis is officially supported by web2py. If not, any 
timeline available? Many thanks.


[web2py] Re: redis support in Web2py

2012-04-06 Thread Massimo Di Pierro
I did not try it but I am told by the author it works. The more people use 
it the more it will be tested. If changes are necessary, we will take care 
of them.

On Friday, 6 April 2012 21:06:29 UTC-5, cyan wrote:


 Hi group,

 Could someone please let me know how much support exists for redis in 
 web2py? I've come across this: 
 http://code.google.com/p/web2py/source/browse/gluon/contrib/redis_cache.py, 
 but not sure if redis is officially supported by web2py. If not, any 
 timeline available? Many thanks.



[web2py] Re: export Data Abstraction Layer (DAL) to be used with Google Cloud SQL on App Engine

2012-04-06 Thread Matt
Hey Jarod,

I'm using it! 

The following hack - which I've documented in the issue I've raised below - 
seemed to fix some uploading issues.

http://code.google.com/p/web2py/issues/detail?id=746q=cloud

Hope that helps,
Matt

On Monday, 19 March 2012 16:03:25 UTC+13, Jarod G.R. Meng wrote:

 Hi, 

 I was trying to use web2py's DAL with Google Cloud SQL on App Engine, 
 but to no avail. The error seems to be because GAE doesn't allow any 
 manipulation of its filesystem which web2py's DAL module (gluon.dal) 
 needs to define a folder attribute (my understanding of the trouble 
 could be wrong). 

 I was wondering whether anyone has used web2py's DAL with Cloud SQL 
 before? 

 Any advice is welcome! 

 Jarod



[web2py] Re: auth_user reference to other table

2012-04-06 Thread Annet
Hi Anthony,

Define it as Field('country', 'reference country') instead of 
 Field('country', db.country) -- the latter won't work if db.country hasn't 
 been defined yet.


Should I use 'reference table' instead of db.table in all table definitions 
or just in the definition of tables that reference a table that hasn't been 
defined yet?


Kind regards,

Annet


[web2py] Re: represent in form

2012-04-06 Thread Annet
Hi Anthony,

I apologize for not giving a reply to your answer to my question.

I am talking about the second bullet in 
http://web2py.com/books/default/chapter/29/6#Record-representation.

   - To set the db.othertable.person.represent attribute for all fields 
   referencing this table. This means that SQLTABLE will not show references 
   by id but will use the format preferred representation instead.

This talks about SQLTABLE, which works alright. However, when I open a 
record in an SQLFORM, it doesn't use the format preferred representation.


Kind regards,

Annet.



[web2py] Re: reference or list:reference

2012-04-06 Thread Annet
HI Anthony,

Thanks for your reply. It enables me to make the right choice on reference 
fields.

Kind regards,

Annet