Re: [web2py] Re: CMS idea

2011-12-12 Thread Angelo Compagnucci
Wow!

It' really amazing! This is really innovative and never seen! We must build
something like an easy administrative interface around it!

Great Massimo!

2011/12/12 Massimo Di Pierro massimo.dipie...@gmail.com

 And here is the full source

 https://github.com/mdipierro/Plasmid

 On Dec 11, 11:14 pm, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:
  I made a better version and I made a video about it:
 
  http://vimeo.com/33513600
 
  Massimo
 
  On Dec 10, 10:55 am, Massimo Di Pierro massimo.dipie...@gmail.com
  wrote:
 
 
 
 
 
 
 
   notice that every edited page gets its own new url... with minor
   changes one could make it edit its own pages and display a list of
   pages edited by the same user:
 
   Example of workflow:
   1. point it to a page you like
   2. clone it
   3. edit it
   4. clone the clone
   5. edit it and add links to the other cloned page
   6. goto 4
 
   ...
 
   the editor could be replaced with a minimalist version of ckeditor so
   one gets some clientside html validation.
   one could add macros like $comments, $contactform, translated
   serverside.
 
   On Dec 10, 10:07 am, Massimo Di Pierro massimo.dipie...@gmail.com
   wrote:
 
Would be really nice if you could hack the jeditable in inject.js so
that when clicking on an image one could edit the src and when
clicking on a link one could edit the href as well as the content.
Although this could also be handled via some server-side re.sub.
 
On Dec 10, 2:12 am, Angelo Compagnucci angelo.compagnu...@gmail.com
 
wrote:
 
 Totally insane! I'm astonished!
 
 This could be really useful for a project I'm working on, it's
 really
 what I'm looking for!
 
 Thank you!
 
 2011/12/10 Massimo Di Pierro massimo.dipie...@gmail.com:
 
  I wrote this code which could be used to create a CMS.
 
  The app basically asks for the URL of any existing pubic page.
 It allows you to edit the text of that page in place (simply double click
 on it) and saves it locally as a modified copy of the original page. It
 gives you a unique URL for the spoofed site. Basically this can be used
 to take any page and turn it into a layout. The in-place edit is filtered
 server-side therefore we can imagine all kind of manipulations such as
 using a markup language, etc.
 
  It is setup as a working demo but it probably is illegal to run
 it on a public site as it is.
  Yet you can install it on your machine and play with it.
 
  There is lots of room for improvement.
 
  Can somebody help and modify it so that all html and css are
 also downloaded and moved into a static subfolder, instead of linked?
 
  Can somebody help and improve the popup textareas so that is
 looks better?
 
  Massimo
 
 --
 Profile:http://www.gild.com/compagnucciangelo
 Register on Gild:http://www.gild.com/referral/compagnucciangelo




-- 
Profile: http://www.gild.com/compagnucciangelo
Register on Gild: http://www.gild.com/referral/compagnucciangelo


[web2py] How to translate Django+GAE project for deferred.defer in web2py

2011-12-12 Thread Constantine Vasil
In my Django+GAE project I have these settings for deferred.defer in GAE.

What I need to change in order to have equivalent file for web2py?
django_wrapper_deferred.py is used from GAE deferred library
which I want to run in web2py environment.

=
app.yaml
=
- url: /_ah/queue/deferred
  script: django_wrapper_deferred.py
  login: admin

=
django_wrapper_deferred.py
=
from appengine_django import InstallAppengineHelperForDjango
InstallAppengineHelperForDjango(version=1.2)

from google.appengine.ext.webapp import util

from google.appengine.ext import deferred

def main():
import django
util.run_wsgi_app(deferred.application)

if __name__ == '__main__':
main() 


[web2py] Re: Getting table a to use as default string from field in table b

2011-12-12 Thread tsvim
Ok here's what I want to do.

I want a user to be able to create multiple tables of data, with some 
information about every table.
So instead of creating more tables, I figured I'll have one big table of 
data with a reference to the record in the table_settings database so I can 
return to the user only the information pertaining to his virtual table.
I'd like some of the fields in the data table to take their default value 
from the parent_table as I call it.
Rethinking my strategy, I think maybe it would be easier performance wise 
to scale by just setting up new tables per user.

Still, if I understand correctly I'd have to setup a AJAX call requesting 
the default values to prepopulate the fields with the defaults matching the 
table?
Or else maybe when creating the table for the user, I could enter the 
default values. I'm trying to imagine though how I would go around 
implementing this.


[web2py] Re: CMS idea

2011-12-12 Thread stefaan
Very, very nice idea.


[web2py] Special select widget returning form errors when submitted (no data)

2011-12-12 Thread Dominique
Hello All,

I need some help to have a widget work correctly.
BTW, once corrected, I think it could be useful to other users...

I built a widget to expose in a SELECT regions and their sub-regions 
('departement')  to choose.
For instance: a region A is divided into departement 11 and departement 12 
and so on.
The user can choose either a region or a specific departement (sub-region).

The widget works except that when submitted, the form returns errors:
r_name: no data.
Below is a working example to show the problem.

Could anybody help me having this widget work correctly without returning 
errors, please.
I would greatly appreciate your kind help.
Thanks a lot in advance.

Dominique


in the model:
db.define_table('region',
Field('r_name', 'string', length=250, required=True)
)   
db.define_table('departement',
Field('d_name', 'string', length=250, required=True),
Field('d_code', 'string', length=3, required=True),
Field('d_region', db.region)
)

def region_widget(f,v,_class= options): 

Widget  that shows regions and departements in a SELECT.
Can be used with SQLFORM and SQLFORM.factory
Usage:
db.region.r_name.widget = region_dptt_select_widget

region_dptt = db(db.region.id==db.departement.d_region)\
.select(db.region.r_name, db.region.id, 
db.departement.d_name, db.departement.d_code, db.departement.id, \
orderby=db.region.r_name, cache=(cache.ram,6))

def prepare_select(rows):

Creates a list of tuples to be used in the SELECT helper:
['Region A', OPTGROUP('SubRegion 1','SubRegion 2', 'SubRegion 3'),
'Region B', OPTGROUP('SubRegion 4','SubRegion 5', 'SubRegion 6')]

l_r=[]
for row in rows:
r = row.region.r_name
if row.region.r_name not in l_r:
l_r.append(row.region.r_name)
interm_list=[]
for reg in l_r:
   l_sr=[]
   for row in rows:
if reg == row.region.r_name:
reg_id = row.region.id
dep = row.departement.d_code + ' ' + 
row.departement.d_name
dep_id = row.departement.id
l_sr.append(OPTION(dep,_value=row.departement.d_code))  
   option_reg = OPTION(reg, _value= 'R'+str(reg_id))
   interm_list.append((option_reg,l_sr))
res=[]
for reg, l_sr in interm_list:
res.append(reg)
res.append(OPTGROUP(*l_sr))
return res
return SELECT(*prepare_select(region_dptt), 
  **dict(_name='region_to_search', _value=v, 
_id='region_to_search', _type = 'string', _class=options))

in the controller:
def test():
db.region.r_name.widget = region_widget
fields=['r_name']
labels = {'r_name':T('')}
form= SQLFORM(db.region, fields = fields, labels = labels)
a=None
if form.accepts(request.vars, session, formname='test_form', 
dbio=False):
a = form.vars
elif form.errors:
a = form.errors
return dict(form=form, a = a)

def insertions():# TO RUN one time
db.region.insert(r_name=Region A)
db.region.insert(r_name=Region B)
db.departement.insert(d_name=SubRegion 1, d_code=11, d_region=1)
db.departement.insert(d_name=SubRegion 2, d_code=12,  d_region=1)
db.departement.insert(d_name=SubRegion 3, d_code=21,  d_region=2)
db.departement.insert(d_name=SubRegion 4, d_code=22,  d_region=2)
db.departement.insert(d_name=SubRegion 5, d_code=25,  d_region=2)
db.departement.insert(d_name=SubRegion 6, d_code=26,  d_region=2) 
  


[web2py] (Very) small improvement suggestion

2011-12-12 Thread Omri Har-Shemesh
Hi All,

I have an extremely small suggestion to make life a tiny bit easier - in 
the beginning when starting web2py using python web2py.py there appears a 
dialog box.
In the dialog box, the password field has a binding on the 'Return' to 
start the server when the return key is pressed. I suggest adding a similar 
binding to the port field (and maybe IP field as well), since usually the 
focus is on the password field I fill it in first, and since I need a 
different port and change it next and it will be very helpful if it 
automatically opens the window after a return press.

the only change necessary is in the gluon.widget, around line 214 one has 
to add:
self.port_number.bind('Return', lambda e: self.start())

and maybe around line 202 the same for the ip field.

Thanks,
Omri


[web2py] migrate passwords from phpBB

2011-12-12 Thread thodoris
I am trying to migrate users from phpBB whose passwords have been encrypted 
with php_pass. There is a python module that mimics the functionality of 
php_pass and i am wondering what is the best way to override the default 
encryption of web2py. 

