Re: [web2py] XML Webservice

2012-09-05 Thread hasan alnator
Dear Derek ,

What should i do then ??

Best Regards,

On Wed, Sep 5, 2012 at 2:01 AM, Derek  wrote:

> It is XML, but it doesn't have a doctype. So, when it gets to this
> character:  *’*  it fails to validate against UTF-8. It should probably
> be this:  charset=ISO-8859-1
>
>
> On Tuesday, September 4, 2012 2:15:11 AM UTC-7, Hassan Alnatour wrote:
>
>> Dear ALec ,
>>
>> when i go to the link i gave you before , i can see some XML data but i
>> dont understand what is the viewing problem you are talking about ? and why
>> wold a table filed interrupter Viewing as XML  as long as i am returning an
>> object that has all the date ?
>>
>> Best Regards,
>>
>> On Sun, Sep 2, 2012 at 12:47 PM, hasan alnator > > wrote:
>>
>>> Dear ALec ,
>>>
>>> when i go to the link i gave you before , i can see some XML data but i
>>> dont understand what is the viewing problem you are talking about ? and why
>>> wold a table filed interrupter Viewing as XML  as long as i am returning an
>>> object that has all the date ?
>>>
>>> Best Regards,
>>>
>>>
>>> On Sun, Sep 2, 2012 at 12:42 PM, Alec Taylor wrote:
>>>
 Hmm, try lower-case 'description'.

 Otherwise not sure what's causing the XML viewer problem.

 Also nowadays JSON is prefered over XML, as it's much less verbose;
 thus has a much lower overhead

 On Sun, Sep 2, 2012 at 7:39 PM, hasan alnator
  wrote:
 > Dear Alec ,
 >
 > What Do you mean with  preprocessing ?
 >
 > this is my db.py :
 >
 > # -*- coding: utf-8 -*-
 >
 > ##**##**
 #
 > ## This scaffolding model makes your app work on Google App Engine too
 > ## File is released under public domain and you can use without
 limitations
 > ##**##**
 #
 >
 > ## if SSL/HTTPS is properly configured and you want all HTTP requests
 to
 > ## be redirected to HTTPS, uncomment the line below:
 > # request.requires_https()
 >
 > if not request.env.web2py_runtime_**gae:
 > ## if NOT running on Google App Engine use SQLite or other DB
 > db = DAL('sqlite://storage.sqlite')
 > else:
 > ## connect to Google BigTable (optional
 'google:datastore://namespace'**)
 > db = DAL('google:datastore')
 > ## store sessions and tickets there
 > session.connect(request, response, db = db)
 > ## or store session in Memcache, Redis, etc.
 > ## from gluon.contrib.memdb import MEMDB
 > ## from google.appengine.api.memcache import Client
 > ## session.connect(request, response, db = MEMDB(Client()))
 >
 > ## by default give a view/generic.extension to all actions from
 localhost
 > ## none otherwise. a pattern can be 'controller/function.**extension'
 > response.generic_patterns = ['*'] if request.is_local else []
 > ## (optional) optimize handling of static files
 > # response.optimize_css = 'concat,minify,inline'
 > # response.optimize_js = 'concat,minify,inline'
 >
 > ##**##**
 #
 > ## Here is sample code if you need for
 > ## - email capabilities
 > ## - authentication (registration, login, logout, ... )
 > ## - authorization (role based authorization)
 > ## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
 > ## - old style crud actions
 > ## (more options discussed in gluon/tools.py)
 > ##**##**
 #
 >
 > from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
 > auth = Auth(db, hmac_key=Auth.get_or_create_**key())
 > crud, service, plugins = Crud(db), Service(), PluginManager()
 >
 > ## create all tables needed by auth if not custom tables
 > auth.define_tables()
 >
 > ## configure email
 > mail=auth.settings.mailer
 > mail.settings.server = 'logging' or 'smtp.gmail.com:587'
 > mail.settings.sender = 'y...@gmail.com'

 > mail.settings.login = 'username:password'
 >
 > ## configure auth policy
 > auth.settings.registration_**requires_verification = False
 > auth.settings.registration_**requires_approval = False
 > auth.settings.reset_password_**requires_verification = True
 >
 > ## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin,
 etc.
 > ## register with janrain.com, write your domain:api_key in
 > private/janrain.key
 > from gluon.contrib.login_methods.**rpx_account import use_janrain
 > use_janrain(auth,filename='**private/janrain.key')
 >
 > ##**##**
 #
 > ## Define your tables below (or better in another model file) for
 example
 > ##
 > ## >>> db.define_ta

Re: [web2py] Re: Bootstrap and custom forms and widgets

2012-09-05 Thread Alec Taylor
Thanks, set it to this and it's now working:

.form-actions {
background-color: #d9edf7;
border-top: 0;
padding: 0;
}

On Wed, Sep 5, 2012 at 3:58 AM, Anthony  wrote:

> I don't think it's a bug. The submit button is in a div with class
> "form-actions", and bootstrap.css defines the background color of that
> class as whiteSmoke. You can override that with your own CSS rule for the
> "form-actions" class.
>
> Anthony
>
>
> On Tuesday, September 4, 2012 1:18:13 PM UTC-4, Alec Taylor wrote:
>
>> Thanks, in that case I think I've found a bug in that formstyle setting.
>>
>> Around my submit button it has drawn a white rectangle; I've been able to
>> extract it into a test-case:  
>> http://jsfiddle.net/**AlecTaylor/7whPt/
>>
>>
>> On Tue, Sep 4, 2012 at 11:09 PM, Anthony  wrote:
>>
>>> Also, you can now create your own formstyle function, which should take
>>> the form object and a list of field tuples (each field tuple includes the
>>> id, label, controls, and comment for the field) and return the DOM you want
>>> displayed in the form (i.e., the part that goes inside ).
>>> Internally, this is how all the formstyles now work (each has its own
>>> function). To see how they work, check out the code:
>>> http://code.google.com/**p/web2py/source/browse/gluon/**sqlhtml.py#651
>>> .
>>>
>>> Anthony
>>>
>>>
>>> On Tuesday, September 4, 2012 7:49:45 AM UTC-4, Anthony wrote:

 For Crud, it's a setting:

 crud.settings.formstyle = 'bootstrap'

 Anthony

 On Tuesday, September 4, 2012 5:36:55 AM UTC-4, Alec Taylor wrote:
>
> Unfortunately that didn't work:
>  create() got an unexpected keyword
> argument 'formstyle'  update() got an
> unexpected keyword argument 'formstyle'
>
> On Tue, Sep 4, 2012 at 7:31 PM, Niphlod  wrote:
>
>> should be formstyle='bootstrap', the same way you use formstyle=divs
>> , ul, etc
>>
>> Il giorno martedì 4 settembre 2012 10:34:07 UTC+2, Alec Taylor ha
>> scritto:
>>>
>>> Thanks, but I can't seem to find anything in the release about how
>>> to use bootstrap with forms:  https://groups.google.com/**foru
>>> m/#!topic/web2py/**0Uk5b34LUsc
>>>
>>>
>>> (Note that I'm using crud.create and crud.update)
>>>
>>> On Tue, Sep 4, 2012 at 5:45 PM, Niphlod  wrote:
>>>
 the code is out there on 
 github.com/niphlod/w2p_**tvseries,
 but included in web2py 2.0.6 there is other code for 
 bootstrap-compatible
 forms

 Il giorno martedì 4 settembre 2012 05:03:59 UTC+2, Alec Taylor ha
 scritto:

> Hi Niphlod,
>
> Now that web2py 2 has been released, could you release the code
> for your form manipulation?
>
> Thanks a heap,
>
> Alec taylor
>
> On Sunday, May 20, 2012 2:48:57 AM UTC+10, Niphlod wrote:
>>
>> me too, but in a different way.
>>
>> I'm working on an app and waiting for web2py 2.0 to release it to
>> the public.
>> It contains a function able to serialize form in "bootstrap"
>> styles (i.e. form-horizontal, form-vertical, form-inline) 
>> With some additional work maybe that could be included to provide
>> more than the current 'table3cols', 'table2cols', 'divs', 'ul' 
>> styles of
>> the forms.
>>
>> Right now it's called into the view, i.e.:
>>
>> {{=twitter_form(form, 'form-vertical')}}
>>
>> Il giorno sabato 19 maggio 2012 11:10:30 UTC+2, Pystar ha scritto:
>>>
>>> Hi matt,
>>> I have been working extensively with bootstrap with web2py and I
>>> can say the approach you are taking is the best way.
>>>
>>> This is my solution
>>>
>>> #controller####3
>>>
>>> form = SQLFORM(db.blahblah)
>>> if form.accepts(request, session, hideerrror=True):
>>> blahblah
>>>
>>> the hideerror=True is what does the magic.
>>> It prevents your forms from displaying the error messages in the
>>> default position which is below the form field.
>>>
>>> In your views, you can now display your error messages by doing
>>>
>>> {{=form.**er**
>>> rors["post"]}}
>>>
>>> make sure you put the above in a conditional IF, ElSE block or
>>> else the errors will be displayed whether you have errors in your 
>>> form or
>>> not
>>>
>>> On Sunday, May 13, 2012 4:35:52 AM UTC+1, Matt wrote:

 Hi Everybody,

[web2py] CentOS Web2py IOError - Permission denied

2012-09-05 Thread webtest
I am running web2py on Centos and used the fedora shell script to do the 
installation. It did set all my folder/files as apache:apache, did the 
selinux configuration and such. I have the welcome and examples 
applications loaded.
When I run the examples application locally I get no errors (here this 
makes me think the DAL is set up fine and working) But when I access it 
online I get the internal error : unknown ticket created message.
Here is the error log it generates. It looks like a permissions issue but I 
already verified that all files as set as apache:apache , as it is in my 
httpd config and the folder/files have write and read permissions.
What could be the reason for this?

[Tue Sep 04 23:12:49 2012] [error] ERROR:web2py.cache:corrupted file 
/opt/web-apps/web2py/applications/examples/cache/cache.shelve, will try 
delete it!
[Tue Sep 04 23:12:49 2012] [error] WARNING:web2py.cache:unable to delete 
file /opt/web-apps/web2py/applications/examples/cache/cache.shelve
[Tue Sep 04 23:12:49 2012] [error] ERROR:web2py:Traceback (most recent call 
last):
[Tue Sep 04 23:12:49 2012] [error]   File 
"/opt/web-apps/web2py/gluon/restricted.py", line 205, in restricted
[Tue Sep 04 23:12:49 2012] [error] exec ccode in environment
[Tue Sep 04 23:12:49 2012] [error]   File 
"/opt/web-apps/web2py/applications/examples/compiled/models/menu.py", line 
63, in 
[Tue Sep 04 23:12:49 2012] [error]   File 
"/opt/web-apps/web2py/gluon/dal.py", line 6320, in define_table
[Tue Sep 04 23:12:49 2012] [error] polymodel=polymodel)
[Tue Sep 04 23:12:49 2012] [error]   File 
"/opt/web-apps/web2py/gluon/dal.py", line 710, in create_table
[Tue Sep 04 23:12:49 2012] [error] logfile = 
self.file_open(table._loggername, 'a')
[Tue Sep 04 23:12:49 2012] [error]   File 
"/opt/web-apps/web2py/gluon/dal.py", line 545, in file_open
[Tue Sep 04 23:12:49 2012] [error] fileobj = 
portalocker.LockedFile(filename,mode)
[Tue Sep 04 23:12:49 2012] [error]   File 
"/opt/web-apps/web2py/gluon/portalocker.py", line 120, in __init__
[Tue Sep 04 23:12:49 2012] [error] self.file = 
open(filename,mode.replace('w','a'))
[Tue Sep 04 23:12:49 2012] [error] IOError: [Errno 13] Permission denied: 
'/opt/web-apps/web2py/applications/examples/databases/sql.log'

-- 





[web2py] Re: web2py login and register forms as part of main page

2012-09-05 Thread Anthony
On Wednesday, September 5, 2012 2:46:49 AM UTC-4, Yebach wrote:
>
> Thank you for your fast reply
>
> With main page function you mean I include them in my mainpage.py 
> contorler?


It depends exactly where you want the forms. If on every page, then you 
need to define in a model and include in the layout. If just on the home 
page, then define the forms in the function for that page.

Another option is to include the forms in an Ajax component -- see 
http://web2py.com/books/default/chapter/29/12#Components. 
 

> OR do I just do a check if user is logged in and show the proper one if he 
> is?
>

If the user is logged in, presumably they won't need either form, right?

Anthony

-- 





[web2py] I can't display a thumbnail?

2012-09-05 Thread BlueShadow
Hi,
its driving me nuts. I used the code from web2pyslices to generate 
thumbnails:
db.py:
db.define_table('Images',
Field('Name',length=512),
Field('Image','upload'),
Field('thumb','upload',writable=False,readable=False),
format = '%(Name)s' # <<< important
)
db.define_table('Article',
Field('Title',length=512),
Field('Content','text'),
Field('Submitted','datetime',default=datetime.datetime.now()),
Field('Views','integer',default=0),
Field('TopImage',db.Images)
)
default.py:
def download():
return response.download(request, db)
def makeThumbnail(dbtable,ImageID,size=(200,200)):
try:
thisImage=db(dbtable.id==ImageID).select()[0]
import os, uuid
except: 
print "Error while loading libraries"
return
try:
from PIL import Image
except:
print "Error while Importing PIL library"
return
print request.folder + 'uploads/' + thisImage.Image
im=Image.open(request.folder + 'uploads/' + thisImage.Image)
im.thumbnail(size,Image.ANTIALIAS)
thumbName='uploads.thumb.%s.jpg' % (uuid.uuid4())
im.save(request.folder + 'uploads/' + thumbName,'jpeg')
thisImage.update_record(thumb=thumbName)
response.flash = 'Thumb created everything went fine'
return
def newImage():
dbtable = db.Images  #uploads table name
if len(request.args):
records = db(dbtable.id==request.args[0]).select()
if len(request.args) and len(records):
form = SQLFORM(dbtable, records[0], deletable=True)
else:
form = SQLFORM(dbtable)
if form.accepts(request.vars, session):
response.flash = 'Entry for Images Database accepted,start creating 
thumb'
makeThumbnail(dbtable,form.vars.id,(200,200))
elif form.errors:
response.flash = 'Error in Form for Images Database'
## Quick list just to demonstrate...
list = crud.select(dbtable)
return dict(form=form,list=list)
def Article():
id=request.vars.id
row=db(db.Article.id==id).select()
row[0].update_record(Views=row[0].Views+1)
if len(row)==0:
redirect(URL(r=request,f='Articles'))
return dict(Article=row[0])
article.html
{{extend 'layout.html'}}
 {{=Article.Title}} 


{{print URL(r=request, c='default', 
f='download',args=Article.TopImage.thumb)}}
{{=IMG(_src=URL(r=request, c='default', 
f='download',args=Article.TopImage.thumb),_style="display:block;")}}
 
 
{{=XML(Article.Content)}}
the thumbnail is generated by the code as it should. and it lands in the 
upload folder with the original image as it should. if I change the 
article.TopImage.thumb to .image it works perfectly. if I change it to 
.thumb again no image is displayed. the path and name I get from the print 
seem to be correct at least it is the same path as for the origianl image.
thanks for your help guys

-- 





[web2py] web2py login redirect

2012-09-05 Thread Yebach
Hello

My login function doesn't work. After I try to login i am redirected to 
user/user/profile instead back to my main page /school/index.html
Register works, everything
Also, if I login and enter the url where I should be redirected again I am 
redirected to /user/user/profile

any suggestion??

Thank you

-- 





[web2py] Re: web2py 2.0.2 is out

2012-09-05 Thread pradeep cs
Hi,

Is there any problem with windows binaries for XP, i tried installing the 
new version 2.0.7 on XP it is not working

*C:\web2py1\web2py>web2py.exe*
*The system cannot execute the specified program.*

regards
Pradeep