Is it sufficient to override CRYPT() using something like:

db.auth_user.password.requires = MyCrypt()

Thanks


[web2py] Re: js paypal shopping cart

2011-12-12 Thread newnomad
It uses javascript to create buyable items, and to handle the cart. For 
those who prefer to render items in html, and have only the cart work with 
clientside script, check out Simplecart. Those who prefer an all-serverside 
solution, extended with AJAX cart, might want to port jCart to web2py.

[web2py] Re: Getting table a to use as default string from field in table b

2011-12-12 Thread Anthony


 Still, if I understand correctly I'd have to setup a AJAX call requesting 
 the default values to prepopulate the fields with the defaults matching the 
 table?
 Or else maybe when creating the table for the user, I could enter the 
 default values. I'm trying to imagine though how I would go around 
 implementing this.


It depends on how you want to define the user experience. Assuming the user 
has to first select a table, there has to be some subsequent step on the 
server to determine the defaults for the selected table -- that can be done 
via Ajax or simply a new page load, but will require an additional request 
either way. I suppose another alternative is to send the defaults for all 
possible tables with the original page, but hidden, and then use Javascript 
to populate the defaults for the selected table.

Anthony 


[web2py] Re: migrate passwords from phpBB

2011-12-12 Thread Massimo Di Pierro
yes.

On Dec 12, 5:56 am, thodoris pasxi...@gmail.com wrote:
 I am trying to migrate users from phpBB whose passwords have been encrypted
 with php_pass. There is a python module that mimics the functionality of
 php_pass and i am wondering what is the best way to override the default
 encryption of web2py.

 Is it sufficient to override CRYPT() using something like:

 db.auth_user.password.requires = MyCrypt()

 Thanks


[web2py] Re: 500 internal server error after deployment of app and upgrade to latest version

2011-12-12 Thread Adnan Smajlovic

Thanks Anthony and Massimo.

I contacted the hosting company and they suggested to install the 
additional python instance. 

Can you please advise, how would I go about auto-starting web2py with a 
proper version of python then? 

Thanks,
Adnan

### Reference email from hosting company:
... there would essentially be two installs of python. One at 2.4.3 for 
Cpanel and the other python 2.7.2. What would change is the reference for 
the version. If coding a typical python program 

#/usr/bin/python which would link to #/usr/local/bin/python243 or similar 
If coding using 2.7.2 your top of code would look like 
#usr/bin/pyton27 which would be linked to the install of python272. They 
both would reside on the server. 

[web2py] MARKMIN indentation

2011-12-12 Thread lyn2py
Hi, how do I make nested lists with MARKMIN?
For example, indentation to create it?

+ Ordered Item
- Bulleted Item
+ Another Item
+ Sub Item
+ Sub 2
- Bulleted Again

Probably gives:

1. Ordered Item
- Bulleted Item
2. Another Item
a. Sub Item
b. Sub 2
* Bulleted Again

* represents the current (round black) bullet
- represents a different bullet type, perhaps (round white) bullet or
a dash-bullet

Idea stolen from google mail's nested list. :D

Thank you!


[web2py] Re: CMS idea

2011-12-12 Thread Ross Peoples
This would be great tool for moving an existing website to a web2py-based 
CMS. I remember having to move static HTML pages to WordPress a few years 
back and it was such a pain. This would be an excellent migration tool.

Re: [web2py] Re: about SQLFORM

2011-12-12 Thread Richard Vézina
Why not using web2py feature for this :

db[request.args(0)].entered_by.update=auth.user and auth.user.id
db[request.args(0)].input_date.update=request.now

request.args(0) = your table

So here you tell web2py to stamp user id (from auth_user) into entered_by
field of the given table only on update... You can define also the default
at the models level...

Richard

On Thu, Mar 10, 2011 at 9:47 AM, DenesL denes1...@yahoo.ca wrote:


 After an insert, form.vars.id will have the new record's id.

 But to avoid another DB access you can make the changes before the
 record is written using the onvalidation parameter in the accepts.

 @auth.requires_login()
 def new():
def set_name(form):
form.vars.name=author
return
 form = SQLFORM(db.autos, fields=['num'],
   labels={'num':'Number'},
   submit_button='GO',
   formstyle='divs')
 if form.accepts(request.vars, session,
onvalidation=set_name):
 response.flash = 'Yoh-ho-ho!'
elif form.errors:
response.flash = 'Bad-bad-bad!'
 else:
response.flash = 'Fill the form'
return dict(form=form)


 On Mar 10, 5:56 am, cyber vlad.mul...@gmail.com wrote:
  The code in controller:
  @auth.requires_login()
  def new():
  author=auth.user.username
  form = SQLFORM(db.autos, fields=['num'], labels={'num':'Number'},
  submit_button='GO', formstyle='divs')
  if form.accepts(request.vars, session):
  response.flash = 'It's OK!'
  elif form.errors:
  response.flash = 'There is an error!'
  else:
  response.flash = 'Fill the form!'
  rows=db(db.autos.id0).select()
  last_row=rows[-1]
  last_row.update_record(name=author)
  return dict(form=form)
 
  ***
  And the model piece of code is:
  import datetime
  now=datetime.datetime.today()
  db.define_table('autos',
  Field('num', length=8),
  Field('name'),
  Field('dtime', 'datetime', default=now),
  Field('enter', 'boolean', default=False),
  Field('enter_d'),
  Field('idk', 'boolean', default=False),
  Field('idk_d'),
  Field('svh', 'boolean', default=False),
  Field('svh_d'),
  Field('reg', 'boolean', default=False),
  Field('reg_d'),
  Field('out', 'boolean', default=False),
  Field('out_d')
  )
 
  *
  And view file is:
  {{extend 'layout.html'}}
  {{=form}}
 
  So, I want user to enter only value 'num' in db.autos.
  But user_name (for current user) and date_time info have to be updated
  automaticly after user presses GO button.
  Could you check my code? Is it correct?
 
  On 9 мар, 17:27, DenesL denes1...@yahoo.ca wrote:
 
   Can you show us your current code?.
 
   On Mar 9, 9:03 am, cyber vlad.mul...@gmail.com wrote:
 
Hi
 
How can I update new (just created) record in the table?
Table consists of several fields but in the form page user have to
enter only one value for one row.
So, I need insert in the current row not only this value but user
 name
and datetime.
I can insert first value but I have no idea of how to auto update new
row with required values.
 
Any ideas?
 
 



[web2py] Project Idea

2011-12-12 Thread Massimo Di Pierro
We could use this

https://github.com/amoffat/Inspect-Shell/blob/master/inspect_shell.py

together with a modified shell (from admin/controllers/shell.py) to
give a web based presence to any running python script.


[web2py] Re: MARKMIN indentation

2011-12-12 Thread Massimo Di Pierro
There is already an open issue about this. I approved it but did not
have the time to implement it. The minor complication is that it would
require changing not just markmin2html.py but also markmin2latex.

On Dec 12, 9:22 am, lyn2py lyn...@gmail.com wrote:
 Hi, how do I make nested lists with MARKMIN?
 For example, indentation to create it?

 + Ordered Item
     - Bulleted Item
 + Another Item
     + Sub Item
     + Sub 2
 - Bulleted Again

 Probably gives:

 1. Ordered Item
     - Bulleted Item
 2. Another Item
     a. Sub Item
     b. Sub 2
 * Bulleted Again

 * represents the current (round black) bullet
 - represents a different bullet type, perhaps (round white) bullet or
 a dash-bullet

 Idea stolen from google mail's nested list. :D

 Thank you!


[web2py] Re: CMS idea

2011-12-12 Thread Massimo Di Pierro
I agree. I think this should be a component of a larger project. Is
should include the ability to recursively download all linked pages
from the same domain (including html, css, js, images, etc.). It
should not take that much to do but one needs to decide what to do
with the downloaded data. I think all files should go into uploads
with permissions and html should go into database so it can be edited.
Not sure about css.

On Dec 12, 10:51 am, Ross Peoples ross.peop...@gmail.com wrote:
 This would be great tool for moving an existing website to a web2py-based
 CMS. I remember having to move static HTML pages to WordPress a few years
 back and it was such a pain. This would be an excellent migration tool.


Re: [web2py] Re: CMS idea

2011-12-12 Thread Javier Quarite
On Mon, Dec 12, 2011 at 12:33 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 I agree. I think this should be a component of a larger project. Is
 should include the ability to recursively download all linked pages
 from the same domain (including html, css, js, images, etc.). It
 should not take that much to do but one needs to decide what to do
 with the downloaded data. I think all files should go into uploads
 with permissions and html should go into database so it can be edited.
 Not sure about css.


So.. until now , it only gets a copy of a url (a copy of a html) and
translate it to web2py
right?

Javier


[web2py] Re: CMS idea

2011-12-12 Thread Anthony
Right now, it's just saving a static copy of the full HTML page, right? So, 
if you want to change the header or footer, for example, you'd have to 
change it on each individual page.