On Thursday, August 30, 2012 9:11:34 AM UTC+5:30, Massimo Di Pierro wrote:
>
> After 5 months. It is done. This is the most waited and the most 
> feature-packed release.
>
> I am sure we'll find some corners that need to be ironed but it is 
> considerably better than 1.99.7. It adds lot of new features and improves 
> many existing ones:
>
> - 57,000 new lines of code and closed 279 issues since 1.99.7.
> - Retrieving data from DB should be faster, in particular 
> select(cacheable=True)
> - Has a new scheduler, a built-in wiki, new language and pluralization 
> system, better markmin with oembed support and better scaffolding app, 
> increased security.
> - Lots of experimental features including GIS support, mongodb support, 
> built-in auth.wiki(), and more.
>
> Should be 100% backward compatible. If you run into any issue let us know 
> ASAP.
>
> I personally want to thank the major contributors to this release (in 
> alphabetic order)
> Alan, Andrew, Anthony, Bruno, Christian, Dave, Dominic, Iceberg, Jonathan, 
> Marc, Mariano, Marin, Martin, Mark, Michael, Michele, Niphlod, Patrick, 
> Vladyslav, 
> They spend many nights testing, coding, debugging at a very fast pace.
>
> Many many people have contributed.
>
> If your contribution has not been properly acknowledged please let us know 
> ASAP. It is probably an oversight.
>
>
> Massimo
>
>
> Detailed changelog
> ===
>
> ## 2.00.2
>
> ### DAL Improvements
>
> - Support for DAL(lazy_tables=True) and db.define_table(on_define=lambda 
> table:), thanks Jonathan
> - db(...).select(cacheable=True) make select 30% faster
> - db(...).select(cache=(cache.ram,3600)) now caches parsed data 100x faster
> - db(...).count(cache=(cache.ram,3600)) now supported
> - MongoDB support in DAL (experimental), thanks Mark Breedveld
> - geodal and spatialite, thanks Denes and Fran (experimental)
> - db.mytable._before_insert, _after_insert, _before_update, _after_update, 
> _before_delete. _after_delete (list of callbacks)
> - db(...).update_naive(...) same as update but ignores 
> table._before_update and table._after_update
> - DAL BIGINT support and DAL(...,bigint_id=True)
> - IS_IN_DB(..., distinct=True)
> - new syntax: db.mytable.insert(myuploadfield=open()), thank you 
> Iceberg
> - db(...).select(db.mytable.myfield.count(distinct=True))
> - db(db.a)._update(name=db(db.b.a==db.a.id).nested_select(db.b.id))
> - db.mytable.myfield.filter_in, filter_out
> - db.mytable._enable_record_versioning(db) adds versioning to this table
> - teradata adapter, thanks Andrew Willimott
> - experimental Sybase Adapter
> - added db.table.field.avg()
> - Support for Google App Engine projections, thanks Christian
> - Field(... 'upload', default=path) now accepts a path to a local file as 
> default value, if user does not upload a file. Relative path looks inside 
> current application folder, thanks Marin
> - executesql(...,fields=,columns=) allows parsing of results in Rows, 
> thanks Anthony
>
> ### Auth improvements
>
> - auth.enable_record_versioning(db)  adds full versioning to all tables
> - @auth.requires_login(otherwise=URL(...))
> - auth supports salt and compatible with third party data, thanks Dave 
> Stoll
> - CRYPT now defaults to pbkdf2(1000,20,sha1)
> - Built-in wiki with menu, tags, search, media, permissions. def index: 
> return auth.wiki()
> - auth.settings.everybody_group_id
> - allow storage of uploads on any PyFileSystem (including amazon)
>
> ### Form improvements
>
> - FORM.confirm('Are you sure?',{'Back':URL(...)})
> - SQLFORM.smartdictform(dict)
> - form.add_button(value,link)
> - SQLFORM.grid(groupby='...')
> - fixed security issue with SQLFORM.grid and SQLFORM.smartgrid
> - more export options in SQLFORM.grid and SQLFORM.smartgrid (html, xml, 
> csv, ...)
>
> ### Admin improvements
>
> - new admin pages: manage_students, bulk_regsiter, and progress reports
> - increased security in admin against CSRF
> - experimental Git integration
> - experimental OpenShift deployment
> - multi-language pluralization engine 
> - ace text web editor in admin
> - Ukrainian translations, thanks Vladyslav Kozlovskyy
> - Romanian translation for welcome, thanks ionel
> - support for mercurial 2.6, thanks Vlad
>
> ### Scheduler Improvements (thanks to niphlod, ykessler, dhx, toomim)
>
> - web2py.py -K myapp -X starts the myapp scheduler alongside the webserver
> - tasks are marked EXPIRED (if stop_time passed)
> - functions with no result don't end up in scheduler_run
> - more options: web2py.py -E -b -L
> - scheduler can now handle 10k tasks with 20 concurrent workers and with 
> no issues
> - new params:
> tasks can be found in the environment (no need to define the tasks 
> parameter)
> max_empty_runs kills the workers automatically

[web2py] Re: web2py login redirect

2012-09-05 Thread Anthony
First suggestion -- post your code. :-)

On Wednesday, September 5, 2012 8:15:40 AM UTC-4, Yebach wrote:
>
> Hello
>
> My login function doesn't work. After I try to login i am redirected to 
> user/user/profile instead back to my main page /school/index.html
> Register works, everything
> Also, if I login and enter the url where I should be redirected again I am 
> redirected to /user/user/profile
>
> any suggestion??
>
> Thank you
>

-- 





[web2py] Re: web2py login redirect

2012-09-05 Thread Yebach

my view user.html