On Monday, December 12, 2011 12:33:12 PM UTC-5, Massimo Di Pierro wrote:

 I agree. I think this should be a component of a larger project. Is
 should include the ability to recursively download all linked pages
 from the same domain (including html, css, js, images, etc.). It
 should not take that much to do but one needs to decide what to do
 with the downloaded data. I think all files should go into uploads
 with permissions and html should go into database so it can be edited.
 Not sure about css.

 On Dec 12, 10:51 am, Ross Peoples ross.p...@gmail.com wrote:
  This would be great tool for moving an existing website to a web2py-based
  CMS. I remember having to move static HTML pages to WordPress a few years
  back and it was such a pain. This would be an excellent migration tool.



[web2py] Re: CMS idea

2011-12-12 Thread Massimo Di Pierro
Yes but the point is that eventually you could edit the text and write
$FOOTER and then same it as a template. I am thinking this should be
a piece of a CMS that can be used to create themes from existing
pages.

On Dec 12, 12:03 pm, Anthony abasta...@gmail.com wrote:
 Right now, it's just saving a static copy of the full HTML page, right? So,
 if you want to change the header or footer, for example, you'd have to
 change it on each individual page.







 On Monday, December 12, 2011 12:33:12 PM UTC-5, Massimo Di Pierro wrote:

  I agree. I think this should be a component of a larger project. Is
  should include the ability to recursively download all linked pages
  from the same domain (including html, css, js, images, etc.). It
  should not take that much to do but one needs to decide what to do
  with the downloaded data. I think all files should go into uploads
  with permissions and html should go into database so it can be edited.
  Not sure about css.

  On Dec 12, 10:51 am, Ross Peoples ross.p...@gmail.com wrote:
   This would be great tool for moving an existing website to a web2py-based
   CMS. I remember having to move static HTML pages to WordPress a few years
   back and it was such a pain. This would be an excellent migration tool.


Re: [web2py] Re: CMS idea

2011-12-12 Thread Javier Quarite
On Mon, Dec 12, 2011 at 1:14 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 Yes but the point is that eventually you could edit the text and write
 $FOOTER and then same it as a template. I am thinking this should be
 a piece of a CMS that can be used to create themes from existing
 pages.


Well, I was wrong. I was thinking of it as a web scraping tool :)
because ... 2 weeks ago I had some troubles with getting information from a
select list (a country/states list )
and I thought this could be used for that..

It's a good idea to use it as a tool to create themes as you said


Javier


[web2py] generate multiple form from a query

2011-12-12 Thread Richard
Hello,

Is there a better way of doing this :

def bunch_update_with_multi_form():
form0=None
form1=None
form3=None
form4=None
form5=None
form6=None
form7=None
form8=None
form9=None
form10=None
form11=None
form12=None
form13=None
form14=None
form15=None
form16=None
form17=None
form18=None
form19=None
form20=None
form21=None
form22=None
form23=None
form24=None
form25=None
form26=None
form27=None
form28=None
form29=None
form30=None

form_num = 0
for i in rows:
globals()['form%s'%form_num] = SQLFORM(db[request.args(0)])
for f in db[request.args(0)].fields:
if globals()['form%s'%form_num] != None:
globals()['form%s'%form_num].vars[f] =
i[request.args(0)][f]
if globals()['form%s'%form_num] != None:
if globals()['form%s'%form_num].process().accepted:
response.flash = '...'
elif globals()['form%s'%form_num].errors:
response.flash = 'form has errors'
form_num+=1
return
dict(table=table,form0=form0,form1=form1,form2=form2,form3=form3,form4=form4,form5=form5,form6=form6,form7=form7,form8=form8,form9=form9,form10=form10,form11=form11,form12=form12,form13=form13,form14=form14)

When using web2py shell I don't have any problem to execute my loops,
but in app I am getting only one correct form on 14...

I read in the book that SQLFORM is creating it on unique form
identifier but there is no example about that... Should I user SQLFORM
in view (put my loop there) to make it works :

Thanks

Richard


Re: [web2py] generate multiple form from a query

2011-12-12 Thread Anthony
web2py creates a hidden _formname field for each form. If there are 
multiple forms on the page, they must each have a unique _formname. By 
default, SQLFORM creates a _formname based on the table name and type of 
form (and possibly record number), but you can generate your own name via 
the 'formname' argument to form.accepts (or form.validate, or 
form.process). If you want to create update forms, though, you don't have 
to manually fill in the field values -- just pass the record as the second 
argument to SQLFORM. Also, in that case, you'll automatically get a unique 
_formname for each form because the record id becomes part of the 
_formname. 
See http://web2py.com/book/default/chapter/07#SQLFORM-and-insert/update/delete.

Also, rather than having a new variable for each form (i.e., form0, form1, 
etc.), which makes the code rather messy, why not just make a list of forms?

forms = []
forms.append(SQLFORM(...))  # add a new form to the list
form[i]  # to reference the i-th form

You might also consider creating each form as an Ajax component, or at 
least submitting the forms via Ajax, so the whole page of forms doesn't 
have to get re-processed when just a single form is submitted.

Anthony

On Monday, December 12, 2011 1:43:05 PM UTC-5, Richard wrote:

 Hello,

 Is there a better way of doing this :

 def bunch_update_with_multi_form():
 form0=None
 form1=None
 form3=None
 form4=None
 form5=None
 form6=None
 form7=None
 form8=None
 form9=None
 form10=None
 form11=None
 form12=None
 form13=None
 form14=None
 form15=None
 form16=None
 form17=None
 form18=None
 form19=None
 form20=None
 form21=None
 form22=None
 form23=None
 form24=None
 form25=None
 form26=None
 form27=None
 form28=None
 form29=None
 form30=None

 form_num = 0
 for i in rows:
 globals()['form%s'%form_num] = SQLFORM(db[request.args(0)])
 for f in db[request.args(0)].fields:
 if globals()['form%s'%form_num] != None:
 globals()['form%s'%form_num].vars[f] =
 i[request.args(0)][f]
 if globals()['form%s'%form_num] != None:
 if globals()['form%s'%form_num].process().accepted:
 response.flash = '...'
 elif globals()['form%s'%form_num].errors:
 response.flash = 'form has errors'
 form_num+=1
 return

 dict(table=table,form0=form0,form1=form1,form2=form2,form3=form3,form4=form4,form5=form5,form6=form6,form7=form7,form8=form8,form9=form9,form10=form10,form11=form11,form12=form12,form13=form13,form14=form14)

 When using web2py shell I don't have any problem to execute my loops,
 but in app I am getting only one correct form on 14...

 I read in the book that SQLFORM is creating it on unique form
 identifier but there is no example about that... Should I user SQLFORM
 in view (put my loop there) to make it works :

 Thanks

 Richard



[web2py] Re: generate multiple form from a query

2011-12-12 Thread Massimo Di Pierro
'N'+''.join('o' for in in range(100))+'!'

yes there is a better way :-)


def bunch_update_with_multi_form():

for k in range(31): locals()['form%s' % k] = None # not sure if
necessary
if not request.args(0) in [... list of allowed tables...]:
redirect(URL('error'))
tablename, table = request.args(0), db[request.args(0)]
response.flash = ''
formset = dict()
for k,item in enumerate(rows):
form _name= 'form%s' % k
form = formset[form_name] = SQLFORM(table)
for fieldname in table.fields:
 if fieldname in item[tablename]:
  form.vars[fieldname] = item[tablename][fieldname]
if form.process().accepted:
 response.flash += '...'
elif form.errors:
 response.flash += 'form %s has errors ' % form_name
return formset

On Dec 12, 12:43 pm, Richard ml.richard.vez...@gmail.com wrote:
 Hello,

 Is there a better way of doing this :

 def bunch_update_with_multi_form():
     form0=None
     form1=None
     form3=None
     form4=None
     form5=None
     form6=None
     form7=None
     form8=None
     form9=None
     form10=None
     form11=None
     form12=None
     form13=None
     form14=None
     form15=None
     form16=None
     form17=None
     form18=None
     form19=None
     form20=None
     form21=None
     form22=None
     form23=None
     form24=None
     form25=None
     form26=None
     form27=None
     form28=None
     form29=None
     form30=None

     form_num = 0
     for i in rows:
         globals()['form%s'%form_num] = SQLFORM(db[request.args(0)])
         for f in db[request.args(0)].fields:
             if globals()['form%s'%form_num] != None:
                 globals()['form%s'%form_num].vars[f] =
 i[request.args(0)][f]
         if globals()['form%s'%form_num] != None:
             if globals()['form%s'%form_num].process().accepted:
                 response.flash = '...'
             elif globals()['form%s'%form_num].errors:
                 response.flash = 'form has errors'
         form_num+=1
     return
 dict(table=table,form0=form0,form1=form1,form2=form2,form3=form3,form4=form 
 4,form5=form5,form6=form6,form7=form7,form8=form8,form9=form9,form10=form10 
 ,form11=form11,form12=form12,form13=form13,form14=form14)

 When using web2py shell I don't have any problem to execute my loops,
 but in app I am getting only one correct form on 14...

 I read in the book that SQLFORM is creating it on unique form
 identifier but there is no example about that... Should I user SQLFORM
 in view (put my loop there) to make it works :

 Thanks

 Richard


[web2py] Re: FluxFlex New Version Issue

2011-12-12 Thread Omi Chiba
Oh, it looks like solved !

On Dec 11, 10:12 pm, Ismael Serratos ialejandr...@gmail.com wrote:
 In fact, I'm trying to create new projects, and new appliances of web2py
 and with all happens the same..http://kodesideman.fluxflex.com/the new
 one, same error, and the old one kodeside.fluxflex.com now I'm getting a
 quota limit error. I'm wondering if is a fluxflex issue. I've already send
 them an email.







 On Sun, Dec 11, 2011 at 10:01 PM, ochib...@gmail.com wrote:
  **
  Hm... I've never seen this error before. Is this your welcome app and you
  said it's just installed ? If you haven't done anything maybe you can
  reinstall from scratch.
  Sent from my Verizon Wireless BlackBerry
  --
  *From: * Ismael Serratos ialejandr...@gmail.com
  *Sender: * web2py@googlegroups.com
  *Date: *Sun, 11 Dec 2011 21:38:32 -0600
  *To: *web2py@googlegroups.com
  *ReplyTo: * web2py@googlegroups.com
  *Subject: *Re: [web2py] Re: FluxFlex New Version Issue

  Now I'm having another issue, it doesn´t load anything, it was working but
  now when I get into my urlhttp://kodeside.fluxflex.comI get a server
  error.

  On Sun, Dec 11, 2011 at 9:35 PM, ochib...@gmail.com wrote:

  **
  Ismael,

  You need to access by https and password is your mysql password. This
  instruction should be written in readme.
  Sent from my Verizon Wireless BlackBerry
  --
  *From: * Ismael Serratos ialejandr...@gmail.com
  *Sender: * web2py@googlegroups.com
  *Date: *Sun, 11 Dec 2011 20:27:30 -0600
  *To: *web2py@googlegroups.com
  *ReplyTo: * web2py@googlegroups.com
  *Subject: *Re: [web2py] Re: FluxFlex New Version Issue

  And how can I do that?

  =( Sorry I've never used fluxflex.

  On Sun, Dec 11, 2011 at 8:18 PM, Massimo Di Pierro 
  massimo.dipie...@gmail.com wrote:

  You need to run it from shell once so that it creates the password
  file.

  On Dec 11, 8:14 pm, Ismael Serratos ialejandr...@gmail.com wrote:
   HI!! I just installed web2py on fluxlflex and I noticed it is the new
   web2py version (best for me :D).

   But just after installing it I tried to go to the admin interface and
  I get
   this error:

   admin disabled because unable to access password file

   Thanks!!


Re: [web2py] generate multiple form from a query

2011-12-12 Thread Richard Vézina
Thanks Anthony...

Here what I did so far...


 ## CONTROLLER
def bunch_review_with_multi_form():

# Getting lot and test from args or vars...
rows = db((db.lotns_lot_number.id == request.args(1))\
(db.lotns_sample.lot_number_id == db.lotns_lot_number.id)\
(db[request.args(0)].sample_id ==
db.lotns_sample.sample_id)).select\
(db.lotns_lot_number.lot_number_computed,
db.lotns_sample.sample_code, \
db[request.args(0)].ALL, orderby=db.lotns_sample.sample_code)

forms = []
flag = 0
for i in rows:
forms.append(SQLFORM(db[request.args(0)], i[request.args(0)].id))
forms[flag].process(detect_record_change=True)
if forms[flag].record_changed:
response.flash = T('form have changed between the time you
edited and submitted it, please have a look on the data again')
elif forms[flag].accepted:
session.flash = T('form accepted').capitalize()

#redirect(URL(request.application,c=request.controller,f='read',args=(request.args[0],request.args[1])))
else:
response.flash = T('please correct the form')
flag+=1
return dict(forms=forms)

###VIEW
{{extend 'layout_form.html'}}
{{for i in range(0,len(forms)):}}
{{=forms[i]}}
{{pass}}


I am confuse and I am not sure if my controller can works independently
with each form embeded into forms the way I wrote my controller function...
What's the way you were telling me to do??

Thanks

PS.: Is there any way I can make a multiple lines update with SQLFORM or
.grid or .smartgrid??

Richard

On Mon, Dec 12, 2011 at 2:40 PM, Anthony abasta...@gmail.com wrote:

 web2py creates a hidden _formname field for each form. If there are
 multiple forms on the page, they must each have a unique _formname. By
 default, SQLFORM creates a _formname based on the table name and type of
 form (and possibly record number), but you can generate your own name via
 the 'formname' argument to form.accepts (or form.validate, or
 form.process). If you want to create update forms, though, you don't have
 to manually fill in the field values -- just pass the record as the second
 argument to SQLFORM. Also, in that case, you'll automatically get a unique
 _formname for each form because the record id becomes part of the
 _formname. See
 http://web2py.com/book/default/chapter/07#SQLFORM-and-insert/update/delete
 .

 Also, rather than having a new variable for each form (i.e., form0, form1,
 etc.), which makes the code rather messy, why not just make a list of forms?

 forms = []
 forms.append(SQLFORM(...))  # add a new form to the list
 form[i]  # to reference the i-th form

 You might also consider creating each form as an Ajax component, or at
 least submitting the forms via Ajax, so the whole page of forms doesn't
 have to get re-processed when just a single form is submitted.

 Anthony

 On Monday, December 12, 2011 1:43:05 PM UTC-5, Richard wrote:

 Hello,

 Is there a better way of doing this :

 def bunch_update_with_multi_form()**:
 form0=None
 form1=None
 form3=None
 form4=None
 form5=None
 form6=None
 form7=None
 form8=None
 form9=None
 form10=None
 form11=None
 form12=None
 form13=None
 form14=None
 form15=None
 form16=None
 form17=None
 form18=None
 form19=None
 form20=None
 form21=None
 form22=None
 form23=None
 form24=None
 form25=None
 form26=None
 form27=None
 form28=None
 form29=None
 form30=None

 form_num = 0
 for i in rows:
 globals()['form%s'%form_num] = SQLFORM(db[request.args(0)])
 for f in db[request.args(0)].fields:
 if globals()['form%s'%form_num] != None:
 globals()['form%s'%form_num].**vars[f] =
 i[request.args(0)][f]
 if globals()['form%s'%form_num] != None:
 if globals()['form%s'%form_num].**process().accepted:
 response.flash = '...'
 elif globals()['form%s'%form_num].**errors:
 response.flash = 'form has errors'
 form_num+=1
 return
 dict(table=table,form0=form0,**form1=form1,form2=form2,form3=**
 form3,form4=form4,form5=form5,**form6=form6,form7=form7,form8=**
 form8,form9=form9,form10=**form10,form11=form11,form12=**
 form12,form13=form13,form14=**form14)

 When using web2py shell I don't have any problem to execute my loops,
 but in app I am getting only one correct form on 14...

 I read in the book that SQLFORM is creating it on unique form
 identifier but there is no example about that... Should I user SQLFORM
 in view (put my loop there) to make it works :

 Thanks

 Richard




[web2py] PyCon 2012 tutorials announced

2011-12-12 Thread Massimo Di Pierro
https://us.pycon.org/2012/schedule/lists/tutorials/

No web2py tutorial this year. Rejected. :-(



Re: [web2py] generate multiple form from a query

2011-12-12 Thread Richard Vézina
I would need a way to display my updated rows in line...

I just though that I could combine SQLTABLE and for each row of my rows
query I could embeded a submit button of each of my forms that I could
rename review... Putting all the form fields to hidden I could then make a
onvalidation process that update the fields I want to set the records to
reviewed... So the user has only to submit each row for review the whole
SQLTABLE diplayed rows...

What do you think?

Richard

On Mon, Dec 12, 2011 at 4:12 PM, Richard Vézina ml.richard.vez...@gmail.com
 wrote:

 Thanks Anthony...

 Here what I did so far...


  ## CONTROLLER
 def bunch_review_with_multi_form():

 # Getting lot and test from args or vars...
 rows = db((db.lotns_lot_number.id == request.args(1))\
 (db.lotns_sample.lot_number_id == db.lotns_lot_number.id)\
 (db[request.args(0)].sample_id ==
 db.lotns_sample.sample_id)).select\
 (db.lotns_lot_number.lot_number_computed,
 db.lotns_sample.sample_code, \
 db[request.args(0)].ALL, orderby=db.lotns_sample.sample_code)

 forms = []
 flag = 0
 for i in rows:
 forms.append(SQLFORM(db[request.args(0)], i[request.args(0)].id))
 forms[flag].process(detect_record_change=True)
 if forms[flag].record_changed:
 response.flash = T('form have changed between the time you
 edited and submitted it, please have a look on the data again')
 elif forms[flag].accepted:
 session.flash = T('form accepted').capitalize()

 #redirect(URL(request.application,c=request.controller,f='read',args=(request.args[0],request.args[1])))
 else:
 response.flash = T('please correct the form')
 flag+=1
 return dict(forms=forms)

 ###VIEW
 {{extend 'layout_form.html'}}
 {{for i in range(0,len(forms)):}}
 {{=forms[i]}}
 {{pass}}


 I am confuse and I am not sure if my controller can works independently
 with each form embeded into forms the way I wrote my controller function...
 What's the way you were telling me to do??

 Thanks

 PS.: Is there any way I can make a multiple lines update with SQLFORM or
 .grid or .smartgrid??

 Richard

 On Mon, Dec 12, 2011 at 2:40 PM, Anthony abasta...@gmail.com wrote:

 web2py creates a hidden _formname field for each form. If there are
 multiple forms on the page, they must each have a unique _formname. By
 default, SQLFORM creates a _formname based on the table name and type of
 form (and possibly record number), but you can generate your own name via
 the 'formname' argument to form.accepts (or form.validate, or
 form.process). If you want to create update forms, though, you don't have
 to manually fill in the field values -- just pass the record as the second
 argument to SQLFORM. Also, in that case, you'll automatically get a unique
 _formname for each form because the record id becomes part of the
 _formname. See
 http://web2py.com/book/default/chapter/07#SQLFORM-and-insert/update/delete
 .

 Also, rather than having a new variable for each form (i.e., form0,
 form1, etc.), which makes the code rather messy, why not just make a list
 of forms?

 forms = []
 forms.append(SQLFORM(...))  # add a new form to the list
 form[i]  # to reference the i-th form

 You might also consider creating each form as an Ajax component, or at
 least submitting the forms via Ajax, so the whole page of forms doesn't
 have to get re-processed when just a single form is submitted.

 Anthony

 On Monday, December 12, 2011 1:43:05 PM UTC-5, Richard wrote:

 Hello,

 Is there a better way of doing this :

 def bunch_update_with_multi_form()**:
 form0=None
 form1=None
 form3=None
 form4=None
 form5=None
 form6=None
 form7=None
 form8=None
 form9=None
 form10=None
 form11=None
 form12=None
 form13=None
 form14=None
 form15=None
 form16=None
 form17=None
 form18=None
 form19=None
 form20=None
 form21=None
 form22=None
 form23=None
 form24=None
 form25=None
 form26=None
 form27=None
 form28=None
 form29=None
 form30=None

 form_num = 0
 for i in rows:
 globals()['form%s'%form_num] = SQLFORM(db[request.args(0)])
 for f in db[request.args(0)].fields:
 if globals()['form%s'%form_num] != None:
 globals()['form%s'%form_num].**vars[f] =
 i[request.args(0)][f]
 if globals()['form%s'%form_num] != None:
 if globals()['form%s'%form_num].**process().accepted:
 response.flash = '...'
 elif globals()['form%s'%form_num].**errors:
 response.flash = 'form has errors'
 form_num+=1
 return
 dict(table=table,form0=form0,**form1=form1,form2=form2,form3=**
 form3,form4=form4,form5=form5,**form6=form6,form7=form7,form8=**
 form8,form9=form9,form10=**form10,form11=form11,form12=**
 form12,form13=form13,form14=**form14)

 When using web2py shell I don't have any problem to 

Re: [web2py] PyCon 2012 tutorials announced

2011-12-12 Thread Ovidio Marinho
 web2py does not have anything? We need to unite for a petition demanding
web2py this important event. Because they rejected?



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

Apóio



2011/12/12 Massimo Di Pierro mdipie...@cs.depaul.edu

 https://us.pycon.org/2012/schedule/lists/tutorials/

 No web2py tutorial this year. Rejected. :-(




Re: [web2py] PyCon 2012 tutorials announced

2011-12-12 Thread António Ramos
After the Bossie Award, web2py should be the main attraction...

2011/12/12 Ovidio Marinho ovidio...@gmail.com

 web2py does not have anything? We need to unite for a petition demanding
 web2py this important event. Because they rejected?



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

 Apóio



 2011/12/12 Massimo Di Pierro mdipie...@cs.depaul.edu

 https://us.pycon.org/2012/schedule/lists/tutorials/

 No web2py tutorial this year. Rejected. :-(





Re: [web2py] PyCon 2012 tutorials announced

2011-12-12 Thread joseph simpson
Or post multiple on-line tutorials that cover web2py.

Then create a communications plan to educate the target audience.

The information would be available, everyone with web access could share
the information.



On Mon, Dec 12, 2011 at 1:24 PM, Ovidio Marinho ovidio...@gmail.com wrote:

 web2py does not have anything? We need to unite for a petition demanding
 web2py this important event. Because they rejected?



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

 Apóio



 2011/12/12 Massimo Di Pierro mdipie...@cs.depaul.edu

 https://us.pycon.org/2012/schedule/lists/tutorials/

 No web2py tutorial this year. Rejected. :-(





-- 
Joe Simpson

Sent From My DROID!!


Re: [web2py] PyCon 2012 tutorials announced

2011-12-12 Thread Jim Steil
We could still organize an Open Spaces time to meet-up and talk about 
Web2py.  The Conference schedule is to be available on 1/1/12.  Anyone 
know if there were any web2py presentations proposed?


I am planning on attending this year and am looking forward to meeting 
other web2py users.


-Jim

On 12/12/2011 3:13 PM, Massimo Di Pierro wrote:

https://us.pycon.org/2012/schedule/lists/tutorials/

No web2py tutorial this year. Rejected. :-(



Re: [web2py] Re: web2py 1.99.3 is OUT

2011-12-12 Thread Richard Vézina
Web2py leitmotiv should be :

Web2py : always further...

:)

Richard

On Sun, Dec 11, 2011 at 8:26 PM, Anthony abasta...@gmail.com wrote:

 Massimo, shortly I'll be sending an updated 'examples' that fixes this as
 well as some other issues (courtesy of Chris May). The Bossie Award problem
 is resolved by moving the .announce div outside the statusbar div (perhaps
 it was nested inadvertently).

 Anthony


 On Sunday, December 11, 2011 3:58:00 PM UTC-5, Massimo Di Pierro wrote:

 Does this work?

 .announce { clear:both;position:absolute;**align:center;color:white;top:
 120px;font-weight:bold;text-**align:center;}

 your proposed chance breaks it for me with chrome.

 On Dec 11, 12:11 pm, Jim Gregory bikes...@gmail.com wrote:
  Changing the announce class specification on line 13 in examples.css
  from :
 
  .announce { position:absolute;align:**center;color:white;top:120px;**
 font-
  weight:bold;text-align:center;**}
 
  to:
  .announce {clear:both;color:white;top:**120px;font-weight:bold;text-
  align:center;}
 
  takes care of the problem for me.
 
  -Jim
 
  On Dec 10, 6:02 pm, Stefan Scholl ste...@no-spoon.de wrote:
 
 
 
 
 
 
 
   Massimo Di Pierro massimo@gmail.com wrote:
 
The new web site layout needs work but we put it out there hoping
 for
more feedback.
 
   The announcement 2011 BOSSIE AWARD FOR OPEN SOURCE DEVELOPMENT
   SOFTWARE is cut off and too far on the right in Firefox 9.0 Beta
   on Mac OS X 10.6.
 
   Haven't found a good solution, but if you add a br clear=all /
   before the announce DIV, the text is centered again.




[web2py] Re: PyCon 2012 tutorials announced

2011-12-12 Thread Massimo Di Pierro
I submitted two talk proposals and one tutorial proposal. I do not
know yet about talks.

Massimo


On Dec 12, 3:24 pm, Ovidio Marinho ovidio...@gmail.com wrote:
  web2py does not have anything? We need to unite for a petition demanding
 web2py this important event. Because they rejected?

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

                         Apóio

 2011/12/12 Massimo Di Pierro mdipie...@cs.depaul.edu







 https://us.pycon.org/2012/schedule/lists/tutorials/

  No web2py tutorial this year. Rejected. :-(


[web2py] Lock wait timeout exceeded; Try restarting transaction

2011-12-12 Thread frasse
Hi
I have two function one is running in controller when users access the
page (manageGame) and one is running as cron job (cleanDB). I am
geting   Lock wait timeout exceeded; Try restarting transaction
error in mysql database.
How can I avoid this problem ?

def manageGame():
now = datetime.datetime.now()
activeBigGame = db((db.games.LotteryDrawTime  now) 
(db.games.Type == 'Big Game')  (db.games.active == 'Yes')).select()
activeone_of_7 = db((db.games.Type == '1 of 7') (db.games.active
== 'Yes')  (db.games.LotteryDrawTime  now)).select()
db(db.games.LotteryDrawTime  now).update(active = 'No')
..




def cleanDB(now):
db((db.games.LotteryDrawTime  now) (db.games.numberPlayer ==
0) ).delete()



Thanx Frasse


Re: [web2py] Re: PyCon 2012 tutorials announced

2011-12-12 Thread Ovidio Marinho
  From what I see already set the tutorials, including basic Django, as
not present web2py and web2py to make django did most of the framework
developed inPython, I think it also should have policies in PyCon
preferences, as in all places.
   Finish select tutorials, these are the selected:

http://pycon.blogspot.com/2011/12/announcing-pycon-2012-tutorials.html



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

Apóio



2011/12/12 Massimo Di Pierro massimo.dipie...@gmail.com

 I submitted two talk proposals and one tutorial proposal. I do not
 know yet about talks.

 Massimo


 On Dec 12, 3:24 pm, Ovidio Marinho ovidio...@gmail.com wrote:
   web2py does not have anything? We need to unite for a petition demanding
  web2py this important event. Because they rejected?
 
 Ovidio Marinho Falcao Neto
  Web Developer
   ovidio...@gmail.com
ovidiomari...@itjp.net.br
   ITJP - itjp.net.br
 83   8826 9088 - Oi
 83   9334 0266 - Claro
  Brasil
 
  Apóio
 
  2011/12/12 Massimo Di Pierro mdipie...@cs.depaul.edu
 
 
 
 
 
 
 
  https://us.pycon.org/2012/schedule/lists/tutorials/
 
   No web2py tutorial this year. Rejected. :-(



[web2py] Re: PyCon 2012 tutorials announced

2011-12-12 Thread Anthony
On Monday, December 12, 2011 4:39:34 PM UTC-5, Massimo Di Pierro wrote:

 I submitted two talk proposals and one tutorial proposal. I do not
 know yet about talks.


Hopefully web2py will get a talk. I think talks probably generate more 
exposure anyway because you don't have to pay a separate extra fee or 
arrive a day or two early to attend.

Anthony


[web2py] Redirecting to a URL, but with changed html

2011-12-12 Thread peter
If I have a function as follows in default.py


def test():
redirect(url of some web page)

Then

app/default/test does open up the web page as if it was entered in the
url bar  of the browser.

If the function is

def test():
import urllib
url=url of some web page
f = urllib.urlopen(url)
s = f.read()
return s

Then it does kind of redirect, but it is no longer connected to the
session, and the defaults in the html are no longer correct.

Is it possible to alter the routine above to have the same
functionality as redirect?

The reason I want to be able to do this is that I want to edit s. So I
want to do a redirect, but with slightly edited html.

Any ideas
Thanks
Peter








[web2py] Re: Lock wait timeout exceeded; Try restarting transaction

2011-12-12 Thread Anthony
You probably need to add db.commit() to your cron job to commit the 
transaction. This is necessary in external scripts, but not in models, 
views, and controllers. 
See http://web2py.com/book/default/chapter/06#commit-and-rollback 
and http://web2py.com/book/default/chapter/04#Cron.

Anthony

On Monday, December 12, 2011 4:50:13 PM UTC-5, frasse wrote:

 Hi
 I have two function one is running in controller when users access the
 page (manageGame) and one is running as cron job (cleanDB). I am
 geting   Lock wait timeout exceeded; Try restarting transaction
 error in mysql database.
 How can I avoid this problem ?

 def manageGame():
 now = datetime.datetime.now()
 activeBigGame = db((db.games.LotteryDrawTime  now) 
 (db.games.Type == 'Big Game')  (db.games.active == 'Yes')).select()
 activeone_of_7 = db((db.games.Type == '1 of 7') (db.games.active
 == 'Yes')  (db.games.LotteryDrawTime  now)).select()
 db(db.games.LotteryDrawTime  now).update(active = 'No')
 ..


 def cleanDB(now):
 db((db.games.LotteryDrawTime  now) (db.games.numberPlayer ==
 0) ).delete()

 Thanx Frasse



Re: [web2py] generate multiple form from a query

2011-12-12 Thread Richard Vézina
Not as easy as I thought...

:(

Richard

On Mon, Dec 12, 2011 at 4:21 PM, Richard Vézina ml.richard.vez...@gmail.com
 wrote:

 I would need a way to display my updated rows in line...

 I just though that I could combine SQLTABLE and for each row of my rows
 query I could embeded a submit button of each of my forms that I could
 rename review... Putting all the form fields to hidden I could then make a
 onvalidation process that update the fields I want to set the records to
 reviewed... So the user has only to submit each row for review the whole
 SQLTABLE diplayed rows...

 What do you think?

 Richard


 On Mon, Dec 12, 2011 at 4:12 PM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 Thanks Anthony...

 Here what I did so far...


  ## CONTROLLER
 def bunch_review_with_multi_form():

 # Getting lot and test from args or vars...
 rows = db((db.lotns_lot_number.id == request.args(1))\
 (db.lotns_sample.lot_number_id == db.lotns_lot_number.id)\
 (db[request.args(0)].sample_id ==
 db.lotns_sample.sample_id)).select\
 (db.lotns_lot_number.lot_number_computed,
 db.lotns_sample.sample_code, \
 db[request.args(0)].ALL, orderby=db.lotns_sample.sample_code)

 forms = []
 flag = 0
 for i in rows:
 forms.append(SQLFORM(db[request.args(0)], i[request.args(0)].id))
 forms[flag].process(detect_record_change=True)
 if forms[flag].record_changed:
 response.flash = T('form have changed between the time you
 edited and submitted it, please have a look on the data again')
 elif forms[flag].accepted:
 session.flash = T('form accepted').capitalize()

 #redirect(URL(request.application,c=request.controller,f='read',args=(request.args[0],request.args[1])))
 else:
 response.flash = T('please correct the form')
 flag+=1
 return dict(forms=forms)

 ###VIEW
 {{extend 'layout_form.html'}}
 {{for i in range(0,len(forms)):}}
 {{=forms[i]}}
 {{pass}}


 I am confuse and I am not sure if my controller can works independently
 with each form embeded into forms the way I wrote my controller function...
 What's the way you were telling me to do??

 Thanks

 PS.: Is there any way I can make a multiple lines update with SQLFORM or
 .grid or .smartgrid??

 Richard

 On Mon, Dec 12, 2011 at 2:40 PM, Anthony abasta...@gmail.com wrote:

 web2py creates a hidden _formname field for each form. If there are
 multiple forms on the page, they must each have a unique _formname. By
 default, SQLFORM creates a _formname based on the table name and type of
 form (and possibly record number), but you can generate your own name via
 the 'formname' argument to form.accepts (or form.validate, or
 form.process). If you want to create update forms, though, you don't have
 to manually fill in the field values -- just pass the record as the second
 argument to SQLFORM. Also, in that case, you'll automatically get a unique
 _formname for each form because the record id becomes part of the
 _formname. See
 http://web2py.com/book/default/chapter/07#SQLFORM-and-insert/update/delete
 .

 Also, rather than having a new variable for each form (i.e., form0,
 form1, etc.), which makes the code rather messy, why not just make a list
 of forms?

 forms = []
 forms.append(SQLFORM(...))  # add a new form to the list
 form[i]  # to reference the i-th form

 You might also consider creating each form as an Ajax component, or at
 least submitting the forms via Ajax, so the whole page of forms doesn't
 have to get re-processed when just a single form is submitted.

 Anthony

 On Monday, December 12, 2011 1:43:05 PM UTC-5, Richard wrote:

 Hello,

 Is there a better way of doing this :

 def bunch_update_with_multi_form()**:
 form0=None
 form1=None
 form3=None
 form4=None
 form5=None
 form6=None
 form7=None
 form8=None
 form9=None
 form10=None
 form11=None
 form12=None
 form13=None
 form14=None
 form15=None
 form16=None
 form17=None
 form18=None
 form19=None
 form20=None
 form21=None
 form22=None
 form23=None
 form24=None
 form25=None
 form26=None
 form27=None
 form28=None
 form29=None
 form30=None

 form_num = 0
 for i in rows:
 globals()['form%s'%form_num] = SQLFORM(db[request.args(0)])
 for f in db[request.args(0)].fields:
 if globals()['form%s'%form_num] != None:
 globals()['form%s'%form_num].**vars[f] =
 i[request.args(0)][f]
 if globals()['form%s'%form_num] != None:
 if globals()['form%s'%form_num].**process().accepted:
 response.flash = '...'
 elif globals()['form%s'%form_num].**errors:
 response.flash = 'form has errors'
 form_num+=1
 return
 dict(table=table,form0=form0,**form1=form1,form2=form2,form3=**
 form3,form4=form4,form5=form5,**form6=form6,form7=form7,form8=**
 

[web2py] Re: How to translate Django+GAE project for deferred.defer in web2py

2011-12-12 Thread howesc
can you point it at web2py/gae_handler.py or base your deferred handler off 
of that?


Re: [web2py] generate multiple form from a query

2011-12-12 Thread Anthony


 forms = []
 flag = 0
 for i in rows:


Python tip -- instead of the above, try:

for flag, i in enumerate(rows):
 

 forms.append(SQLFORM(db[request.args(0)], i[request.args(0)].id))


It looks like your rows are actually the result of a multi-table join, so 
you might need to use SQLFORM.factory -- 
see http://web2py.com/book/default/chapter/07#One-form-for-multiple-tables.
 

 {{for i in range(0,len(forms)):}}
 {{=forms[i]}}


Another Python tip:

{{for form in forms:}}
{{=form}}

 

 I am confuse and I am not sure if my controller can works independently 
 with each form embeded into forms the way I wrote my controller function... 
 What's the way you were telling me to do??


At this point, I'm a bit confused too. :-)  Maybe consider putting each 
form in a separate LOAD component -- see 
http://web2py.com/book/default/chapter/13#Components. 


 PS.: Is there any way I can make a multiple lines update with SQLFORM or 
 .grid or .smartgrid??


I don't think so.

Anthony


[web2py] Re: Redirecting to a URL, but with changed html

2011-12-12 Thread Anthony
I guess that's not technically a redirect -- it's actually copying the 
other page and delivering the copy. What do you mean it's no longer 
connected to the session? The difficulty with copying a web page and 
delivering the copy is that it might contain some relative URL references 
(links as well as static resources) that will no longer work when being 
delivered from your server. You would have to rewrite the URLs to make them 
absolute (including URLs within any static files linked in the page) and/or 
copy the static resources to your own server. I'm assuming the other URL 
isn't another web2py app that you control, right?

Anyway, Massimo just released Plasmid, which does exactly this (clones an 
external page, converts relative to absolute 
references): https://github.com/mdipierro/Plasmid. You might be able to 
make use of that.

Anthony

On Monday, December 12, 2011 5:10:40 PM UTC-5, peter wrote:

 If I have a function as follows in default.py


 def test():
 redirect(url of some web page)

 Then

 app/default/test does open up the web page as if it was entered in the
 url bar  of the browser.

 If the function is

 def test():
 import urllib
 url=url of some web page
 f = urllib.urlopen(url)
 s = f.read()
 return s

 Then it does kind of redirect, but it is no longer connected to the
 session, and the defaults in the html are no longer correct.

 Is it possible to alter the routine above to have the same
 functionality as redirect?

 The reason I want to be able to do this is that I want to edit s. So I
 want to do a redirect, but with slightly edited html.

 Any ideas
 Thanks
 Peter




[web2py] Re: Redirecting to a URL, but with changed html

2011-12-12 Thread Anthony


  You would have to rewrite the URLs to make them absolute (including URLs 
 within any static files linked in the page)


Correction -- you probably don't have to worry about relative URLs within 
linked CSS files because they will be loaded relative to the CSS file URL 
(so only that URL needs to be converted to absolute). 


[web2py] Re: Redirecting to a URL, but with changed html

2011-12-12 Thread Constantine Vasil
Spend all week struggling with the same.

Basically you have to use browsers' 
window.location.replace and initialize 
the location via Python from your function.

Let say you are here:
http://www.mycoolapp.com/old_location
in the html you place the JavaScript
at the bottom before /body:

relocation_url = http://www.mycoolapp.com/old_location;
window.location.replace({{=relocation_url}})

When you want to redirect and the new html to replace the old one:
you initialize:
relocation_url = http://www.mycoolapp.com/new_location;

When the browser loads the page, close to the /body (end of page)
it sees actually window.location.replace
(http://www.mycoolapp.com/new_location;)

And it will reload the page with the new location in the browser bar 
and also the new html.

If you use just the web2py redirect, it loads the html but you see 
the old url in the browser address bar. If the new page is a form,
you fill out the form, hit the Submit button and nothing happens
because the browser sees the old address bar. Struggled all week with that
and only solution I found is that.

Good luck and give back to community ;)














[web2py] Re: Redirecting to a URL, but with changed html

2011-12-12 Thread Anthony
web2py redirect issues a standard http redirect, so the address will change 
in the browser address bar. I believe you were using jQuery Mobile and 
Ajax, which apparently introduces some complications (not specific to 
web2py). For a regular application, a standard redirect should work fine. 
In any case, I don't think peter is looking for just a redirect -- he wants 
to grab a copy of a page, edit it, and return the edited version -- quite a 
different task.

Anthony

On Monday, December 12, 2011 6:44:01 PM UTC-5, Constantine Vasil wrote:

 Spend all week struggling with the same.

 Basically you have to use browsers' 
 window.location.replace and initialize 
 the location via Python from your function.

 Let say you are here:
 http://www.mycoolapp.com/old_location
 in the html you place the JavaScript
 at the bottom before /body:

 relocation_url = http://www.mycoolapp.com/old_location;
 window.location.replace({{=relocation_url}})

 When you want to redirect and the new html to replace the old one:
 you initialize:
 relocation_url = http://www.mycoolapp.com/new_location;

 When the browser loads the page, close to the /body (end of page)
 it sees actually window.location.replace(
 http://www.mycoolapp.com/new_location;)

 And it will reload the page with the new location in the browser bar 
 and also the new html.

 If you use just the web2py redirect, it loads the html but you see 
 the old url in the browser address bar. If the new page is a form,
 you fill out the form, hit the Submit button and nothing happens
 because the browser sees the old address bar. Struggled all week with that
 and only solution I found is that.

 Good luck and give back to community ;)














[web2py] Re: Redirecting to a URL, but with changed html

2011-12-12 Thread Constantine Vasil
yes, redirect is little tricky ;) my solution is for ajax.

[web2py] Re: web2py 1.99.3 is OUT

2011-12-12 Thread Jim Karsten
SQLFORM.factory hidden fields are not working the same in 1.99.3 as in 
1.99.2. Here is a simple example 
form = SQLFORM.factory( 
Field('text_field'), 
Field('hidden_field', type='hidden', default='test'),) 

The hidden field is not hidden. Here is the html produced. The first is 
from 1.99.2, the second 1.99.3. 

input id=no_table_hidden_field class=hidden type=text value=test 
name=hidden_field style=display: none; 
input id=no_table_hidden_field class=string type=text value=test 
name=hidden_field 

If I use readable=False, writable=False, the field is hidden from the 
display but then no input is created for it. I have javascript code 
accessing the hidden input value. I can probably work around the problem 
using this syntax. 

form = SQLFORM.factory( 
Field('text_field'), 
hidden={'hidden_field': 'test'}) 

However, the input produced has no id or class attribute which I was using. 

input value=test name=hidden_field type=hidden 

Is what I'm seeing a bug or was the Field(... type='hidden'...) syntax 
never intended to work? 

[web2py] Re: web2py 1.99.3 is OUT

2011-12-12 Thread Anthony
I'm guessing that was never supposed to work. I think the 'type' argument 
to Field() is only supposed to take one of the DAL's pre-defined types. In 
the past this worked because without specifying a widget or one of the 
recognized field types, the field was given the string widget by default, 
and the string widget previously didn't assign a specific class, so just 
adopted the field's 'type' as the class. In 1.99.3, the string widget 
explicitly assigns a class=string, so now ignores the field's 'type'.

If you want to add hidden fields, you're supposed to do so via the 'hidden' 
argument -- see the end of this 
section: http://web2py.com/book/default/chapter/07#SQLFORM

Anthony

On Monday, December 12, 2011 8:21:42 PM UTC-5, Jim Karsten wrote:

 SQLFORM.factory hidden fields are not working the same in 1.99.3 as in 
 1.99.2. Here is a simple example 
 form = SQLFORM.factory( 
 Field('text_field'), 
 Field('hidden_field', type='hidden', default='test'),) 

 The hidden field is not hidden. Here is the html produced. The first is 
 from 1.99.2, the second 1.99.3. 

 input id=no_table_hidden_field class=hidden type=text value=test 
 name=hidden_field style=display: none; 
 input id=no_table_hidden_field class=string type=text value=test 
 name=hidden_field 

 If I use readable=False, writable=False, the field is hidden from the 
 display but then no input is created for it. I have javascript code 
 accessing the hidden input value. I can probably work around the problem 
 using this syntax. 

 form = SQLFORM.factory( 
 Field('text_field'), 
 hidden={'hidden_field': 'test'}) 

 However, the input produced has no id or class attribute which I was 
 using. 

 input value=test name=hidden_field type=hidden 

 Is what I'm seeing a bug or was the Field(... type='hidden'...) syntax 
 never intended to work? 



[web2py] Re: weird database behavior

2011-12-12 Thread Nik Go
I'm still stuck with this :(

I've already deleted my database to start from scratch but I am
encountering the same issue. For example, i deleted a record from
auth_account (in this case record #3) but when the I run the app and run a
trace with ipdb, my functions still return a row id 3, as if it wasn't
deleted. But verifying with the admin app, and checking the sqlite
database, there's no more id 3 (as to be expected). It's supposed to be
deleted and yet the function still return the old data!

db.define_table('see'
,Field('name',length=128)
,Field('classification', 'integer')
,Field('jurisdiction', 'reference see')
,Field('affinity', 'integer'))
db.define_table('auth_account'
,Field('subdomain', 'string')
,Field('see', 'reference see')
,Field('status',
'integer',requires=IS_IN_SET(settings.account_status,zero=None))
,Field('manager', 'integer', default=2))


In a function, I have this to check the value of a database
if not session.auth_account:
subdomain=request.env.http_host
session.auth_account=db((db.auth_account.subdomain==subdomain)\
(db.auth_account.status==4)(db.
auth_account.is_active==True))\
.select(db.auth_account.id,
db.auth_account.see,
db.auth_account.status).first()

and it returns: *Row {'status': 4, 'see': 11, 'id': 3}*

That is not correct since record id 3 has been deleted (from the admin
interface, confirmed by checking the sqlite table). And if I add a new
record (to replace id 3), the new record isn't found by the function. I
have restarted web2py, deleted the databases, restarted the browser,
changed browser but I get the same thing.

Under what conditions would this thing happen: a function returning a row
that doesn't exist?  What are the other things I should check?

On Monday, December 12, 2011, Nik Go wrote:

 And the other fields are still set to none, while their true values are
 otherwise.

 On Monday, December 12, 2011, Nik Go wrote:


 Here's a screenshot. Noticed that i edited the name toGJonathan but the
 response.flash  retrieves it as Jonathan

 On Monday, December 12, 2011, Nik Go wrote:

 I have a custom auth_user field that I could edit from admin (and I can
 verify that changes are actually written in the sqlite table) but every
 time I check the data from a view, the field value is always set to the
 initial default values, and not whatever's actually stored in the table.
 It's like the data is being retrieved from some cache I don't know about.

 I'm stumped. Has anyone experienced anything similar? This is the first
 time I encountered this. What gives?





[web2py] How to get JSON results?

2011-12-12 Thread lyn2py
I have followed the instructions from the book
http://web2py.com/book/default/chapter/09
But it is not working for me, please point out my errors!

#controller
@service.json
def search():
query = db.search.title.contains(request.args(0), all=True)
return db(query).select()

def call():
return service()

#browser calls
.../app/controller/search/title = Works
.../app/controller/call/json/search/title = empty JSON array

I also tried changing json to xml, but it returns empty


[web2py] Re: MARKMIN indentation

2011-12-12 Thread lyn2py
Thanks Massimo, MARKMIN is an excellent tool. Looking forward to this
new feature in MARKMIN.

On Dec 13, 1:30 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 There is already an open issue about this. I approved it but did not
 have the time to implement it. The minor complication is that it would
 require changing not just markmin2html.py but also markmin2latex.

 On Dec 12, 9:22 am, lyn2py lyn...@gmail.com wrote:







  Hi, how do I make nested lists with MARKMIN?
  For example, indentation to create it?

  + Ordered Item
      - Bulleted Item
  + Another Item
      + Sub Item
      + Sub 2
  - Bulleted Again

  Probably gives:

  1. Ordered Item
      - Bulleted Item
  2. Another Item
      a. Sub Item
      b. Sub 2
  * Bulleted Again

  * represents the current (round black) bullet
  - represents a different bullet type, perhaps (round white) bullet or
  a dash-bullet

  Idea stolen from google mail's nested list. :D

  Thank you!


[web2py] mysql relationship error

2011-12-12 Thread Stanislaw Smetanin
Hi community. I'm new to the web2py, but have a passion to learn it.
I'm a little stuck when start to define my models, I use MySQL engine, and 
have following models:

db = DAL('mysql://login:password@localhost/mydb') 
 #db = DAL('sqlite://sqlite.sqlite') 
 db.define_table('aphorizm',
 Field('body', 'text'),
 Field('author_id', db.author),
 Field('created_at'),
 Field('tags'),
 Field('like_count'),
 Field('slug'),
 Field('view_count'))
 db.define_table('author',
 Field('name'),
 Field('slug'),
 Field('created_at'),
 Field('user_id'))


but after successful saving I try the controller and have following 
ticket's details:

Traceback (most recent call last):
  File /var/www/web2py.catchword.mobi/gluon/restricted.py, line 194, in 
restricted
exec ccode in environment
  File /var/www/web2py.catchword.mobi/applications/catchword/models/db.py 
http://serv1.smetanin-online.name:8081/admin/default/edit/catchword/models/db.py,
 line 8, in module
Field('author_id', db.author),
  File /var/www/web2py.catchword.mobi/gluon/dal.py, line 4511, in __getattr__
return self[key]
  File /var/www/web2py.catchword.mobi/gluon/dal.py, line 4505, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: 'author'

so i can't figure out what's the problem in the relation between 'aphorizm' 
and 'author' models... I've defined the models according to the official 
reference.
Please notice, when I change the engine from MySQL to SQLite all goes fine, 
without any errors..


[web2py] Re: How to get JSON results?

2011-12-12 Thread Anthony
Does it work if you pass the request arg as an argument to the function:

@service.json
def search(keyword):
query = db.search.title.contains(keyword, all=True)
return db(query).select()

On Monday, December 12, 2011 9:44:50 PM UTC-5, lyn2py wrote:

 I have followed the instructions from the book
 http://web2py.com/book/default/chapter/09
 But it is not working for me, please point out my errors!

 #controller
 @service.json
 def search():
 query = db.search.title.contains(request.args(0), all=True)
 return db(query).select()

 def call():
 return service()

 #browser calls
 .../app/controller/search/title = Works
 .../app/controller/call/json/search/title = empty JSON array

 I also tried changing json to xml, but it returns empty



[web2py] Re: mysql relationship error

2011-12-12 Thread Anthony
In the 'aphorizm' table definition, you refer to db.author, but at that 
point, db.author doesn't yet exist. You have two options -- either reverse 
the order of the table definitions, or use the alternate syntax for 
defining a reference field: Field('author_id', 'reference author').

Anthony

On Monday, December 12, 2011 9:43:12 PM UTC-5, Stanislaw Smetanin wrote:

 Hi community. I'm new to the web2py, but have a passion to learn it.
 I'm a little stuck when start to define my models, I use MySQL engine, and 
 have following models:

 db = DAL('mysql://login:password@localhost/mydb') 
 #db = DAL('sqlite://sqlite.sqlite') 
 db.define_table('aphorizm',
 Field('body', 'text'),
 Field('author_id', db.author),
 Field('created_at'),
 Field('tags'),
 Field('like_count'),
 Field('slug'),
 Field('view_count'))
 db.define_table('author',
 Field('name'),
 Field('slug'),
 Field('created_at'),
 Field('user_id'))


 but after successful saving I try the controller and have following 
 ticket's details:

 Traceback (most recent call last):
   File /var/www/web2py.catchword.mobi/gluon/restricted.py, line 194, in 
 restricted
 exec ccode in environment
   File /var/www/web2py.catchword.mobi/applications/catchword/models/db.py 
 http://serv1.smetanin-online.name:8081/admin/default/edit/catchword/models/db.py,
  line 8, in module
 Field('author_id', db.author),
   File /var/www/web2py.catchword.mobi/gluon/dal.py, line 4511, in 
 __getattr__
 return self[key]
   File /var/www/web2py.catchword.mobi/gluon/dal.py, line 4505, in 
 __getitem__
 return dict.__getitem__(self, str(key))
 KeyError: 'author'

 so i can't figure out what's the problem in the relation between 
 'aphorizm' and 'author' models... I've defined the models according to the 
 official reference.
 Please notice, when I change the engine from MySQL to SQLite all goes 
 fine, without any errors..



[web2py] Re: How to get JSON results?

2011-12-12 Thread lyn2py
Yes it does. LOL. Sorry for the trouble!

On Dec 13, 11:04 am, Anthony abasta...@gmail.com wrote:
 Does it work if you pass the request arg as an argument to the function:

 @service.json
 def search(keyword):
     query = db.search.title.contains(keyword, all=True)
     return db(query).select()







 On Monday, December 12, 2011 9:44:50 PM UTC-5, lyn2py wrote:

  I have followed the instructions from the book
 http://web2py.com/book/default/chapter/09
  But it is not working for me, please point out my errors!

  #controller
  @service.json
  def search():
      query = db.search.title.contains(request.args(0), all=True)
      return db(query).select()

  def call():
      return service()

  #browser calls
  .../app/controller/search/title = Works
  .../app/controller/call/json/search/title = empty JSON array

  I also tried changing json to xml, but it returns empty


Re: [web2py] Re: error gluon/sqlhtml.py?

2011-12-12 Thread Martin Weissenboeck
yes, the new code is in 1.99.3

2011/12/7 Anthony abasta...@gmail.com

 I think it has already been changed in trunk -- can you check it there?


 On Wednesday, December 7, 2011 9:40:28 AM UTC-5, mweissen wrote:

 I think line 1566 of gluon/sqlhtml.py
 message = error or T('%(nrows)s records found' % dict(nrows=nrows))
 should be
 message = error or T('%(nrows)s records found') % dict(nrows=nrows)


 Regards, Martin




[web2py] Re: PyCon 2012 tutorials announced

2011-12-12 Thread mikech
Web2pyCon?  Maybe?