{{=T( request.args(0).replace('_',' ').capitalize() )}}
{{=form}} 
{{if request.args(0)=='login':}} 
{{if not 'register' in auth.settings.actions_disabled:}}
{{=response.flash or ''}}
 {{=T('Register')}}
{{pass}} 
{{if not 'request_reset_password' in auth.settings.actions_disabled:}}  
{{=T('Lost 
Password')}} 
{{pass}} 
{{pass}}

http://www.algit.eu"; target="_blank">



my model user.py

from gluon.tools import Auth
import urllib

if (request.controller=='user' or request.controller=='school'  or 
request.controller=='timetable' and request.cookies.has_key('mycookie')):
response.generic_patterns = ['*'] if request.is_local else []
database = request.cookies['mycookie'].value
baza = DAL('postgres://postgres:postgres@localhost/' + database, 
migrate=True)
from gluon.tools import Mail

auth = Auth(baza, controller='user')



auth.settings.logout_next =  URL('school','index', 
vars=dict(school=database))
   

auth.settings.registration_requires_approval = True

   
auth.settings.register_onaccept=lambda form: 
mail.send(to=['vid.og...@algit.si'],
  subject='web2py registration',
  # If reply_to is omitted, then mail.settings.sender is used
  reply_to='u...@example.com',
  message='Kreiral se je nov uporabnik, ki ga je potrebno 
potrditi') 

auth.settings.expiration = 3600
auth.define_tables()

mail=Mail()
auth.settings.mailer=mail
mail.settings.server='smtp.gmail.com:587'
mail.settings.sender='x...@gmail.com'
mail.settings.login='x...@gmail.com:'



auth.messages.registration_pending = u'Registracija je v postopku 
odobritve. Ko bo vaš račun potrjen boste prejeli e-mail.'
auth.messages.invalid_login = 'Nepravilno geslo'
auth.messages.invalid_user = 'Uporabnik ne obstaja'

   
## configure auth policy

## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc.
## register with janrain.com, write your domain:api_key in 
private/janrain.key
from gluon.contrib.login_methods.rpx_account import use_janrain
use_janrain(auth,filename='private/janrain.key')


and my controler user.py
def user():
form = auth()
#auth.settings.controller="user"
return dict(form=form)


On Wednesday, September 5, 2012 2:40:09 PM UTC+2, Anthony wrote:
>
> First suggestion -- post your code. :-)
>
> On Wednesday, September 5, 2012 8:15:40 AM UTC-4, Yebach wrote:
>>
>> Hello
>>
>> My login function doesn't work. After I try to login i am redirected to 
>> user/user/profile instead back to my main page /school/index.html
>> Register works, everything
>> Also, if I login and enter the url where I should be redirected again I 
>> am redirected to /user/user/profile
>>
>> any suggestion??
>>
>> Thank you
>>
>

-- 





Re: [web2py] jQuery UI in 2.0.7

2012-09-05 Thread Richard Vézina
I had some problem with jQuery UI too, most were gone by using 1.8.16 ship
with web2py (uncomment line in the layout that point to google api).

Richard

On Wed, Sep 5, 2012 at 1:35 AM, Annet  wrote:

> I just upgraded to 2.0.7, this backward comaptibility issue still hasn't
> been fixed:
>
> The issue has something to do with web2py.
>
> In 1.99.7
> jQuery 1.7.1
> jQuery UI 1.8.20
>
> ... the date and auto complete field do work:
>
>  class="date hasDatepicker">
>
>  type="text" value="" name="locality" autocomplete="off" role="textbox"
> aria-autocomplete="list" aria-haspopup="true">
>
>
> In 2.0.6
> jQuery 1.7.1
> jQuery UI 1.8.20
>
> ... (same code, different web2py version) the date and autocomplete field
> do not work when they are in the same form. The date field get the
> hasDatepicker class and works. The auto complete field isn't set.
>
>  class="date input-xlarge hasDatepicker">
>
>
>  class="input-xlarge string">
>
>
> I have no idea why.
>
>
> Kind regards,
>
> Annet
>
> --
>
>
>
>

-- 





[web2py] web2py.js error

2012-09-05 Thread Johann Spies
Using Version 2.0.7 (2012-09-04 18:33:19) stable:

I get this error on the Firebug console:

Timestamp: 05/09/2012 15:22:54
Error: TypeError: doc.on is not a function
Source File: http://localhost:8000/init/static/js/web2py.js
Line: 42

The code:

function web2py_event_handlers() {
 var doc = jQuery(document)
 doc.on('click', '.flash', function(e){jQuery(this).fadeOut('slow'); e.
preventDefault();});
 doc.on('keyup', 'input.integer', function(){this.value=this.value.reverse
().replace(/[^0-9\-]|\-(?=.)/g,'').reverse();});
 doc.on('keyup', 'input.double, input.decimal', function(){this.value=this.
value.reverse().replace(/[^0-9\-\.,]|[\-](?=.)|[\.,](?=[0-9]*[\.,])/g,'').
reverse();});
 var confirm_message = (typeof w2p_ajax_confirm_message != 'undefined') 
?w2p_ajax_confirm_message 
: "Are you sure you want to delete this object?";
 doc.on('click', "input[type='checkbox'].delete", function(){if(this.checked
) if(!confirm(confirm_message)) this.checked=false;});
 doc.ajaxSuccess(function(e, xhr) {
 var redirect=xhr.getResponseHeader('web2py-redirect-location');
 if (redirect != null) {
 window.location = redirect;
 };
 });



I also noticed this morning that the flash ("Success") did not fade away 
after filling in a form.  I suspect it has something to do with this 
problem.


and 

Timestamp: 05/09/2012 15:22:54
Error: TypeError: a("body").on is not a function
Source File: http://localhost:8000/init/static/js/bootstrap.min.js
Line: 6


Regards
Johann

-- 





Re: [web2py] CentOS Web2py IOError - Permission denied

2012-09-05 Thread Jonathan Lundell
On 4 Sep 2012, at 9:22 PM, webtest  wrote:
> I am running web2py on Centos and used the fedora shell script to do the 
> installation. It did set all my folder/files as apache:apache, did the 
> selinux configuration and such. I have the welcome and examples applications 
> loaded.
> When I run the examples application locally I get no errors (here this makes 
> me think the DAL is set up fine and working) But when I access it online I 
> get the internal error : unknown ticket created message.
> Here is the error log it generates. It looks like a permissions issue but I 
> already verified that all files as set as apache:apache , as it is in my 
> httpd config and the folder/files have write and read permissions.
> What could be the reason for this?

If you're very sure about permissions, try disabling selinux, at least as an 
experiment. 

> 
> [Tue Sep 04 23:12:49 2012] [error] ERROR:web2py.cache:corrupted file 
> /opt/web-apps/web2py/applications/examples/cache/cache.shelve, will try 
> delete it!
> [Tue Sep 04 23:12:49 2012] [error] WARNING:web2py.cache:unable to delete file 
> /opt/web-apps/web2py/applications/examples/cache/cache.shelve
> [Tue Sep 04 23:12:49 2012] [error] ERROR:web2py:Traceback (most recent call 
> last):
> [Tue Sep 04 23:12:49 2012] [error]   File 
> "/opt/web-apps/web2py/gluon/restricted.py", line 205, in restricted
> [Tue Sep 04 23:12:49 2012] [error] exec ccode in environment
> [Tue Sep 04 23:12:49 2012] [error]   File 
> "/opt/web-apps/web2py/applications/examples/compiled/models/menu.py", line 
> 63, in 
> [Tue Sep 04 23:12:49 2012] [error]   File 
> "/opt/web-apps/web2py/gluon/dal.py", line 6320, in define_table
> [Tue Sep 04 23:12:49 2012] [error] polymodel=polymodel)
> [Tue Sep 04 23:12:49 2012] [error]   File 
> "/opt/web-apps/web2py/gluon/dal.py", line 710, in create_table
> [Tue Sep 04 23:12:49 2012] [error] logfile = 
> self.file_open(table._loggername, 'a')
> [Tue Sep 04 23:12:49 2012] [error]   File 
> "/opt/web-apps/web2py/gluon/dal.py", line 545, in file_open
> [Tue Sep 04 23:12:49 2012] [error] fileobj = 
> portalocker.LockedFile(filename,mode)
> [Tue Sep 04 23:12:49 2012] [error]   File 
> "/opt/web-apps/web2py/gluon/portalocker.py", line 120, in __init__
> [Tue Sep 04 23:12:49 2012] [error] self.file = 
> open(filename,mode.replace('w','a'))
> [Tue Sep 04 23:12:49 2012] [error] IOError: [Errno 13] Permission denied: 
> '/opt/web-apps/web2py/applications/examples/databases/sql.log'
> 
> 


-- 





[web2py] Re: web2py.js error

2012-09-05 Thread Anthony
Are you using a version of jQuery earlier than 1.7?

On Wednesday, September 5, 2012 9:27:02 AM UTC-4, Johann Spies wrote:
>
> Using Version 2.0.7 (2012-09-04 18:33:19) stable:
>
> I get this error on the Firebug console:
>
> Timestamp: 05/09/2012 15:22:54
> Error: TypeError: doc.on is not a function
> Source File: http://localhost:8000/init/static/js/web2py.js
> Line: 42
>
> The code:
>
> function web2py_event_handlers() {
>  var doc = jQuery(document)
>  doc.on('click', '.flash', function(e){jQuery(this).fadeOut('slow'); e.
> preventDefault();});
>  doc.on('keyup', 'input.integer', function(){this.value=this.value.reverse
> ().replace(/[^0-9\-]|\-(?=.)/g,'').reverse();});
>  doc.on('keyup', 'input.double, input.decimal', function(){this.value=this
> .value.reverse().replace(/[^0-9\-\.,]|[\-](?=.)|[\.,](?=[0-9]*[\.,])/g,''
> ).reverse();});
>  var confirm_message = (typeof w2p_ajax_confirm_message != 'undefined') 
> ?w2p_ajax_confirm_message 
> : "Are you sure you want to delete this object?";
>  doc.on('click', "input[type='checkbox'].delete", function(){if(this.
> checked) if(!confirm(confirm_message)) this.checked=false;});
>  doc.ajaxSuccess(function(e, xhr) {
>  var redirect=xhr.getResponseHeader('web2py-redirect-location');
>  if (redirect != null) {
>  window.location = redirect;
>  };
>  });
>
>
>
> I also noticed this morning that the flash ("Success") did not fade away 
> after filling in a form.  I suspect it has something to do with this 
> problem.
>
>
> and 
>
> Timestamp: 05/09/2012 15:22:54
> Error: TypeError: a("body").on is not a function
> Source File: http://localhost:8000/init/static/js/bootstrap.min.js
> Line: 6
>
>
> Regards
> Johann
>

-- 





[web2py] Re: web2py login redirect

2012-09-05 Thread Anthony
Looks like it's going to auth.settings.logged_url, which should only happen 
if you call the auth.register() function when the user is already logged in 
-- is that happening anywhere?

Also, by default, if you get to the login page via the navbar link from 
another page, you will be redirected back to that page. If you get to the 
login page via a direct link (e.g., a bookmark), then you will get 
redirected to auth.settings.login_next, which in your case would default to 
URL('user', 'index') -- so you would want to change it to URL('school', 
'index').

Anthony

On Wednesday, September 5, 2012 8:44:00 AM UTC-4, Yebach wrote:
>
>
> my view user.html
>
> 
> {{=T( request.args(0).replace('_',' ').capitalize() )}}
> {{=form}} 
> {{if request.args(0)=='login':}} 
> {{if not 'register' in auth.settings.actions_disabled:}}
> {{=response.flash or ''}}
>  {{=T('Register')}}
> {{pass}} 
> {{if not 'request_reset_password' in auth.settings.actions_disabled:}}  /> 
> {{=T('Lost 
> Password')}} 
> {{pass}} 
> {{pass}}
> 
> http://www.algit.eu"; target="_blank"> src="{{=URL(request.application,'static','images/algit.gif')}}"
> alt="Algit.eu" />
> 
> 
>
> my model user.py
>
> from gluon.tools import Auth
> import urllib
>
> if (request.controller=='user' or request.controller=='school'  or 
> request.controller=='timetable' and request.cookies.has_key('mycookie')):
> response.generic_patterns = ['*'] if request.is_local else []
> database = request.cookies['mycookie'].value
> baza = DAL('postgres://postgres:postgres@localhost/' + database, 
> migrate=True)
> from gluon.tools import Mail
> 
> auth = Auth(baza, controller='user')
> 
> 
> 
> auth.settings.logout_next =  URL('school','index', 
> vars=dict(school=database))
>
> 
> auth.settings.registration_requires_approval = True
> 
>
> auth.settings.register_onaccept=lambda form: mail.send(to=['
> vid@algit.si '],
>   subject='web2py registration',
>   # If reply_to is omitted, then mail.settings.sender is used
>   reply_to='u...@example.com ',
>   message='Kreiral se je nov uporabnik, ki ga je potrebno 
> potrditi') 
> 
> auth.settings.expiration = 3600
> auth.define_tables()
> 
> mail=Mail()
> auth.settings.mailer=mail
> mail.settings.server='smtp.gmail.com:587'
> mail.settings.sender='x...@gmail.com '
> mail.settings.login='x...@gmail.com:'
> 
> 
> 
> auth.messages.registration_pending = u'Registracija je v postopku 
> odobritve. Ko bo vaš račun potrjen boste prejeli e-mail.'
> auth.messages.invalid_login = 'Nepravilno geslo'
> auth.messages.invalid_user = 'Uporabnik ne obstaja'
> 
>
> ## configure auth policy
> 
> ## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, 
> etc.
> ## register with janrain.com, write your domain:api_key in 
> private/janrain.key
> from gluon.contrib.login_methods.rpx_account import use_janrain
> use_janrain(auth,filename='private/janrain.key')
>
>
> and my controler user.py
> def user():
> form = auth()
> #auth.settings.controller="user"
> return dict(form=form)
>
>
> On Wednesday, September 5, 2012 2:40:09 PM UTC+2, Anthony wrote:
>>
>> First suggestion -- post your code. :-)
>>
>> On Wednesday, September 5, 2012 8:15:40 AM UTC-4, Yebach wrote:
>>>
>>> Hello
>>>
>>> My login function doesn't work. After I try to login i am redirected to 
>>> user/user/profile instead back to my main page /school/index.html
>>> Register works, everything
>>> Also, if I login and enter the url where I should be redirected again I 
>>> am redirected to /user/user/profile
>>>
>>> any suggestion??
>>>
>>> Thank you
>>>
>>

-- 





Re: [web2py] Re: web2py.js error

2012-09-05 Thread Johann Spies
On 5 September 2012 15:44, Anthony  wrote:

> Are you using a version of jQuery earlier than 1.7?


Yes, I was trying to use jQuery-multiSelect which uses 1.6.4. Removing the
following lines from my view:

  {{
#  response.files.append("
http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js";)
#  response.files.append("
http://ajax.googleapis.com/ajax/libs/themes/ui-darkness/jquery-ui.css";)
#   response.files.append(URL('static', 'js/jquery.bgiframe.min.js'))
#  response.files.append(URL('static', 'css/jquery.multiSelect.css'))
}}

Stops the complaint by firebug and disables any multiselect editing options
for me.  It practically makes the multiselect field uneditable.

:(


Is there a solution for a multiselect-field?

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





[web2py] Re: Limit Length column

2012-09-05 Thread Mandar Vaze
Using maxtextlengths optional parameter partially helps.
http://web2py.com/books/default/chapter/29/07?search=maxtextlengths

I say partially because this param controls how many characters are 
displayed in the column (Only those many characters are sent by the server)
If one has too many wide columns, result could be ugly, especially buttons 
in last column are now shown vertically - depending on screen size etc.

I wish there was way to control the column width via web2py

-Mandar

On Tuesday, September 4, 2012 12:35:55 AM UTC+5:30, Ovidio Marinho wrote:
>
> how to limit the size of columns in sqlform.grid
> 25 
>  40 
>   15
> 1 col lenght 25   
> === =
> 2 col lenght 40
> 3 col lenght 15
> etc...
>
>
>   
>
>
>Ovidio Marinho Falcao Neto
> Web Developer
>  ovid...@gmail.com  
>   ovidio...@itjp.net.br 
>  ITJP - itjp.net.br
>83   8826 9088 - Oi
>83   9334 0266 - Claro
> Brasil
>   
>
>  

-- 





[web2py] Re: I can't display a thumbnail?

2012-09-05 Thread villas
def Article():
id=request.vars.id
row=db(db.Article.id==id).select()

Not sure how you get the Images filenames.  The code does not seem join the 
Article to the Image?

Maybe something like: 
def Article():
id=request.vars.id  #  <<-- only ok for testing
row=db((db.Article.id==id)&(db.Article.TopImage==db.Images.id)).select()



Regards, David

On Wednesday, September 5, 2012 12:35:26 PM UTC+1, BlueShadow wrote:
>
> Hi,
> its driving me nuts. I used the code from web2pyslices to generate 
> thumbnails:
> db.py:
> db.define_table('Images',
> Field('Name',length=512),
> Field('Image','upload'),
> Field('thumb','upload',writable=False,readable=False),
> format = '%(Name)s' # <<< important
> )
> db.define_table('Article',
> Field('Title',length=512),
> Field('Content','text'),
> Field('Submitted','datetime',default=datetime.datetime.now()),
> Field('Views','integer',default=0),
> Field('TopImage',db.Images)
> )
> default.py:
> def download():
> return response.download(request, db)
> def makeThumbnail(dbtable,ImageID,size=(200,200)):
> try:
> thisImage=db(dbtable.id==ImageID).select()[0]
> import os, uuid
> except: 
> print "Error while loading libraries"
> return
> try:
> from PIL import Image
> except:
> print "Error while Importing PIL library"
> return
> print request.folder + 'uploads/' + thisImage.Image
> im=Image.open(request.folder + 'uploads/' + thisImage.Image)
> im.thumbnail(size,Image.ANTIALIAS)
> thumbName='uploads.thumb.%s.jpg' % (uuid.uuid4())
> im.save(request.folder + 'uploads/' + thumbName,'jpeg')
> thisImage.update_record(thumb=thumbName)
> response.flash = 'Thumb created everything went fine'
> return
> def newImage():
> dbtable = db.Images  #uploads table name
> if len(request.args):
> records = db(dbtable.id==request.args[0]).select()
> if len(request.args) and len(records):
> form = SQLFORM(dbtable, records[0], deletable=True)
> else:
> form = SQLFORM(dbtable)
> if form.accepts(request.vars, session):
> response.flash = 'Entry for Images Database accepted,start 
> creating thumb'
> makeThumbnail(dbtable,form.vars.id,(200,200))
> elif form.errors:
> response.flash = 'Error in Form for Images Database'
> ## Quick list just to demonstrate...
> list = crud.select(dbtable)
> return dict(form=form,list=list)
> def Article():
> id=request.vars.id
> row=db(db.Article.id==id).select()
> row[0].update_record(Views=row[0].Views+1)
> if len(row)==0:
> redirect(URL(r=request,f='Articles'))
> return dict(Article=row[0])
> article.html
> {{extend 'layout.html'}}
>  {{=Article.Title}} 
> 
> 
> {{print URL(r=request, c='default', 
> f='download',args=Article.TopImage.thumb)}}
> {{=IMG(_src=URL(r=request, c='default', 
> f='download',args=Article.TopImage.thumb),_style="display:block;")}}
>  
>  
> {{=XML(Article.Content)}}
> the thumbnail is generated by the code as it should. and it lands in the 
> upload folder with the original image as it should. if I change the 
> article.TopImage.thumb to .image it works perfectly. if I change it to 
> .thumb again no image is displayed. the path and name I get from the print 
> seem to be correct at least it is the same path as for the origianl image.
> thanks for your help guys
>
>

-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-05 Thread Alan Etkin

>
> Does NOT seem to work.  computed field is still not visible.
>
>
Same problem with this version: 2.0.7 (2012-09-04 18:33:19) stable (updated 
with hg)

I think we should open an issue in the google code page.

-- 





[web2py] Re: web2py 2.0.2 is out

2012-09-05 Thread Massimo Di Pierro
Looks like it is a DLL issue. Some DLLs are missing. I will try rebuild it 
today but I am not sure which one is missing.

Has anybody successfully used the windows version 2.0.x?

Massimo

On Wednesday, 5 September 2012 07:29:51 UTC-5, pradeep cs wrote:
>
> Hi,
>
> Is there any problem with windows binaries for XP, i tried installing the 
> new version 2.0.7 on XP it is not working
>
> *C:\web2py1\web2py>web2py.exe*
> *The system cannot execute the specified program.*
>
> regards
> Pradeep
>
> On Thursday, August 30, 2012 9:11:34 AM UTC+5:30, Massimo Di Pierro wrote:
>>
>> After 5 months. It is done. This is the most waited and the most 
>> feature-packed release.
>>
>> I am sure we'll find some corners that need to be ironed but it is 
>> considerably better than 1.99.7. It adds lot of new features and improves 
>> many existing ones:
>>
>> - 57,000 new lines of code and closed 279 issues since 1.99.7.
>> - Retrieving data from DB should be faster, in particular 
>> select(cacheable=True)
>> - Has a new scheduler, a built-in wiki, new language and pluralization 
>> system, better markmin with oembed support and better scaffolding app, 
>> increased security.
>> - Lots of experimental features including GIS support, mongodb support, 
>> built-in auth.wiki(), and more.
>>
>> Should be 100% backward compatible. If you run into any issue let us know 
>> ASAP.
>>
>> I personally want to thank the major contributors to this release (in 
>> alphabetic order)
>> Alan, Andrew, Anthony, Bruno, Christian, Dave, Dominic, Iceberg, 
>> Jonathan, Marc, Mariano, Marin, Martin, Mark, Michael, Michele, Niphlod, 
>> Patrick, Vladyslav, 
>> They spend many nights testing, coding, debugging at a very fast pace.
>>
>> Many many people have contributed.
>>
>> If your contribution has not been properly acknowledged please let us 
>> know ASAP. It is probably an oversight.
>>
>>
>> Massimo
>>
>>
>> Detailed changelog
>> ===
>>
>> ## 2.00.2
>>
>> ### DAL Improvements
>>
>> - Support for DAL(lazy_tables=True) and db.define_table(on_define=lambda 
>> table:), thanks Jonathan
>> - db(...).select(cacheable=True) make select 30% faster
>> - db(...).select(cache=(cache.ram,3600)) now caches parsed data 100x 
>> faster
>> - db(...).count(cache=(cache.ram,3600)) now supported
>> - MongoDB support in DAL (experimental), thanks Mark Breedveld
>> - geodal and spatialite, thanks Denes and Fran (experimental)
>> - db.mytable._before_insert, _after_insert, _before_update, 
>> _after_update, _before_delete. _after_delete (list of callbacks)
>> - db(...).update_naive(...) same as update but ignores 
>> table._before_update and table._after_update
>> - DAL BIGINT support and DAL(...,bigint_id=True)
>> - IS_IN_DB(..., distinct=True)
>> - new syntax: db.mytable.insert(myuploadfield=open()), thank you 
>> Iceberg
>> - db(...).select(db.mytable.myfield.count(distinct=True))
>> - db(db.a)._update(name=db(db.b.a==db.a.id).nested_select(db.b.id))
>> - db.mytable.myfield.filter_in, filter_out
>> - db.mytable._enable_record_versioning(db) adds versioning to this table
>> - teradata adapter, thanks Andrew Willimott
>> - experimental Sybase Adapter
>> - added db.table.field.avg()
>> - Support for Google App Engine projections, thanks Christian
>> - Field(... 'upload', default=path) now accepts a path to a local file as 
>> default value, if user does not upload a file. Relative path looks inside 
>> current application folder, thanks Marin
>> - executesql(...,fields=,columns=) allows parsing of results in Rows, 
>> thanks Anthony
>>
>> ### Auth improvements
>>
>> - auth.enable_record_versioning(db)  adds full versioning to all tables
>> - @auth.requires_login(otherwise=URL(...))
>> - auth supports salt and compatible with third party data, thanks Dave 
>> Stoll
>> - CRYPT now defaults to pbkdf2(1000,20,sha1)
>> - Built-in wiki with menu, tags, search, media, permissions. def index: 
>> return auth.wiki()
>> - auth.settings.everybody_group_id
>> - allow storage of uploads on any PyFileSystem (including amazon)
>>
>> ### Form improvements
>>
>> - FORM.confirm('Are you sure?',{'Back':URL(...)})
>> - SQLFORM.smartdictform(dict)
>> - form.add_button(value,link)
>> - SQLFORM.grid(groupby='...')
>> - fixed security issue with SQLFORM.grid and SQLFORM.smartgrid
>> - more export options in SQLFORM.grid and SQLFORM.smartgrid (html, xml, 
>> csv, ...)
>>
>> ### Admin improvements
>>
>> - new admin pages: manage_students, bulk_regsiter, and progress reports
>> - increased security in admin against CSRF
>> - experimental Git integration
>> - experimental OpenShift deployment
>> - multi-language pluralization engine 
>> - ace text web editor in admin
>> - Ukrainian translations, thanks Vladyslav Kozlovskyy
>> - Romanian translation for welcome, thanks ionel
>> - support for mercurial 2.6, thanks Vlad
>>
>> ### Scheduler Improvements (thanks to niphlod, ykessler, dhx, toomim)
>>
>> - web2py.py -K myapp -X starts the myapp scheduler alongside the webserver

Re: [web2py] Re: web2py.js error

2012-09-05 Thread Richard Vézina
For me chosen has keep working properly...

Richard

On Wed, Sep 5, 2012 at 10:06 AM, Johann Spies wrote:

> On 5 September 2012 15:44, Anthony  wrote:
>
>> Are you using a version of jQuery earlier than 1.7?
>
>
> Yes, I was trying to use jQuery-multiSelect which uses 1.6.4. Removing the
> following lines from my view:
>
>   {{
> #  response.files.append("
> http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js";)
> #  response.files.append("
> http://ajax.googleapis.com/ajax/libs/themes/ui-darkness/jquery-ui.css";)
> #   response.files.append(URL('static', 'js/jquery.bgiframe.min.js'))
> #  response.files.append(URL('static', 'css/jquery.multiSelect.css'))
> }}
>
> Stops the complaint by firebug and disables any multiselect editing
> options for me.  It practically makes the multiselect field uneditable.
>
> :(
>
>
> Is there a solution for a multiselect-field?
>
> Regards
> Johann
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)
>
>  --
>
>
>
>

-- 





[web2py] Re: I can't display a thumbnail?

2012-09-05 Thread BlueShadow
the image filename is joined to articles by this line:
Field('TopImage',db.Images)
id=request.vars.id  #<<-- only ok for testing
I removed some code to make it as short as possible the original version 
gets the article id from request.vars.id
if none is given it redirects to a page where you can choose the article 
you want to read.

On Wednesday, September 5, 2012 4:07:29 PM UTC+2, villas wrote:
>
> def Article():
> id=request.vars.id
> row=db(db.Article.id==id).select()
>
> Not sure how you get the Images filenames.  The code does not seem join 
> the Article to the Image?
>
> Maybe something like: 
> def Article():
> id=request.vars.id  #  <<-- only ok for testing
> row=db((db.Article.id==id)&(db.Article.TopImage==db.Images.id)).select
> ()
>
>
>
> Regards, David
>
> On Wednesday, September 5, 2012 12:35:26 PM UTC+1, BlueShadow wrote:
>>
>> Hi,
>> its driving me nuts. I used the code from web2pyslices to generate 
>> thumbnails:
>> db.py:
>> db.define_table('Images',
>> Field('Name',length=512),
>> Field('Image','upload'),
>> Field('thumb','upload',writable=False,readable=False),
>> format = '%(Name)s' # <<< important
>> )
>> db.define_table('Article',
>> Field('Title',length=512),
>> Field('Content','text'),
>> Field('Submitted','datetime',default=datetime.datetime.now()),
>> Field('Views','integer',default=0),
>> Field('TopImage',db.Images)
>> )
>> default.py:
>> def download():
>> return response.download(request, db)
>> def makeThumbnail(dbtable,ImageID,size=(200,200)):
>> try:
>> thisImage=db(dbtable.id==ImageID).select()[0]
>> import os, uuid
>> except: 
>> print "Error while loading libraries"
>> return
>> try:
>> from PIL import Image
>> except:
>> print "Error while Importing PIL library"
>> return
>> print request.folder + 'uploads/' + thisImage.Image
>> im=Image.open(request.folder + 'uploads/' + thisImage.Image)
>> im.thumbnail(size,Image.ANTIALIAS)
>> thumbName='uploads.thumb.%s.jpg' % (uuid.uuid4())
>> im.save(request.folder + 'uploads/' + thumbName,'jpeg')
>> thisImage.update_record(thumb=thumbName)
>> response.flash = 'Thumb created everything went fine'
>> return
>> def newImage():
>> dbtable = db.Images  #uploads table name
>> if len(request.args):
>> records = db(dbtable.id==request.args[0]).select()
>> if len(request.args) and len(records):
>> form = SQLFORM(dbtable, records[0], deletable=True)
>> else:
>> form = SQLFORM(dbtable)
>> if form.accepts(request.vars, session):
>> response.flash = 'Entry for Images Database accepted,start 
>> creating thumb'
>> makeThumbnail(dbtable,form.vars.id,(200,200))
>> elif form.errors:
>> response.flash = 'Error in Form for Images Database'
>> ## Quick list just to demonstrate...
>> list = crud.select(dbtable)
>> return dict(form=form,list=list)
>> def Article():
>> id=request.vars.id
>> row=db(db.Article.id==id).select()
>> row[0].update_record(Views=row[0].Views+1)
>> if len(row)==0:
>> redirect(URL(r=request,f='Articles'))
>> return dict(Article=row[0])
>> article.html
>> {{extend 'layout.html'}}
>>  {{=Article.Title}} 
>> 
>> 
>> {{print URL(r=request, c='default', 
>> f='download',args=Article.TopImage.thumb)}}
>> {{=IMG(_src=URL(r=request, c='default', 
>> f='download',args=Article.TopImage.thumb),_style="display:block;")}}
>>  
>>  
>> {{=XML(Article.Content)}}
>> the thumbnail is generated by the code as it should. and it lands in the 
>> upload folder with the original image as it should. if I change the 
>> article.TopImage.thumb to .image it works perfectly. if I change it to 
>> .thumb again no image is displayed. the path and name I get from the print 
>> seem to be correct at least it is the same path as for the origianl image.
>> thanks for your help guys
>>
>>

-- 





[web2py] Re: Limit Length column

2012-09-05 Thread Anthony
If you want to control the column widths and allow the content to wrap if 
necessary, you can do so with CSS (and some JS in IE). Let's say you want 
to set the width of the 5th column. To support IE, in Javascript do:


$(function() {
$('.ie .web2py_table td:nth-child(5)').addClass('td-wrap');
});


Then in CSS:

.web2py_table td:nth-child(5), .web2py_table td.td-wrap {
min-width: 15em; max-width: 20em; white-space: normal !important;
}

Anthony

On Wednesday, September 5, 2012 10:06:41 AM UTC-4, Mandar Vaze wrote:
>
> Using maxtextlengths optional parameter partially helps.
> http://web2py.com/books/default/chapter/29/07?search=maxtextlengths
>
> I say partially because this param controls how many characters are 
> displayed in the column (Only those many characters are sent by the server)
> If one has too many wide columns, result could be ugly, especially buttons 
> in last column are now shown vertically - depending on screen size etc.
>
> I wish there was way to control the column width via web2py
>
> -Mandar
>
> On Tuesday, September 4, 2012 12:35:55 AM UTC+5:30, Ovidio Marinho wrote:
>>
>> how to limit the size of columns in sqlform.grid
>> 25   
>>40   
>> 15
>> 1 col lenght 25   
>> === =
>> 2 col lenght 40
>> 3 col lenght 15
>> etc...
>>
>>
>>   
>>
>>
>>Ovidio Marinho Falcao Neto
>> Web Developer
>>  ovid...@gmail.com 
>>   ovidio...@itjp.net.br
>>  ITJP - itjp.net.br
>>83   8826 9088 - Oi
>>83   9334 0266 - Claro
>> Brasil
>>   
>>
>>  

-- 





[web2py] Re: I can't display a thumbnail?

2012-09-05 Thread Anthony
On Wednesday, September 5, 2012 10:07:29 AM UTC-4, villas wrote:
>
> def Article():
> id=request.vars.id
> row=db(db.Article.id==id).select()
>
> Not sure how you get the Images filenames.  The code does not seem join 
> the Article to the Image?
>

Note, Article.TopImage.thumb does a recursive select, so it retrieves the 
value of the "thumb" field from the referenced db.Images record.

Anthony

-- 





Re: [web2py] Re: 2.02 Table name in smartgrid changed...

2012-09-05 Thread Adnan Smajlovic
Massimo,
Any chance to leave only table_plural on line 2248 in sqlhtml.py:

#header = table._plural + (field and ' for '+field.name or '')
header = table._plural

I would also leave all in one line if possible, e.g: table_level_1 > id >
table_level_2, etc...


Thanks,
Adnan

On Tue, Sep 4, 2012 at 10:07 AM, Jim S  wrote:

> I'm having the same issue as well with second level display
>
> -Jim
>
> On Friday, August 31, 2012 9:59:38 AM UTC-5, Adi wrote:
>>
>> trunk works for the first level, but doesn't when i drill down into the
>> second level... (image attached)
>>
>> also it used to display all breadcrumbs in the same line...
>>
>> old source code:
>> > class="w2p_trap" href="/list_suppliers/supplier">Suppliers > > class="w2p_trap" href="
>> /list_suppliers/supplier/view/supplier/21?_signature=3a9f06fff5edbc76efc140b8838b11063d1cd328
>> ">Concept Laboratories, Inc. > Purchase orders
>> 
>>
>> so far, all seems to work perfectly fine on 2 apps :) had a migration
>> problem to alter scheduler tables (usual back and forth), but got it
>> working as well... continuing testing...
>>
>> thanks again for the best framework!
>>
>>
>> On Thursday, August 30, 2012 4:36:40 PM UTC-4, Massimo Di Pierro wrote:
>>>
>>> Got it. fixed in trunk. This was not intentional!
>>>
>>> On Thursday, 30 August 2012 10:29:25 UTC-5, Adi wrote:

 Smartgrid used to display the table name automatically. Is that
 supposed to be as before?

>>>  --
>
>
>
>

-- 





Re: [web2py] Updated cheatsheet

2012-09-05 Thread rif
Maybe the otherwise param should appear in the cheatsheet:
@auth.requires_login(otherwise=URL(...))

-- 





[web2py] Re: I can't display a thumbnail?

2012-09-05 Thread Anthony

>
> thumbName='uploads.thumb.%s.jpg' % (uuid.uuid4())
> im.save(request.folder + 'uploads/' + thumbName,'jpeg')
>

The above is not quite the naming scheme expected by response.download. 
Instead of trying to make the name yourself, it might be easier to use the 
field's .store() method to handle it the naming and saving:

thisImage.update_record(thumb=db.Images.thumb.store(im, 
filename='thumbnail.jpg'))

See http://web2py.com/books/default/chapter/29/06#More-on-uploads.

Anthony

-- 





[web2py] Question about vars and crud.create (newbie)

2012-09-05 Thread tommasot
I need to catch the request parameters in a crud.create operation

Thi the simple code in the controller

form = crud.create(db.anno,next='list_anno')


and this the domain

db.define_table('anno',
Field('descrizione'),
Field('incorso','boolean'),format='%(descrizione)s')

Now i want before the create operation manipulate the 'incorso' Field

Thanks

-- 





[web2py] Re: Init Script in Web2Py

2012-09-05 Thread tommasot
Thank you so much

Il giorno venerdì 10 agosto 2012 11:56:15 UTC+2, tommasot ha scritto:
>
> I have a newbie question.
>
> I need to create some record in db on application startup,like for example 
> default user and other things..
>
> Where is the right script/place to implement it
>
>

-- 





[web2py] NewBie Question about crud.create

2012-09-05 Thread tommasot
I have the following code in the controller about record creation

*form = crud.create(db.anno,next='list_anno')*

This is the model,how you can see is very simple :)

*db.define_table('anno',
Field('descrizione'),
Field('incorso','boolean'),format='%(descrizione)s')*

Now i want to catch the 'incorso' value posted from the form and manipulate 
the value if some condition is satisfied.

The question is how can i intercept the value, i hope there is something 
like form.field


Thanks

-- 





Re: [web2py] Question about vars and crud.create (newbie)

2012-09-05 Thread Richard Vézina
What you want to do with the field?

there is :

db.tablename.fieldname.* = *

Richard

On Wed, Sep 5, 2012 at 10:50 AM, tommasot  wrote:

> I need to catch the request parameters in a crud.create operation
>
> Thi the simple code in the controller
>
> form = crud.create(db.anno,next='list_anno')
>
>
> and this the domain
>
> db.define_table('anno',
> Field('descrizione'),
> Field('incorso','boolean'),format='%(descrizione)s')
>
> Now i want before the create operation manipulate the 'incorso' Field
>
> Thanks
>
> --
>
>
>
>

-- 





Re: [web2py] NewBie Question about crud.create

2012-09-05 Thread Richard Vézina
What you want to do exactly?

Base on the value you are talking about filtering a dropbox list for an
other field?

If so there is lazy option plugin :

http://dev.s-cubism.com/plugin_lazy_options_widget

You will need to be more specific in your question if you want us to help
you properly.

Richard

On Wed, Sep 5, 2012 at 11:09 AM, tommasot  wrote:

> I have the following code in the controller about record creation
>
> *form = crud.create(db.anno,next='list_anno')*
>
> This is the model,how you can see is very simple :)
>
> *db.define_table('anno',
> Field('descrizione'),
> Field('incorso','boolean'),format='%(descrizione)s')*
>
> Now i want to catch the 'incorso' value posted from the form and
> manipulate the value if some condition is satisfied.
>
> The question is how can i intercept the value, i hope there is something
> like form.field
>
>
> Thanks
>
> --
>
>
>
>

-- 





[web2py] Start web2py as windows service with ssl

2012-09-05 Thread Geo

Greetings,
I have searched similar posts but I still can't make it work.

I have a test machine with the following configuration:
- Windows Server 2008 R2 Standard 64
- python 2.7
- pywin32_system32
- OpenSSL
- web2py source 1.99.7 (2012-03-04 22:12:08) stable

options.py:
import socket
import os

ip = socket.gethostbyname(socket.gethostname())
port = 8000
interfaces=[(ip,port)]
interfaces.append((ip,443,'server.key','server.crt'))
password = ''  # ##  means use the previous password
pid_filename = 'httpserver.pid'
log_filename = 'httpserver.log'
profiler_filename = None
#ssl_certificate = 'server.crt'  # ## path to certificate file
#ssl_private_key = 'server.key'  # ## path to private key file
minthreads = None
maxthreads = None
server_name = socket.gethostname()
request_queue_size = 5
timeout = 30
shutdown_timeout = 5
folder = os.getcwd()
extcron = None
nocron = None

additional files:
parameters_442.py
parameters_8000.py

all works when started by command line (python web2py.py--password="" 
--
config=options.py) but when I try to start it as a service I get mixed 
results.
if I comment the lines
#ssl_certificate = 'server.crt'  # ## path to certificate file
#ssl_private_key = 'server.key'  # ## path to private key file
the service does not start and in the event logger I get:

Traceback (most recent call last): File "D:\web2py\gluon\winservice.py", 
line 49, in SvcDoRun self.start() File "D:\web2py\gluon\winservice.py", 
line 122, in start ssl_certificate=options.ssl_certificate, AttributeError: 
'module' object has no attribute 'ssl_certificate' 

if I uncomment the lines
ssl_certificate = 'server.crt'  # ## path to certificate file
ssl_private_key = 'server.key'  # ## path to private key file

the service starts but I cannot connect to the pages

Also, if I try to start the service from command line (--winservice=start) 
instead than from the services pannel, the sytem returns "Error starting 
service: Access is denied."

Can anyone help me?

Thanks

-- 





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-05 Thread Massimo Di Pierro
yes please. Did this work in 1.99.7?

On Wednesday, 5 September 2012 09:07:41 UTC-5, Alan Etkin wrote:
>
> Does NOT seem to work.  computed field is still not visible.
>>
>>
> Same problem with this version: 2.0.7 (2012-09-04 18:33:19) stable 
> (updated with hg)
>
> I think we should open an issue in the google code page.
>
>

-- 





Re: [web2py] Re: 2.02 Table name in smartgrid changed...

2012-09-05 Thread Massimo Di Pierro
Open an issue. We can make that a parameter.

On Wednesday, 5 September 2012 09:49:11 UTC-5, Adi wrote:
>
> Massimo,
> Any chance to leave only table_plural on line 2248 in sqlhtml.py: 
>
> #header = table._plural + (field and ' for '+field.name or '')
> header = table._plural
>
> I would also leave all in one line if possible, e.g: table_level_1 > id > 
> table_level_2, etc... 
>
>
> Thanks,
> Adnan
>
> On Tue, Sep 4, 2012 at 10:07 AM, Jim S > wrote:
>
>> I'm having the same issue as well with second level display
>>
>> -Jim
>>
>> On Friday, August 31, 2012 9:59:38 AM UTC-5, Adi wrote:
>>>
>>> trunk works for the first level, but doesn't when i drill down into the 
>>> second level... (image attached)
>>>
>>> also it used to display all breadcrumbs in the same line...
>>>
>>> old source code:
>>> >> >Suppliers> 
>>> Concept Laboratories, Inc. > Purchase orders
>>> 
>>>
>>> so far, all seems to work perfectly fine on 2 apps :) had a migration 
>>> problem to alter scheduler tables (usual back and forth), but got it 
>>> working as well... continuing testing...
>>>
>>> thanks again for the best framework!
>>>
>>>
>>> On Thursday, August 30, 2012 4:36:40 PM UTC-4, Massimo Di Pierro wrote:

 Got it. fixed in trunk. This was not intentional!

 On Thursday, 30 August 2012 10:29:25 UTC-5, Adi wrote:
>
> Smartgrid used to display the table name automatically. Is that 
> supposed to be as before?
>
  -- 
>>  
>>  
>>  
>>
>
>
>
>
>

-- 





Re: [web2py] Updated cheatsheet

2012-09-05 Thread Massimo Di Pierro
It should


On Wednesday, 5 September 2012 09:57:30 UTC-5, rif wrote:
>
> Maybe the otherwise param should appear in the cheatsheet:
> @auth.requires_login(otherwise=URL(...))
>
>

-- 





Re: [web2py] Re: web2py.js error

2012-09-05 Thread Johann Spies
On 5 September 2012 16:10, Richard Vézina wrote:

> For me chosen has keep working properly..


What is 'chosen'  in this context?

I have used the native web2py widget in the past - that stopped working in
the past few weeks with changes to the trunk.

I have also used the plugin from
http://dev.s-cubism.com/plugin_multiselect_widget at one stage.  Maybe I
must go back and try that again.

 Regards
Johann


-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





Re: [web2py] little css issue and french translation

2012-09-05 Thread Calycé
Hi Richard,

The french translation would be better as: "Propulsé par" and not 
"Propulser par".
BTW, nice to see french speaking folks around here ;-)



On Wednesday, September 5, 2012 4:31:10 PM UTC+2, Richard wrote:
>
> Hello,
>
> I found that if the number of menu entries are to high or if the text is 
> too long the black nav bar overflow over the rest of the page element...
>
> Also, notice, that the french translation of the web2py : powered by 
>
> is wrong. I mean, in french it translate as : alimenté par
>
> That could mean : feed by
>
> Better to translate with : Propulser par
>
> See attach screenshot, for more details.
>
> Richard
>

-- 





Re: [web2py] Updated cheatsheet

2012-09-05 Thread rif
Also the cast parameter. Are the sources for the cheatsheet available so we 
can make patch suggestions?

-rif

miercuri, 5 septembrie 2012, 18:53:45 UTC+3, Massimo Di Pierro a scris:
>
> It should
>
>
> On Wednesday, 5 September 2012 09:57:30 UTC-5, rif wrote:
>>
>> Maybe the otherwise param should appear in the cheatsheet:
>> @auth.requires_login(otherwise=URL(...))
>>
>>

-- 





Re: [web2py] jQuery UI in 2.0.7

2012-09-05 Thread Annet
Hi Richard,

Thanks for you reply.

I had some problem with jQuery UI too, most were gone by using 1.8.16 ship 
> with web2py (uncomment line in the layout that point to google api).


That version introduced another problem, the auto complete's list wasn't 
displayed properly, besides, it didn't fix the issue I described above, 
which has something to do with a change in web2py between versions 1.99.7 
and 2.0.2, which hasn't been fixed in 2.0.7.

Kind regards,

Annet

-- 





Re: [web2py] Re: web2py.js error

2012-09-05 Thread Anthony
On Wednesday, September 5, 2012 11:57:23 AM UTC-4, Johann Spies wrote:
>
> On 5 September 2012 16:10, Richard Vézina 
> > wrote:
>
>> For me chosen has keep working properly..
>
>
> What is 'chosen'  in this context?
>

Probably http://harvesthq.github.com/chosen/.
 

>
> I have used the native web2py widget in the past - that stopped working in 
> the past few weeks with changes to the trunk.
>

What native widget? Isn't it just a standard HTML select widget?

Anthony

-- 





[web2py] DB Migration (sqlite->pgsql) Problems with 1.99.7 - 2.0.6 - 2.0.7 Versions

2012-09-05 Thread Christian Espinoza
Hello, I'm in trouble with a webapp that I'have.

I develop it using sqlite only for a best approach of web2py features with 
it.

And I'm trying to migrate it to a Postgresql DB to put it on Testing phase.

But It doesn't work with PostgreSQL, only work with sqlite, I'd tried with 
 1.99.7 - 2.0.6 -  2.0.7 Versions

At 2.0.7 and 2.0.6 showme:  invalid literal 
for int() with base 10: 'SELECT'

At 

Traceback (most recent call last):
  File "/opt/web-apps/web2py/gluon/restricted.py", line 209, in restricted
exec ccode in environment
  File "/opt/web-apps/web2py-2.0.7/applications/sadma/models/db.py" 
, line 236, in 

if db(db.auth_user).isempty():
  File "/opt/web-apps/web2py/gluon/dal.py", line 8722, in isempty
return not self.select(limitby=(0,1))
  File "/opt/web-apps/web2py/gluon/dal.py", line 8743, in select
return adapter.select(self.query,fields,attributes)
  File "/opt/web-apps/web2py/gluon/dal.py", line 1583, in select
return self._select_aux(sql,fields,attributes)
  File "/opt/web-apps/web2py/gluon/dal.py", line 1556, in _select_aux
self.execute(sql)

My Connection string:

*#db = DAL('sqlite://storage.sqlite')
db = DAL('postgres://user:pass@localhost/dbapp')**
*

*Running on Centos 6.0, external Postgresql Server with 9 version, **Python 
2.6.6*

*
*

Thanks in advance

Christian.

-- 





[web2py] Re: NewBie Question about crud.create

2012-09-05 Thread Anthony
Do you want to manipulate it (a) after submission but before validation 
(use request.vars.incorso), (b) after validation but before the insert (use 
crud.settings.create_onvalidation), or (c) after the record is inserted 
(use crud.settings.create_onaccept).

Anthony

On Wednesday, September 5, 2012 11:09:41 AM UTC-4, tommasot wrote:
>
> I have the following code in the controller about record creation
>
> *form = crud.create(db.anno,next='list_anno')*
>
> This is the model,how you can see is very simple :)
>
> *db.define_table('anno',
> Field('descrizione'),
> Field('incorso','boolean'),format='%(descrizione)s')*
>
> Now i want to catch the 'incorso' value posted from the form and 
> manipulate the value if some condition is satisfied.
>
> The question is how can i intercept the value, i hope there is something 
> like form.field
>
>
> Thanks
>

-- 





[web2py] Filtering on NULL values in DAL query

2012-09-05 Thread Yarin
Is this documented anywhere?

-- 





Re: [web2py] jQuery UI in 2.0.7

2012-09-05 Thread Richard Vézina
Ok, I may have to take a look at 2.0.7 thought!

Richard

On Wed, Sep 5, 2012 at 12:23 PM, Annet  wrote:

> Hi Richard,
>
> Thanks for you reply.
>
>
> I had some problem with jQuery UI too, most were gone by using 1.8.16 ship
>> with web2py (uncomment line in the layout that point to google api).
>
>
> That version introduced another problem, the auto complete's list wasn't
> displayed properly, besides, it didn't fix the issue I described above,
> which has something to do with a change in web2py between versions 1.99.7
> and 2.0.2, which hasn't been fixed in 2.0.7.
>
> Kind regards,
>
> Annet
>
> --
>
>
>
>

-- 





Re: [web2py] little css issue and french translation

2012-09-05 Thread Richard Vézina
You right, I realised it after I sent my email :(

Richard

On Wed, Sep 5, 2012 at 11:58 AM, Calycé wrote:

> Hi Richard,
>
> The french translation would be better as: "Propulsé par" and not
> "Propulser par".
> BTW, nice to see french speaking folks around here ;-)
>
>
>
>
> On Wednesday, September 5, 2012 4:31:10 PM UTC+2, Richard wrote:
>>
>> Hello,
>>
>> I found that if the number of menu entries are to high or if the text is
>> too long the black nav bar overflow over the rest of the page element...
>>
>> Also, notice, that the french translation of the web2py : powered by
>>
>> is wrong. I mean, in french it translate as : alimenté par
>>
>> That could mean : feed by
>>
>> Better to translate with : Propulser par
>>
>> See attach screenshot, for more details.
>>
>> Richard
>>
>  --
>
>
>
>

-- 





[web2py] Re: 2.02 Table name in smartgrid changed...

2012-09-05 Thread Paolo Caruccio
to display all breadcrumbs in the same line please try to append to 
web2py.css following rule

li.w2p_grid_breadcrumb_elem {
display:inline-block;
}

in versions >= 2.0.2 web2py.css file has the right rule, so this issue 
should arise only with previous experimental versions.

Il giorno giovedì 30 agosto 2012 17:29:25 UTC+2, Adi ha scritto:
>
> Smartgrid used to display the table name automatically. Is that supposed 
> to be as before?
>

-- 





Re: [web2py] Filtering on NULL values in DAL query

2012-09-05 Thread Bruno Rocha
db(db.table.field == None).select()

should give you all records with field = NULL

db(~db.table.field == None).select()

All records where field <> NULL

Is that?

-- 





Re: [web2py] Filtering on NULL values in DAL query

2012-09-05 Thread Marin Pranjić
it is db.table.field != None

operator ~ is used for ORDER BY and it maps to DESC.

On Wed, Sep 5, 2012 at 7:59 PM, Bruno Rocha  wrote:

>
> db(~db.table.field == None).select()
>
>

-- 





Re: [web2py] Filtering on NULL values in DAL query

2012-09-05 Thread Bruno Rocha
On Wed, Sep 5, 2012 at 3:12 PM, Marin Pranjić wrote:

> it is db.table.field != None
>
> operator ~ is used for ORDER BY and it maps to DESC.


Yes, my bad, you are right, but there is one case where ~ is used in query

~db.table.field.belongs(list) and ~db.table.listfield.contains(value)

-- 





Re: [web2py] Filtering on NULL values in DAL query

2012-09-05 Thread Yarin
Thanks. Massimo we need this in the docs.

On Wednesday, September 5, 2012 2:38:26 PM UTC-4, rochacbruno wrote:
>
> On Wed, Sep 5, 2012 at 3:12 PM, Marin Pranjić 
> 
> > wrote:
>
>> it is db.table.field != None
>>
>> operator ~ is used for ORDER BY and it maps to DESC.
>
>
> Yes, my bad, you are right, but there is one case where ~ is used in query
>
> ~db.table.field.belongs(list) and ~db.table.listfield.contains(value) 
>
>

-- 





[web2py] Accessing id in SQLFORM.process()

2012-09-05 Thread Philip Kilner
Hi,

I'm trying to wean myself of CRUD and am doing an insert with 
SQLFORM.process().

I want to redirect on success to view the newly inserted record.

How can I access the ID of the new record in this context? 

Hoped I could do something like: -

SQLFORM(db.t_account).process(next=URL(c='account',f='index', 
args=['t_account', id]))

--

Cheers,

PhilK

-- 





[web2py] Re: Start web2py as windows service with ssl

2012-09-05 Thread Niphlod
a little bug I found (and corrected) is that if you comment out 
ssl_certificate and ssl_private_key, that parameter is missing, and web2py 
requires it. If you don't need certificates just set ssl_certificate and 
ssl_private_key to None (as current trunk options_std.py 
http://code.google.com/p/web2py/source/browse/options_std.py)

second thing, I think the interface for ws2008 changed a little bit, so 
it's not possible to use cmdline parameter to start the service (try 
running the shell as administrator, could help). If it doesn't, just use 
the "windows usual flavour" 
net start nameoftheservice
to start it.

Another thing, you have parameters_* files for ports 8000 and 442 but you 
start the service for 8000 and 443. I don't have a ws2008 installation 
available to test it, but you can try with these hints. 

Not too long ago I proposed to strip off the code of the windows webservice 
cause it's getting harder and harder to maintain. Useful tools as nssm are 
a lot easier to deal with and can make virtually any programs run as 
services with no issues (and I could make a slice for it if users need it).

On Wednesday, September 5, 2012 5:29:06 PM UTC+2, Geo wrote:
>
>
> Greetings,
> I have searched similar posts but I still can't make it work.
>
> I have a test machine with the following configuration:
> - Windows Server 2008 R2 Standard 64
> - python 2.7
> - pywin32_system32
> - OpenSSL
> - web2py source 1.99.7 (2012-03-04 22:12:08) stable
>
> options.py:
> import socket
> import os
>
> ip = socket.gethostbyname(socket.gethostname())
> port = 8000
> interfaces=[(ip,port)]
> interfaces.append((ip,443,'server.key','server.crt'))
> password = ''  # ##  means use the previous password
> pid_filename = 'httpserver.pid'
> log_filename = 'httpserver.log'
> profiler_filename = None
> #ssl_certificate = 'server.crt'  # ## path to certificate file
> #ssl_private_key = 'server.key'  # ## path to private key file
> minthreads = None
> maxthreads = None
> server_name = socket.gethostname()
> request_queue_size = 5
> timeout = 30
> shutdown_timeout = 5
> folder = os.getcwd()
> extcron = None
> nocron = None
>
> additional files:
> parameters_442.py
> parameters_8000.py
>
> all works when started by command line (python 
> web2py.py--password="" --
> config=options.py) but when I try to start it as a service I get mixed 
> results.
> if I comment the lines
> #ssl_certificate = 'server.crt'  # ## path to certificate file
> #ssl_private_key = 'server.key'  # ## path to private key file
> the service does not start and in the event logger I get:
>
> Traceback (most recent call last): File "D:\web2py\gluon\winservice.py", 
> line 49, in SvcDoRun self.start() File "D:\web2py\gluon\winservice.py", 
> line 122, in start ssl_certificate=options.ssl_certificate, AttributeError: 
> 'module' object has no attribute 'ssl_certificate' 
>
> if I uncomment the lines
> ssl_certificate = 'server.crt'  # ## path to certificate file
> ssl_private_key = 'server.key'  # ## path to private key file
>
> the service starts but I cannot connect to the pages
>
> Also, if I try to start the service from command line (--winservice=start) 
> instead than from the services pannel, the sytem returns "Error starting 
> service: Access is denied."
>
> Can anyone help me?
>
> Thanks
>

-- 





[web2py] Re: Accessing id in SQLFORM.process()

2012-09-05 Thread Niphlod
in any case it should be at least form.vars.id. Don't know if it's 
available inside the process() environment.
Even if it doesn't work, is it so hard to 
if form.process().validate:
redirect(URL('whatever', args=form.vars.id))

?

On Wednesday, September 5, 2012 8:41:44 PM UTC+2, Philip Kilner wrote:
>
> Hi,
>
> I'm trying to wean myself of CRUD and am doing an insert with 
> SQLFORM.process().
>
> I want to redirect on success to view the newly inserted record.
>
> How can I access the ID of the new record in this context? 
>
> Hoped I could do something like: -
>
> SQLFORM(db.t_account).process(next=URL(c='account',f='index', 
> args=['t_account', id]))
>
> --
>
> Cheers,
>
> PhilK
>
>

-- 





Re: [web2py] Re: Accessing id in SQLFORM.process()

2012-09-05 Thread Marin Pranjić
Should be accepted instead of validate:

form = SQLFORM(...).process()
if form.accepted:
... redirect(URL(..., args=form.vars.id))

On Wed, Sep 5, 2012 at 8:56 PM, Niphlod  wrote:

> in any case it should be at least form.vars.id. Don't know if it's
> available inside the process() environment.
> Even if it doesn't work, is it so hard to
> if form.process().validate:
> redirect(URL('whatever', args=form.vars.id))
>
> ?
>
>
> On Wednesday, September 5, 2012 8:41:44 PM UTC+2, Philip Kilner wrote:
>>
>> Hi,
>>
>> I'm trying to wean myself of CRUD and am doing an insert with
>> SQLFORM.process().
>>
>> I want to redirect on success to view the newly inserted record.
>>
>> How can I access the ID of the new record in this context?
>>
>> Hoped I could do something like: -
>>
>> SQLFORM(db.t_account).process(**next=URL(c='account',f='index'**,
>> args=['t_account', id]))
>>
>> --
>>
>> Cheers,
>>
>> PhilK
>>
>>  --
>
>
>
>

-- 





Re: [web2py] Filtering on NULL values in DAL query

2012-09-05 Thread Marin Pranjić
Thanks, good to know :)

On Wed, Sep 5, 2012 at 8:37 PM, Bruno Rocha  wrote:

> On Wed, Sep 5, 2012 at 3:12 PM, Marin Pranjić wrote:
>
>> it is db.table.field != None
>>
>> operator ~ is used for ORDER BY and it maps to DESC.
>
>
> Yes, my bad, you are right, but there is one case where ~ is used in query
>
> ~db.table.field.belongs(list) and ~db.table.listfield.contains(value)
>
>  --
>
>
>
>

-- 





Re: [web2py] Re: Accessing id in SQLFORM.process()

2012-09-05 Thread Niphlod
whoops, right:
form = SQLFORM(db.table)
if form.process().accepted:
 redirect(URL('whatever', args=form.vars.id))

On Wednesday, September 5, 2012 9:00:10 PM UTC+2, Marin Pranjić wrote:
>
> Should be accepted instead of validate:
>
> form = SQLFORM(...).process()
> if form.accepted:
> ... redirect(URL(..., args=form.vars.id))
>
> On Wed, Sep 5, 2012 at 8:56 PM, Niphlod >wrote:
>
>> in any case it should be at least form.vars.id. Don't know if it's 
>> available inside the process() environment.
>> Even if it doesn't work, is it so hard to 
>> if form.process().validate:
>> redirect(URL('whatever', args=form.vars.id))
>>
>> ?
>>
>>
>> On Wednesday, September 5, 2012 8:41:44 PM UTC+2, Philip Kilner wrote:
>>>
>>> Hi,
>>>
>>> I'm trying to wean myself of CRUD and am doing an insert with 
>>> SQLFORM.process().
>>>
>>> I want to redirect on success to view the newly inserted record.
>>>
>>> How can I access the ID of the new record in this context? 
>>>
>>> Hoped I could do something like: -
>>>
>>> SQLFORM(db.t_account).process(**next=URL(c='account',f='index'**, 
>>> args=['t_account', id]))
>>>
>>> --
>>>
>>> Cheers,
>>>
>>> PhilK
>>>
>>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





Re: [web2py] Re: 2.02 Table name in smartgrid changed...

2012-09-05 Thread Adnan Smajlovic
thanks Paolo... worked perfectly.

On Wed, Sep 5, 2012 at 1:59 PM, Paolo Caruccio
wrote:

> to display all breadcrumbs in the same line please try to append to
> web2py.css following rule
>
> li.w2p_grid_breadcrumb_elem {
> display:inline-block;
> }
>
> in versions >= 2.0.2 web2py.css file has the right rule, so this issue
> should arise only with previous experimental versions.
>
> Il giorno giovedì 30 agosto 2012 17:29:25 UTC+2, Adi ha scritto:
>
>> Smartgrid used to display the table name automatically. Is that supposed
>> to be as before?
>>
>  --
>
>
>
>

-- 





Re: [web2py] how to set js variable from session variable?

2012-09-05 Thread Marin Pranjić
jQuery.get('CALLBACK_URL', function(data){
alert(data);
});


source: http://api.jquery.com/jQuery.get/

On Wed, Sep 5, 2012 at 8:15 AM, weheh  wrote:

>
> I tried an ajax call to a controller callback, that in turn returns
> "$('#myjsvar').val('%d');" % session.myvar, based loosely on a thread I
> read here, but that didn't come close to working, either.
>

You can try:

$('#myjsvar

-- 





Re: [web2py] how to set js variable from session variable?

2012-09-05 Thread Marin Pranjić
On Wed, Sep 5, 2012 at 10:00 PM, Marin Pranjić wrote:

> jQuery.get('CALLBACK_URL', function(data){
> alert(data);
> });
>
>
> source: http://api.jquery.com/jQuery.get/
>
> On Wed, Sep 5, 2012 at 8:15 AM, weheh  wrote:
>
>>
>> I tried an ajax call to a controller callback, that in turn returns
>> "$('#myjsvar').val('%d');" % session.myvar, based loosely on a thread I
>> read here, but that didn't come close to working, either.
>>
>

-- 





Re: [web2py] required option in Field

2012-09-05 Thread Marin Pranjić
This should work for other field types as you expect, but empty string is
still valid string value.
You can set: requires=IS_LENGTH(minsize=1) to disallow empty strings.

On Tue, Sep 4, 2012 at 7:24 PM, Denis Rykov  wrote:

> I use the following Field definition:
>
> Field('admin_unit', required=True, label='Region'),
>
> But when I create new row through smartgrid interface and leave this field
> empty - validation error not appears and record creates in database. If see
> table in database you can see that 'admin_unit' field contains empty string
> (''). Is it correct? It looks like required options doesn't work properly.
>
> --
>
>
>
>

-- 





[web2py] 2.0.6: "Required=True" not enforced by DAL?

2012-09-05 Thread mjm
I have created simple table:

db.define_table('hoortoestel', 
# algemeen
Field('merk', type='string', required=True, ), 
Field('type', type='string', required=True, ),
...

When trying to enter a new record in appadmin I noticed that when not 
entering anything in either field, the new record data is accepted and 
entered into the (SQLlite) database. I think that's a bug. 
If I change the required constraint to notnull=True, the empty record is 
indeed rejected, as expected. 


-- 





Re: [web2py] Filtering on NULL values in DAL query

2012-09-05 Thread Marin Pranjić
Db.table.field == None

On Sep 5, 2012 6:42 PM, "Yarin"  wrote:

Is this documented anywhere?

--

-- 





[web2py] 2.0.6 bug? "required=True" not enforced

2012-09-05 Thread mjm
I have defined a simple table: 

db.define_table('hoortoestel', 
# algemeen
Field('merk', type='string', required=True, ), 
Field('type', type='string', required=True, ),
...

If I then try to enter a new record in appadmin and do not enter anything 
for the fields, the record is still accepted and entered into the (SQLite) 
database. I would have expected the DAL to refuse the values. 
If I change the constraints from required=True to notnull=True, the empty 
values are not accepted. 

Bug or oversight by me?

-- 





[web2py] Connecting to external databases

2012-09-05 Thread Gregg Branquinho
I am building a json webservice in web2py and it is being used by many 
different frontends..

What I am looking to do on the back end is connected to external databases 
(1 postgre, 2 mssql) and return the correlated data from the different 
servers to the json client.

What I am struggling with is how to connect to any external database from 
web2py and should I sue the DAL layer to coonect to all these different 
servers ??

Any advice would be greatly apprieciated.



Kind Regards
GRegg

-- 





Re: [web2py] required option in Field

2012-09-05 Thread Niphlod
IS_NOT_EMPTY() is more "remembereable" .

@Marin: when you reply from your mail client please strip the re: from the 
subject or in the group it will show as a separate thread. 

On Wednesday, September 5, 2012 10:07:11 PM UTC+2, Marin Pranjić wrote:
>
> This should work for other field types as you expect, but empty string is 
> still valid string value.
> You can set: requires=IS_LENGTH(minsize=1) to disallow empty strings.
>
> On Tue, Sep 4, 2012 at 7:24 PM, Denis Rykov 
> > wrote:
>
>> I use the following Field definition:
>>
>> Field('admin_unit', required=True, label='Region'),
>>
>> But when I create new row through smartgrid interface and leave this 
>> field empty - validation error not appears and record creates in database. 
>> If see table in database you can see that 'admin_unit' field contains empty 
>> string (''). Is it correct? It looks like required options doesn't work 
>> properly.
>>  
>> -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] Re: 2.0.6 bug? "required=True" not enforced

2012-09-05 Thread Niphlod
As steted on the book

 Notice that requires=... is enforced at the level of forms, required=Trueis 
enforced at the level of the DAL (insert), while 
notnull, unique and ondelete are enforced at the level of the database. 
While they sometimes may seem redundant, it is important to maintain the 
distinction when programming with the DAL.

also, you may want to add a requires=IS_NOT_EMPTY() validator for nice 
error reporting...

On Wednesday, September 5, 2012 7:39:24 PM UTC+2, mjm wrote:
>
> I have defined a simple table: 
>
> db.define_table('hoortoestel', 
> # algemeen
> Field('merk', type='string', required=True, ), 
> Field('type', type='string', required=True, ),
> ...
>
> If I then try to enter a new record in appadmin and do not enter anything 
> for the fields, the record is still accepted and entered into the (SQLite) 
> database. I would have expected the DAL to refuse the values. 
> If I change the constraints from required=True to notnull=True, the empty 
> values are not accepted. 
>
> Bug or oversight by me?
>
>

-- 





Re: [web2py] 2.0.6 bug? "required=True" not enforced

2012-09-05 Thread Marin Pranjić
I would expect that both constraints are accepted (empty string is not
Null).

Is the behavior different from older versions?

On Wed, Sep 5, 2012 at 7:39 PM, mjm  wrote:

> I have defined a simple table:
>
> db.define_table('hoortoestel',
> # algemeen
>  Field('merk', type='string', required=True, ),
> Field('type', type='string', required=True, ),
> ...
>
> If I then try to enter a new record in appadmin and do not enter anything
> for the fields, the record is still accepted and entered into the (SQLite)
> database. I would have expected the DAL to refuse the values.
> If I change the constraints from required=True to notnull=True, the empty
> values are not accepted.
>
> Bug or oversight by me?
>
>  --
>
>
>
>

-- 





Re: [web2py] Re: 2.02 Table name in smartgrid changed...

2012-09-05 Thread Paolo Caruccio
Moreover, if you are interested (I don't know if this is documented), you 
could change breadcrumbs divider and assign a css class to breadcrumbs 
itself.

The complete signature for the smartgrid is indeed the following:

SQLFORM.smartgrid( table, 
  constraints=None, 
  linked_tables=None,
  links=None,
  links_in_grid=True,
  args=None, 
  user_signature=True,
  divider='>',
  breadcrumbs_class='',
  **kwargs):
 

Il giorno mercoledì 5 settembre 2012 21:33:29 UTC+2, Adi ha scritto:
>
> thanks Paolo... worked perfectly.
>
> On Wed, Sep 5, 2012 at 1:59 PM, Paolo Caruccio 
> 
> > wrote:
>
>> to display all breadcrumbs in the same line please try to append to 
>> web2py.css following rule
>>
>> li.w2p_grid_breadcrumb_elem {
>> display:inline-block;
>> }
>>
>> in versions >= 2.0.2 web2py.css file has the right rule, so this issue 
>> should arise only with previous experimental versions.
>>
>> Il giorno giovedì 30 agosto 2012 17:29:25 UTC+2, Adi ha scritto:
>>
>>> Smartgrid used to display the table name automatically. Is that supposed 
>>> to be as before?
>>>
>>  -- 
>>  
>>  
>>   
>>
>
>

-- 





[web2py] Re: Connecting to external databases

2012-09-05 Thread Niphlod
if you want to use the dal to retrieve data from your databases you should 
connect to them.

dbmysql = DAL('mysql://...')
dbmmsql = DAL('mssql://...')

What is your issue ?

On Wednesday, September 5, 2012 6:18:23 PM UTC+2, Gregg Branquinho wrote:
>
> I am building a json webservice in web2py and it is being used by many 
> different frontends..
>
> What I am looking to do on the back end is connected to external databases 
> (1 postgre, 2 mssql) and return the correlated data from the different 
> servers to the json client.
>
> What I am struggling with is how to connect to any external database from 
> web2py and should I sue the DAL layer to coonect to all these different 
> servers ??
>
> Any advice would be greatly apprieciated.
>
>
>
> Kind Regards
> GRegg
>

-- 





Re: [web2py] required option in Field

2012-09-05 Thread Marin Pranjić
I don't know why this happens - I always reply from email and it is always 
in the same thread.

Sorry about that.

Dana srijeda, 5. rujna 2012. 22:14:09 UTC+2, korisnik Niphlod napisao je:
>
> IS_NOT_EMPTY() is more "remembereable" .
>
> @Marin: when you reply from your mail client please strip the re: from the 
> subject or in the group it will show as a separate thread. 
>
> On Wednesday, September 5, 2012 10:07:11 PM UTC+2, Marin Pranjić wrote:
>>
>> This should work for other field types as you expect, but empty string is 
>> still valid string value.
>> You can set: requires=IS_LENGTH(minsize=1) to disallow empty strings.
>>
>> On Tue, Sep 4, 2012 at 7:24 PM, Denis Rykov  wrote:
>>
>>> I use the following Field definition:
>>>
>>> Field('admin_unit', required=True, label='Region'),
>>>
>>> But when I create new row through smartgrid interface and leave this 
>>> field empty - validation error not appears and record creates in database. 
>>> If see table in database you can see that 'admin_unit' field contains empty 
>>> string (''). Is it correct? It looks like required options doesn't work 
>>> properly.
>>>  
>>> -- 
>>>  
>>>  
>>>  
>>>
>>
>>

-- 





Re: [web2py] XML Webservice

2012-09-05 Thread Derek

Create a template with xmlservice.xml and add the appropriate fields.

On Wednesday, September 5, 2012 12:50:28 AM UTC-7, Hassan Alnatour wrote:
>
> Dear Derek , 
>
> What should i do then ??
>
> Best Regards,
>
> On Wed, Sep 5, 2012 at 2:01 AM, Derek >wrote:
>
>> It is XML, but it doesn't have a doctype. So, when it gets to this 
>> character:  *’*  it fails to validate against UTF-8. It should probably 
>> be this:  charset=ISO-8859-1 
>>
>>
>> On Tuesday, September 4, 2012 2:15:11 AM UTC-7, Hassan Alnatour wrote:
>>
>>> Dear ALec , 
>>>
>>> when i go to the link i gave you before , i can see some XML data but i 
>>> dont understand what is the viewing problem you are talking about ? and why 
>>> wold a table filed interrupter Viewing as XML  as long as i am returning an 
>>> object that has all the date ?
>>>
>>> Best Regards,
>>>  
>>> On Sun, Sep 2, 2012 at 12:47 PM, hasan alnator <
>>> haln...@gardeniatelco.com> wrote:
>>>
 Dear ALec , 

 when i go to the link i gave you before , i can see some XML data but i 
 dont understand what is the viewing problem you are talking about ? and 
 why 
 wold a table filed interrupter Viewing as XML  as long as i am returning 
 an 
 object that has all the date ?

 Best Regards,
  

 On Sun, Sep 2, 2012 at 12:42 PM, Alec Taylor wrote:

> Hmm, try lower-case 'description'.
>
> Otherwise not sure what's causing the XML viewer problem.
>
> Also nowadays JSON is prefered over XML, as it's much less verbose;
> thus has a much lower overhead
>
> On Sun, Sep 2, 2012 at 7:39 PM, hasan alnator
>  wrote:
> > Dear Alec ,
> >
> > What Do you mean with  preprocessing ?
> >
> > this is my db.py :
> >
> > # -*- coding: utf-8 -*-
> >
> > ##**##**
> #
> > ## This scaffolding model makes your app work on Google App Engine 
> too
> > ## File is released under public domain and you can use without 
> limitations
> > ##**##**
> #
> >
> > ## if SSL/HTTPS is properly configured and you want all HTTP 
> requests to
> > ## be redirected to HTTPS, uncomment the line below:
> > # request.requires_https()
> >
> > if not request.env.web2py_runtime_**gae:
> > ## if NOT running on Google App Engine use SQLite or other DB
> > db = DAL('sqlite://storage.sqlite')
> > else:
> > ## connect to Google BigTable (optional 
> 'google:datastore://namespace'**)
> > db = DAL('google:datastore')
> > ## store sessions and tickets there
> > session.connect(request, response, db = db)
> > ## or store session in Memcache, Redis, etc.
> > ## from gluon.contrib.memdb import MEMDB
> > ## from google.appengine.api.memcache import Client
> > ## session.connect(request, response, db = MEMDB(Client()))
> >
> > ## by default give a view/generic.extension to all actions from 
> localhost
> > ## none otherwise. a pattern can be 'controller/function.**
> extension'
> > response.generic_patterns = ['*'] if request.is_local else []
> > ## (optional) optimize handling of static files
> > # response.optimize_css = 'concat,minify,inline'
> > # response.optimize_js = 'concat,minify,inline'
> >
> > ##**##**
> #
> > ## Here is sample code if you need for
> > ## - email capabilities
> > ## - authentication (registration, login, logout, ... )
> > ## - authorization (role based authorization)
> > ## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
> > ## - old style crud actions
> > ## (more options discussed in gluon/tools.py)
> > ##**##**
> #
> >
> > from gluon.tools import Auth, Crud, Service, PluginManager, 
> prettydate
> > auth = Auth(db, hmac_key=Auth.get_or_create_**key())
> > crud, service, plugins = Crud(db), Service(), PluginManager()
> >
> > ## create all tables needed by auth if not custom tables
> > auth.define_tables()
> >
> > ## configure email
> > mail=auth.settings.mailer
> > mail.settings.server = 'logging' or 'smtp.gmail.com:587'
> > mail.settings.sender = 'y...@gmail.com'
>
> > mail.settings.login = 'username:password'
> >
> > ## configure auth policy
> > auth.settings.registration_**requires_verification = False
> > auth.settings.registration_**requires_approval = False
> > auth.settings.reset_password_**requires_verification = True
> >
> > ## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, 
> etc.
> > ## register with janrain.com, write your domain:api_key in
> > private/jan

[web2py] Re: Accessing id in SQLFORM.process()

2012-09-05 Thread Anthony
Try:

SQLFORM(db.t_account).process(next=URL('account', 'index', args='t_account') 
+ '/[id]')

If you put the variable name in brackets, it (plus the brackets) should get 
replaced with the variable's value.

Also, .process (and .validate) take an "onsuccess" argument, which can be a 
callable:

SQLFORM(...).process(...,
onsuccess=lambda form: redirect(URL('account', 'index', args=[
't_account', form.vars.id])))

Anthony

On Wednesday, September 5, 2012 2:41:44 PM UTC-4, Philip Kilner wrote:
>
> Hi,
>
> I'm trying to wean myself of CRUD and am doing an insert with 
> SQLFORM.process().
>
> I want to redirect on success to view the newly inserted record.
>
> How can I access the ID of the new record in this context? 
>
> Hoped I could do something like: -
>
> SQLFORM(db.t_account).process(next=URL(c='account',f='index', 
> args=['t_account', id]))
>
> --
>
> Cheers,
>
> PhilK
>
>

-- 





Re: [web2py] Updated cheatsheet

2012-09-05 Thread Massimo Di Pierro
I will add the source to the web2py repo.

On Wednesday, 5 September 2012 11:04:02 UTC-5, rif wrote:
>
> Also the cast parameter. Are the sources for the cheatsheet available so 
> we can make patch suggestions?
>
> -rif
>
> miercuri, 5 septembrie 2012, 18:53:45 UTC+3, Massimo Di Pierro a scris:
>>
>> It should
>>
>>
>> On Wednesday, 5 September 2012 09:57:30 UTC-5, rif wrote:
>>>
>>> Maybe the otherwise param should appear in the cheatsheet:
>>> @auth.requires_login(otherwise=URL(...))
>>>
>>>

-- 





[web2py] Re: DB Migration (sqlite->pgsql) Problems with 1.99.7 - 2.0.6 - 2.0.7 Versions

2012-09-05 Thread Massimo Di Pierro
Did you install psycopg2? If not it is probably using pg8000. Can you 
please help us debug? Edit dal.py and in the function log_excecute can you 
print the value of the command variable? What does it print when it fails?

On Wednesday, 5 September 2012 11:29:42 UTC-5, Christian Espinoza wrote:
>
> Hello, I'm in trouble with a webapp that I'have.
>
> I develop it using sqlite only for a best approach of web2py features with 
> it.
>
> And I'm trying to migrate it to a Postgresql DB to put it on Testing phase.
>
> But It doesn't work with PostgreSQL, only work with sqlite, I'd tried with 
>  1.99.7 - 2.0.6 -  2.0.7 Versions
>
> At 2.0.7 and 2.0.6 showme:  invalid literal 
> for int() with base 10: 'SELECT'
>
> At 
>
> Traceback (most recent call last):
>   File "/opt/web-apps/web2py/gluon/restricted.py", line 209, in restricted
> exec ccode in environment
>   File "/opt/web-apps/web2py-2.0.7/applications/sadma/models/db.py" 
> , line 236, in 
> 
> if db(db.auth_user).isempty():
>   File "/opt/web-apps/web2py/gluon/dal.py", line 8722, in isempty
> return not self.select(limitby=(0,1))
>   File "/opt/web-apps/web2py/gluon/dal.py", line 8743, in select
> return adapter.select(self.query,fields,attributes)
>   File "/opt/web-apps/web2py/gluon/dal.py", line 1583, in select
> return self._select_aux(sql,fields,attributes)
>   File "/opt/web-apps/web2py/gluon/dal.py", line 1556, in _select_aux
> self.execute(sql)
>
> My Connection string:
>
> *#db = DAL('sqlite://storage.sqlite')
> db = DAL('postgres://user:pass@localhost/dbapp')**
> *
>
> *Running on Centos 6.0, external Postgresql Server with 9 version, **Python 
> 2.6.6*
>
> *
> *
>
> Thanks in advance
>
> Christian.
>
>

-- 





[web2py] Re: 2.0.6: "Required=True" not enforced by DAL?

2012-09-05 Thread Massimo Di Pierro
required=True means that a value must be provided. For a string merk='' is 
a value.


On Wednesday, 5 September 2012 12:27:05 UTC-5, mjm wrote:
>
> I have created simple table:
>
> db.define_table('hoortoestel', 
> # algemeen
> Field('merk', type='string', required=True, ), 
> Field('type', type='string', required=True, ),
> ...
>
> When trying to enter a new record in appadmin I noticed that when not 
> entering anything in either field, the new record data is accepted and 
> entered into the (SQLlite) database. I think that's a bug. 
> If I change the required constraint to notnull=True, the empty record is 
> indeed rejected, as expected. 
>
>
>

-- 





Re: [web2py] 2.0.6 bug? "required=True" not enforced

2012-09-05 Thread Massimo Di Pierro
No. This was always like this.

On Wednesday, 5 September 2012 15:18:05 UTC-5, Marin Pranjić wrote:
>
> I would expect that both constraints are accepted (empty string is not 
> Null).
>
> Is the behavior different from older versions?
>
> On Wed, Sep 5, 2012 at 7:39 PM, mjm  >wrote:
>
>> I have defined a simple table: 
>>
>> db.define_table('hoortoestel', 
>> # algemeen
>>  Field('merk', type='string', required=True, ), 
>> Field('type', type='string', required=True, ),
>> ...
>>
>> If I then try to enter a new record in appadmin and do not enter anything 
>> for the fields, the record is still accepted and entered into the (SQLite) 
>> database. I would have expected the DAL to refuse the values. 
>> If I change the constraints from required=True to notnull=True, the empty 
>> values are not accepted. 
>>
>> Bug or oversight by me?
>>
>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] Web2Py : JQuery .ajax data sent not present in request.vars

2012-09-05 Thread PlanetUnknown
Trying to make a simple ajax call from the view back to the controller.
It is working, however the data I'm sending isn't coming in the 
request.vars if I sent the contentType="application/json".
I know there is an internal ajax function, but I have my own library with 
these functions I'd like to use.

Here is the code :
http://pastie.textmate.org/4670338 

Pretty sure I'm doing something silly here. Thanks.

-- 





Re: [web2py] CentOS Web2py IOError - Permission denied

2012-09-05 Thread webtest
Yes you are right! disabling it fixed the problem. 
Can you also please point me to a direction where I can learn how to set up 
multiple applications running at the same time with no selinux permission 
issues?
Thanks a lot again for the quick response.

On Wednesday, September 5, 2012 8:40:02 AM UTC-5, Jonathan Lundell wrote:
>
> On 4 Sep 2012, at 9:22 PM, webtest > wrote:
>
> I am running web2py on Centos and used the fedora shell script to do the 
> installation. It did set all my folder/files as apache:apache, did the 
> selinux configuration and such. I have the welcome and examples 
> applications loaded.
> When I run the examples application locally I get no errors (here this 
> makes me think the DAL is set up fine and working) But when I access it 
> online I get the internal error : unknown ticket created message.
> Here is the error log it generates. It looks like a permissions issue but 
> I already verified that all files as set as apache:apache , as it is in my 
> httpd config and the folder/files have write and read permissions.
> What could be the reason for this?
>
>
> If you're very sure about permissions, try disabling selinux, at least as 
> an experiment. 
>
>
> [Tue Sep 04 23:12:49 2012] [error] ERROR:web2py.cache:corrupted file 
> /opt/web-apps/web2py/applications/examples/cache/cache.shelve, will try 
> delete it!
> [Tue Sep 04 23:12:49 2012] [error] WARNING:web2py.cache:unable to delete 
> file /opt/web-apps/web2py/applications/examples/cache/cache.shelve
> [Tue Sep 04 23:12:49 2012] [error] ERROR:web2py:Traceback (most recent 
> call last):
> [Tue Sep 04 23:12:49 2012] [error]   File 
> "/opt/web-apps/web2py/gluon/restricted.py", line 205, in restricted
> [Tue Sep 04 23:12:49 2012] [error] exec ccode in environment
> [Tue Sep 04 23:12:49 2012] [error]   File 
> "/opt/web-apps/web2py/applications/examples/compiled/models/menu.py", line 
> 63, in 
> [Tue Sep 04 23:12:49 2012] [error]   File 
> "/opt/web-apps/web2py/gluon/dal.py", line 6320, in define_table
> [Tue Sep 04 23:12:49 2012] [error] polymodel=polymodel)
> [Tue Sep 04 23:12:49 2012] [error]   File 
> "/opt/web-apps/web2py/gluon/dal.py", line 710, in create_table
> [Tue Sep 04 23:12:49 2012] [error] logfile = 
> self.file_open(table._loggername, 'a')
> [Tue Sep 04 23:12:49 2012] [error]   File 
> "/opt/web-apps/web2py/gluon/dal.py", line 545, in file_open
> [Tue Sep 04 23:12:49 2012] [error] fileobj = 
> portalocker.LockedFile(filename,mode)
> [Tue Sep 04 23:12:49 2012] [error]   File 
> "/opt/web-apps/web2py/gluon/portalocker.py", line 120, in __init__
> [Tue Sep 04 23:12:49 2012] [error] self.file = 
> open(filename,mode.replace('w','a'))
> [Tue Sep 04 23:12:49 2012] [error] IOError: [Errno 13] Permission denied: 
> '/opt/web-apps/web2py/applications/examples/databases/sql.log'
>
>
>
>
>

-- 





Re: [web2py] Web2Py : JQuery .ajax data sent not present in request.vars

2012-09-05 Thread Bruno Rocha
Your URL should have the vars

url: /test01/default/getContent?sourcetitle=xxx

If you do not pass the vars on url you can't get them at the called
controller

-- 





Re: [web2py] Web2Py : JQuery .ajax data sent not present in request.vars

2012-09-05 Thread Nik
Thanks Bruno !
That worked, but now when I get the response back as JSON, JQuery throws an 
error saying the JSON isn't valid. The JSON seems valid to me & also passes 
JSONLint test :

{"readyState":4,"responseText":"FIFA support India for U-17 and 2022 World 
Cup - Times","status":200,"statusText":"OK"} 



On Wednesday, 5 September 2012 17:40:42 UTC-4, rochacbruno wrote:
>
> Your URL should have the vars
>
> url: /test01/default/getContent?sourcetitle=xxx
>
> If you do not pass the vars on url you can't get them at the called 
> controller
>

-- 





Re: [web2py] Web2Py : JQuery .ajax data sent not present in request.vars

2012-09-05 Thread Bruno Rocha
or you call it with .json extension and use the generic json view

url: /test01/default/getContent*.json*?sourceTitle=x

or you do this on the return

import json

def getContent():
titleArg = str(request.vars.sourceTitle)
print "--"
print "--"
print request.vars # Starts working if "contentType" in ajax request
above is commented
print "Getting news content for : " + titleArg
print "--"
print "--"
#rows=db(db.NewsMaster).select(db.NewsMaster.ALL)
"""
"""
myobj = [dict(value=x),dict(value=x), dict(value=x)]
return json.dumps(myobj)



On Wed, Sep 5, 2012 at 6:51 PM, Nik  wrote:

> Thanks Bruno !
> That worked, but now when I get the response back as JSON, JQuery throws
> an error saying the JSON isn't valid. The JSON seems valid to me & also
> passes JSONLint test :
>
> {"readyState":4,"responseText":"FIFA support India for U-17 and 2022 World
> Cup - Times","status":200,"statusText":"OK"}
>
>
>
> On Wednesday, 5 September 2012 17:40:42 UTC-4, rochacbruno wrote:
>>
>> Your URL should have the vars
>>
>> url: /test01/default/getContent?**sourcetitle=xxx
>>
>> If you do not pass the vars on url you can't get them at the called
>> controller
>>
>  --
>
>
>
>

-- 





Re: [web2py] Web2Py : JQuery .ajax data sent not present in request.vars

2012-09-05 Thread Nik
That worked too ! You rock :)

On Wednesday, 5 September 2012 17:58:16 UTC-4, rochacbruno wrote:
>
> or you call it with .json extension and use the generic json view
>
> url: /test01/default/getContent*.json*?sourceTitle=x
>
> or you do this on the return
>
> import json
>
> def getContent():
> titleArg = str(request.vars.sourceTitle)
> print "--"
> print "--"
> print request.vars # Starts working if "contentType" in ajax request 
> above is commented
> print "Getting news content for : " + titleArg
> print "--"
> print "--"
> #rows=db(db.NewsMaster).select(db.NewsMaster.ALL)
> """
> """
> myobj = [dict(value=x),dict(value=x), dict(value=x)]
> return json.dumps(myobj)
>
>
>
> On Wed, Sep 5, 2012 at 6:51 PM, Nik >wrote:
>
>> Thanks Bruno !
>> That worked, but now when I get the response back as JSON, JQuery throws 
>> an error saying the JSON isn't valid. The JSON seems valid to me & also 
>> passes JSONLint test :
>>
>> {"readyState":4,"responseText":"FIFA support India for U-17 and 2022 
>> World Cup - Times","status":200,"statusText":"OK"} 
>>
>>
>>
>> On Wednesday, 5 September 2012 17:40:42 UTC-4, rochacbruno wrote:
>>>
>>> Your URL should have the vars
>>>
>>> url: /test01/default/getContent?**sourcetitle=xxx
>>>
>>> If you do not pass the vars on url you can't get them at the called 
>>> controller
>>>
>>  -- 
>>  
>>  
>>  
>>
>
>
>

-- 





Re: [web2py] Re: DB Migration (sqlite->pgsql) Problems with 1.99.7 - 2.0.6 - 2.0.7 Versions

2012-09-05 Thread Christian Espinoza
Hi Massimo, this is:

*File /opt/web-apps/web2py/gluon/dal.py in log_execute at line 1653*
Code listing

1648.
1649.
1650.
1651.
1652.
1653.

1654.
1655.
1656.
1657.

command = a[0]
if self.db._debug:
logger.debug('SQL: %s' % command)
self.db._lastsql = command
t0 = time.time()
ret = self.cursor.execute(*a, **b)

self.db._timings.append((command,time.time()-t0))
del self.db._timings[:-TIMINGSSIZE]
return ret

Variablesa('SELECT auth_user.id, auth_user.username, auth_u...r.id > 0)
ORDER BY auth_user.id LIMIT 1 OFFSET 0;',)b{}selfretundefinedself.cursorself.cursor.execute>

2012/9/5 Massimo Di Pierro 

> Did you install psycopg2? If not it is probably using pg8000. Can you
> please help us debug? Edit dal.py and in the function log_excecute can you
> print the value of the command variable? What does it print when it fails?
>
> On Wednesday, 5 September 2012 11:29:42 UTC-5, Christian Espinoza wrote:
>>
>> Hello, I'm in trouble with a webapp that I'have.
>>
>> I develop it using sqlite only for a best approach of web2py features
>> with it.
>>
>> And I'm trying to migrate it to a Postgresql DB to put it on Testing
>> phase.
>>
>> But It doesn't work with PostgreSQL, only work with sqlite, I'd tried
>> with  1.99.7 - 2.0.6 -  2.0.7 Versions
>>
>> At 2.0.7 and 2.0.6 showme:  invalid
>> literal for int() with base 10: 'SELECT'
>>
>> At
>>
>> Traceback (most recent call last):
>>   File "/opt/web-apps/web2py/gluon/**restricted.py", line 209, in restricted
>> exec ccode in environment
>>   File "/opt/web-apps/web2py-2.0.7/**applications/sadma/models/db.**py" 
>> , line 236, in 
>> 
>> if db(db.auth_user).isempty():
>>   File "/opt/web-apps/web2py/gluon/**dal.py", line 8722, in isempty
>> return not self.select(limitby=(0,1))
>>   File "/opt/web-apps/web2py/gluon/**dal.py", line 8743, in select
>> return adapter.select(self.query,fiel**ds,attributes)
>>   File "/opt/web-apps/web2py/gluon/**dal.py", line 1583, in select
>> return self._select_aux(sql,fields,at**tributes)
>>   File "/opt/web-apps/web2py/gluon/**dal.py", line 1556, in _select_aux
>> self.execute(sql)
>>
>> My Connection string:
>>
>> *#db = DAL('sqlite://storage.sqlite')
>> db = DAL('postgres://user:pass@localhost/dbapp')**
>> *
>>
>> *Running on Centos 6.0, external Postgresql Server with 9 version, **Python 
>> 2.6.6*
>>
>> *
>> *
>>
>> Thanks in advance
>>
>> Christian.
>>
>>  --
>
>
>
>

-- 





[web2py] sqlform.grid and query conditions

2012-09-05 Thread Kevin C
Basically, we are generating a SQLFORM.grid with the following code:

db.pages.stores_id.default = STORE_DETAILS.id
query = ((db.pages.stores_id == STORE_DETAILS.id))
form = SQLFORM.grid(query=query)

return dict(form=form)

This is working perfectly fine for us.  However, we have noticed that if we 
just change the ID in the query string for the edit page, we are allowed to 
edit other store's entries.

IE 
http://test.oursite.com/test/admin/pages/edit/pages/6?_signature=f8c5560743.
..

What is the proper way to do this, then?  The grid itself looks great, but 
just by changing the page ID in the URL, we are allowed to edit pages not 
belonging to us.  I guess I was hoping that the query conditional would be 
passed to each function (add, edit, delete) but that obviously is not the 
case.  Is multi-tenancy the solution to this issue or are we overlooking 
something simple?

-- 





Re: [web2py] sqlform.grid and query conditions

2012-09-05 Thread Bruno Rocha
You can do:

if request.args(0) in ['edit', 'delete']:
STORE_DETAILS.id == int(request.args(2)) or redirect(URL('default',
'wherever'))

db.pages.stores_id.default = STORE_DETAILS.id
query = ((db.pages.stores_id == STORE_DETAILS.id))
form = SQLFORM.grid(query=query)

return dict(form=form)



On Wed, Sep 5, 2012 at 9:38 PM, Kevin C  wrote:

> Basically, we are generating a SQLFORM.grid with the following code:
>
> db.pages.stores_id.default = STORE_DETAILS.id
> query = ((db.pages.stores_id == STORE_DETAILS.id))
> form = SQLFORM.grid(query=query)
>
> return dict(form=form)
>
> This is working perfectly fine for us.  However, we have noticed that if
> we just change the ID in the query string for the edit page, we are allowed
> to edit other store's entries.
>
> IE
> http://test.oursite.com/test/admin/pages/edit/pages/6?_signature=f8c5560743.
> ..
>
> What is the proper way to do this, then?  The grid itself looks great, but
> just by changing the page ID in the URL, we are allowed to edit pages not
> belonging to us.  I guess I was hoping that the query conditional would be
> passed to each function (add, edit, delete) but that obviously is not the
> case.  Is multi-tenancy the solution to this issue or are we overlooking
> something simple?
>
> --
>
>
>
>

-- 





Re: [web2py] sqlform.grid and query conditions

2012-09-05 Thread Kevin Cackler
We did something similar but it feels very hackish, considering it has 
to be done in every method of the admin controller.  I just wanted to 
see if there was a better way.


Thank you.

Kevin Cackler
Tech Daddies
501-205-1512
http://www.techdaddies.com

On 9/5/2012 7:45 PM, Bruno Rocha wrote:

You can do:

if request.args(0) in ['edit', 'delete']:
STORE_DETAILS.id == int(request.args(2)) or 
redirect(URL('default', 'wherever'))


db.pages.stores_id.default = STORE_DETAILS.id
query = ((db.pages.stores_id == STORE_DETAILS.id))
form = SQLFORM.grid(query=query)

return dict(form=form)



On Wed, Sep 5, 2012 at 9:38 PM, Kevin C > wrote:


Basically, we are generating a SQLFORM.grid with the following code:

db.pages.stores_id.default = STORE_DETAILS.id
query = ((db.pages.stores_id == STORE_DETAILS.id))
form = SQLFORM.grid(query=query)

return dict(form=form)

This is working perfectly fine for us.  However, we have noticed
that if we just change the ID in the query string for the edit
page, we are allowed to edit other store's entries.

IE
http://test.oursite.com/test/admin/pages/edit/pages/6?_signature=f8c5560743.

..

What is the proper way to do this, then?  The grid itself looks
great, but just by changing the page ID in the URL, we are allowed
to edit pages not belonging to us.  I guess I was hoping that the
query conditional would be passed to each function (add, edit,
delete) but that obviously is not the case.  Is multi-tenancy the
solution to this issue or are we overlooking something simple?
-- 






--





--





Re: [web2py] compute fields do not show up in SQLFORM view form

2012-09-05 Thread Alan Etkin
El miércoles, 5 de septiembre de 2012 12:51:06 UTC-3, Massimo Di Pierro 
escribió:
>
> yes please. Did this work in 1.99.7?
>
>
 Ok, the current way is the same as in 1.99.7. SQLFORM output hides by 
default computed fields.

The problem was discussed in this threads before:
https://groups.google.com/d/topic/web2py/f5T_6j7F3kA/discussion
https://groups.google.com/d/topic/web2py/qzVIBFs2ZGI/discussion

"...
Note, by default computed fields are not shown in SQLFORMs, though you can 
explicitly list them among the fields to be shown.

Anthony ..."

But I belive it's not documented in book, so if there's agreement with 
having a visible computed field by default in forms the behavior could be 
changed.

One reason would be to allow the user to provide a value in a form before 
inserting/updating the db record with a computed value. 

Currently calling SQLFORM( filelds=[... "" ...]) 
should show the field but with crud.create the computed field is hidden, 
even if one specifies field.writable as True

-- 





[web2py] Re: Updated cheatsheet

2012-09-05 Thread Cliff Kachinske
Bless you for this.  It helps so much with my advanced case of CRS.

On Tuesday, September 4, 2012 11:12:03 AM UTC-4, Massimo Di Pierro wrote:
>
> http://web2py.com/examples/static/web2py_cheatsheet.pdf
>

-- 





[web2py] Override auth.login()?

2012-09-05 Thread Alec Taylor
I want to override the default auth.login(), so wherever auth.login is 
called my customised login form appears. Here are the customisations I've 
made to it in my view [which works]:

for label in form.elements('label'):
if label[-1]!='Remember me (for 30 days)':
label["_style"] = "display:none;"
email = {"email": "email address",}
pwd = {"password": "password"}for input in form.elements("input[type=text]"):
input["_placeholder"] = email.get(input["_name"], "")for input in 
form.elements("input[type=password]"):
input["_placeholder"] = pwd.get(input["_name"], "")
form.elements('input[type=submit]')[0]["_value"] = "Login"
form.elements('input[type=submit]')[0]["_class"] = "btn btn-large btn-primary"


How can I perform this override?

Thanks for all suggestions,

Alec Taylor

-- 





Re: [web2py] XML Webservice

2012-09-05 Thread hasan alnator
Dear derek,
This is my first time useing web service .. Can you please give me a simple
example of what you are talking about .. How to creat a template .. And how
fo add fields ..

Thank you a lot.


On Sep 5, 2012 11:21 PM, "Derek"  wrote:
>
>
> Create a template with xmlservice.xml and add the appropriate fields.
>
> On Wednesday, September 5, 2012 12:50:28 AM UTC-7, Hassan Alnatour wrote:
>>
>> Dear Derek ,
>>
>> What should i do then ??
>>
>> Best Regards,
>>
>>
>> On Wed, Sep 5, 2012 at 2:01 AM, Derek  wrote:
>>>
>>> It is XML, but it doesn't have a doctype. So, when it gets to this
character:  ’  it fails to validate against UTF-8. It should probably be
this:  charset=ISO-8859-1
>>>
>>>
>>> On Tuesday, September 4, 2012 2:15:11 AM UTC-7, Hassan Alnatour wrote:

 Dear ALec ,

 when i go to the link i gave you before , i can see some XML data but
i dont understand what is the viewing problem you are talking about ? and
why wold a table filed interrupter Viewing as XML  as long as i am
returning an object that has all the date ?

 Best Regards,

 On Sun, Sep 2, 2012 at 12:47 PM, hasan alnator <
haln...@gardeniatelco.com> wrote:
>
> Dear ALec ,
>
> when i go to the link i gave you before , i can see some XML data but
i dont understand what is the viewing problem you are talking about ? and
why wold a table filed interrupter Viewing as XML  as long as i am
returning an object that has all the date ?
>
> Best Regards,
>
>
> On Sun, Sep 2, 2012 at 12:42 PM, Alec Taylor 
wrote:
>>
>> Hmm, try lower-case 'description'.
>>
>> Otherwise not sure what's causing the XML viewer problem.
>>
>> Also nowadays JSON is prefered over XML, as it's much less verbose;
>> thus has a much lower overhead
>>
>> On Sun, Sep 2, 2012 at 7:39 PM, hasan alnator
>>  wrote:
>> > Dear Alec ,
>> >
>> > What Do you mean with  preprocessing ?
>> >
>> > this is my db.py :
>> >
>> > # -*- coding: utf-8 -*-
>> >
>> >
#
>> > ## This scaffolding model makes your app work on Google App Engine
too
>> > ## File is released under public domain and you can use without
limitations
>> >
#
>> >
>> > ## if SSL/HTTPS is properly configured and you want all HTTP
requests to
>> > ## be redirected to HTTPS, uncomment the line below:
>> > # request.requires_https()
>> >
>> > if not request.env.web2py_runtime_gae:
>> > ## if NOT running on Google App Engine use SQLite or other DB
>> > db = DAL('sqlite://storage.sqlite')
>> > else:
>> > ## connect to Google BigTable (optional
'google:datastore://namespace')
>> > db = DAL('google:datastore')
>> > ## store sessions and tickets there
>> > session.connect(request, response, db = db)
>> > ## or store session in Memcache, Redis, etc.
>> > ## from gluon.contrib.memdb import MEMDB
>> > ## from google.appengine.api.memcache import Client
>> > ## session.connect(request, response, db = MEMDB(Client()))
>> >
>> > ## by default give a view/generic.extension to all actions from
localhost
>> > ## none otherwise. a pattern can be 'controller/function.extension'
>> > response.generic_patterns = ['*'] if request.is_local else []
>> > ## (optional) optimize handling of static files
>> > # response.optimize_css = 'concat,minify,inline'
>> > # response.optimize_js = 'concat,minify,inline'
>> >
>> >
#
>> > ## Here is sample code if you need for
>> > ## - email capabilities
>> > ## - authentication (registration, login, logout, ... )
>> > ## - authorization (role based authorization)
>> > ## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
>> > ## - old style crud actions
>> > ## (more options discussed in gluon/tools.py)
>> >
#
>> >
>> > from gluon.tools import Auth, Crud, Service, PluginManager,
prettydate
>> > auth = Auth(db, hmac_key=Auth.get_or_create_key())
>> > crud, service, plugins = Crud(db), Service(), PluginManager()
>> >
>> > ## create all tables needed by auth if not custom tables
>> > auth.define_tables()
>> >
>> > ## configure email
>> > mail=auth.settings.mailer
>> > mail.settings.server = 'logging' or 'smtp.gmail.com:587'
>> > mail.settings.sender = 'y...@gmail.com'
>>
>> > mail.settings.login = 'username:password'
>> >
>> > ## configure auth policy
>> > auth.settings.registration_requires_verification = False
>> > auth.settings.registration_requires_approval = False
>> > auth.settings.reset_password_requires_verification 

[web2py] Why would I use DIV classes/helpers, over an html template?

2012-09-05 Thread luckysmack
Traditionally, for html templates, I would do something like this in a 
template.php file (i am coming from php):

**
*Hello *
**

and reading through the docs for web2py, I see the classes like DIV(), 
which i can then add id's, classes, and other attributes to, to be 
rendered. Which seems odd to me. Ive always had the mindset that I shouldnt 
mix html template and logic. minus things like for loops and such. and in 
my code, I shouldnt generate html. Mixing them, to me at least, makes it 
harder for designers to go into the templates to style things and change 
id's, classes. I also tend not to use ids/classes for structure. lately i 
have been using things like data attributes to help with structure or 
looping through things. this way if styles change and id's/classes change, 
functionality is not broken.

So should I still think that way? Should I not use DIV and the other html 
helper classes in my templates? or is there a use case where I would to 
that.

If there is, I am curious to see/hear about some use cases or examples of 
why I would use them in templates, or use them in controllers to generate 
html.

or am I just thinking about them wrong somehow. if they should be used in a 
different way, how should I use them.

Thanks.

-- 





Re: [web2py] Re: Limit Length column

2012-09-05 Thread Mandar Vaze / मंदार वझे
Anthony,

I guess the following will apply to ALL the sqlform.grid in the app,
correct ?
Generally, we have multiple different sqlform.grid across the app, and each
instance may have different columns (and thus possible needing different
column widths)

I am looking for something like "maxtextlengths" which can be changed "per
sqlform.grid" instance

-Mandar

On Wed, Sep 5, 2012 at 8:01 PM, Anthony  wrote:

> If you want to control the column widths and allow the content to wrap if
> necessary, you can do so with CSS (and some JS in IE). Let's say you want
> to set the width of the 5th column. To support IE, in Javascript do:
>
> 
> $(function() {
> $('.ie .web2py_table td:nth-child(5)').addClass('td-wrap');
> });
> 
>
> Then in CSS:
>
> .web2py_table td:nth-child(5), .web2py_table td.td-wrap {
> min-width: 15em; max-width: 20em; white-space: normal !important;
> }
>
> Anthony
>
> On Wednesday, September 5, 2012 10:06:41 AM UTC-4, Mandar Vaze wrote:
>>
>> Using maxtextlengths optional parameter partially helps.
>> http://web2py.com/books/**default/chapter/29/07?search=**maxtextlengths
>>
>> I say partially because this param controls how many characters are
>> displayed in the column (Only those many characters are sent by the server)
>> If one has too many wide columns, result could be ugly, especially
>> buttons in last column are now shown vertically - depending on screen size
>> etc.
>>
>> I wish there was way to control the column width via web2py
>>
>> -Mandar
>>
>> On Tuesday, September 4, 2012 12:35:55 AM UTC+5:30, Ovidio Marinho wrote:
>>>
>>> how to limit the size of columns in sqlform.grid
>>> 25
>>>40
>>> 15
>>> 1 col lenght 25  
>>> ==**=
>>> =
>>> 2 col lenght 40
>>> 3 col lenght 15
>>> etc...
>>>
>>>
>>>
>>>
>>>
>>>Ovidio Marinho Falcao Neto
>>> Web Developer
>>>  ovid...@gmail.com
>>>   ovidio...@itjp.net.br
>>>  ITJP - itjp.net.br
>>>83   8826 9088 - Oi
>>>83   9334 0266 - Claro
>>> Brasil
>>>
>>>
>>>   --
>
>
>
>

-- 





[web2py] Re: web2py login redirect

2012-09-05 Thread Yebach
I searched if I call the auth.register() function, but i don't. not in 
view, not in controler not in model. I have absolutely no idea what could 
and where is the problem

On Wednesday, September 5, 2012 2:15:40 PM UTC+2, Yebach wrote:
>
> Hello
>
> My login function doesn't work. After I try to login i am redirected to 
> user/user/profile instead back to my main page /school/index.html
> Register works, everything
> Also, if I login and enter the url where I should be redirected again I am 
> redirected to /user/user/profile
>
> any suggestion??
>
> Thank you
>

--