[web2py] Re: plugin_wiki - Ajax to save pages?

2010-07-30 Thread mdipierro
Good idea. I'll take the patch.

On Jul 29, 7:44 pm, Bruno Rocha rochacbr...@gmail.com wrote:
  to save a page in plugin_wiki page editor, we have to submit the page or
 focus in page title then hit enter.

 As I am writing large pages, I have 2 displays when editing a page, first to
 edit the code, and the other to frequently refresh and view the result.

 It is so annoying to submit the page every time I need to have a preview, is
 there any way to save the page code via Ajax, just like appadmin edit_area ?

 or may be, to have a preview panel, as you can see when editing a slice on 
 web2pyslices.com or the one used to edit markdown in jottit.com

 Tks

 --

 http://rochacbruno.com.br


[web2py] Re: question/suggestion about URL, controller

2010-07-30 Thread mdipierro
You are right but it only breaks backward compatibility in a case
where things would be misleading. Here are some example:

# old syntax that still works
URL('a','c','f')
URL(a='a',c='c',f='f')
URL(f='f',r=request)

#new syntax that resulted in an error before
URL('f')
URL('c','f')
URL(f='f')
URL(c='c',f='f')

## changed of behaviour
URL('a',r=request)
was /a/current_controller/current_function
now
was /current_app/current_controller/a

I.e. the change of behavior only occurs if the user explicitly
specifies r and a (without naming a)  but not f. I.e. if the user is
specifying redundant information that may be conflicting (because a
may differ from r.application). Users should not be doing this anyway.
I have never seen anybody doing this.

Did I miss something? can you see any other case when the behavior
would change?

What do other people think?

Massimo












On Jul 29, 8:27 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 Massimo, you cannot

 I am sorry but that would break backwards compatibility.

 Say if in certain apps you have this (in alot of the earlier apps on
 web2py.com do this too)

 URL(request.application, 'static', 'logo.png')

 Or

 URL(request.application, 'default', 'index')

 Unfortunately, we cannot re-arrange the variables defined in URL from this 
 order

 def URL(
     a=None,
     c=None,
     f=None,
     r=None,
     args=[],
     vars={},
     anchor='',
     extension=None,
     env=None
     ):

 --
 Thadeus

 On Thu, Jul 29, 2010 at 8:23 PM, Michele Comitini

 michele.comit...@gmail.com wrote:
  thumbs up!

  2010/7/30 mdipierro mdipie...@cs.depaul.edu

  I took it one step further...

   URL()
  /app/default/index
   URL('test')
  /app/default/test
   def test(): return 'test'
   URL(test)
  /app/default/test
   URL('static','filename')
  /app/static/filename
   URL('other','static','filename')
  /other/static/filename

  No more r=, c=, f= needed but all optional.

  On Jul 28, 6:28 pm, Thadeus Burgess thade...@thadeusb.com wrote:
   SORRY! =D

   --
   Thadeus

   On Wed, Jul 28, 2010 at 6:22 PM, mdipierro mdipie...@cs.depaul.edu
   wrote:
WOW. Uploading to trunk. Now I need to revise the book again. :-(

On Jul 28, 5:51 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 URL(r=request, c='hello', f='world', args=['hi'],
 vars={'q':'greetings'}, anchor='the_world')

'/welcome/hello/world/hi#the_world?q=greetings' URL(c='hello',
f='world', args=['hi'], vars={'q':'greetings'}, anchor='the_world')

'/welcome/hello/world/hi#the_world?q=greetings'

Attached is the diff

This should not effect any current usages of URL, but from this point
forward we shouldn't have to specify r=request!

--
Thadeus

On Wed, Jul 28, 2010 at 5:21 PM, mdipierro mdipie...@cs.depaul.edu
wrote:
 ok

 On Jul 28, 4:52 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 For a little more advanced version of what Massimo just posted:

 This allows you to use both.

 URL(r=request, c=controller, f=.)
 and
 URL(c=controller, f=function.)

 http://packages.python.org/web2py_utils/init.html#gurlhttp://hg.thade..

 The reason we have to pass the request to URL each time is because
 it
 is just imported into the context. Since it is just a python
 function,
 it has no knowledge of request.

 Why can't we do something like gURL from within web2py? When
 building
 the context, why can't we make URL a loaded function that will get
 request passed to it, exactly how gURL works.

 Effectively, we won't have to pass request into URL function
 anymore... ever.

 If your interested, I can work on the patch.

 --
 Thadeus

 On Wed, Jul 28, 2010 at 3:56 PM, mdipierro
 mdipie...@cs.depaul.edu wrote:
  1) It is a bit more complex because of static, appadmin, and
  admin.
  You can map

  /function/var1/var2

  into

  /app/controller/function/var1/var2

  using a file routes.py
   --- begin file
  routes_in=[
   ('/admin/$anything','/admin/$anything'),
   ('/static/$anything','/app/static/$anything'),
   ('/appadmin/$anything','/app/appadmin/$anything'),
   ('/$anything','/app/default/$anything'),
  ]
  routes_out=[(y,x) for (x,y) in routes_in]
  - end file

  2) in db.py define

  def url(f,args={},vars={}):
       return URL(r=request,f=f,args=args,vars=vars)
  def go(f,args={},vars={},flash=''):
       session.flash=flash
       return go(url(f=f,args=args,vars=vars))

  and use

     url('index')

  or

    go('index',flash='you are being redirected')

  I do it all the time

  On Jul 28, 3:29 pm, VP vtp2...@gmail.com wrote:
  I'm a newbie, so my questions probably have easy answers, but
  anyway.
  Among a few things, there are two I don't understand and think
  can be
  simplified.

  1. this url:   

[web2py] Re: plugin_wiki - how to define the target to an external link?

2010-07-30 Thread mdipierro
not at this time. It seems the wiki language should not assume the
ability of accessing other windows.

On Jul 29, 8:46 pm, Bruno Rocha rochacbr...@gmail.com wrote:
 Any way to define the target=_blank for  [[a linkhttp://someurl.com]]

 any way like this: [[a linkhttp://someurl.com_blank;]] ???

 --

 http://rochacbruno.com.br


[web2py] Re: plugin_wiki - how to define the target to an external link?

2010-07-30 Thread mdipierro
You can use the extra parameters to define behaviour yourself

``link http://``:link_target_blank

extra = {'link_target_blank':lambda x: 'a href=%s target=_blank
%s/a' % (x.rsplit(' ',1)[1],x.rsplit(' ',1)[0])

On Jul 29, 8:46 pm, Bruno Rocha rochacbr...@gmail.com wrote:
 Any way to define the target=_blank for  [[a linkhttp://someurl.com]]

 any way like this: [[a linkhttp://someurl.com_blank;]] ???

 --

 http://rochacbruno.com.br


[web2py] Flash security

2010-07-30 Thread elffikk
I know that web2py aims to be secure, but if you use it with  amfrpc
service that could be interesting to read

http://www.ivizsecurity.com/blog/web-application-security/testing-flash-applications-pen-tester-guide/


[web2py] Re: Flash security

2010-07-30 Thread mdipierro
Thanks. From a quick read the issue is that amf callbacks should
authenticate the user. The @auth.requires_login() should work for
myamf callbacks although  never used it myself.

Massimo

On Jul 30, 2:25 am, elffikk elff...@gmail.com wrote:
 I know that web2py aims to be secure, but if you use it with  amfrpc
 service that could be interesting to read

 http://www.ivizsecurity.com/blog/web-application-security/testing-fla...


Re: [web2py] Re: Whats wrong with orderby, bug??

2010-07-30 Thread Phyo Arkar
Thanks Massimo!!!

On 7/30/10, mdipierro mdipie...@cs.depaul.edu wrote:
 orderby = db.cdsdata[request.vars.sidx]
 ... db( db.casedb.id  0 ).select( orderby = orderby ):

 looks to me you are selecting db.casedb but pretend to order by
 db.cddata.

 On Jul 30, 3:16 am, Phyo Arkar phyo.arkarl...@gmail.com wrote:
 Here is my function:

 in controller:
 def rows():

     fields = ['id', 'filePath', 'fileName', 'cus', 'sentto',
 'emailFrom', 'subject','cc','bcc','extracted','headers']
     rows = []
     page = int( request.vars.page )

     max=request.vars.totalrows
     if max:
         pagesize = int(max)
     else:
         pagesize = int( request.vars.rows )
     limitby = ( page * pagesize - pagesize, page * pagesize )
     orderby = db.cdsdata[request.vars.sidx]
     print orderby
     if request.vars.sord == 'desc':
         orderby = ~orderby
     if max:
         for r in db( db.casedb.id  0 ).select( limitby = limitby,
 orderby = orderby ):
             vals = []
             for f in fields:
                 vals.append( r[f] )
             rows.append( dict( id = r.id, cell = vals ) )
     else:
         for r in db( db.casedb.id  0 ).select(orderby = orderby):
             vals = []
             for f in fields:
                 vals.append( r[f] )
             rows.append( dict( id = r.id, cell = vals ) )

     total = db( db.casedb.id  0 ).count()
     pages = int( total / pagesize )
     #if total % pagesize == 0: pages -= 1
     data = dict( total = pages, page = page, rows = rows )
     return data

 in view:

 I call from jqGrid using:

     url:{{=URL(r=request,f='rows.json')}},

 here , i have an error in orderby caluse :

 OperationalError: (1054, Unknown column 'cdsdata.id' in 'order clause')

 I had use similar jqgrid , before in 1.7x version , it worked well.I
 reuse the same code here.
 also i make sure inside mysql , i thave id column for sure!

 i have this after updating to 1.81.4


[web2py] Re: reset password mail as html mail

2010-07-30 Thread Rohan
Thanks Massimo,

I copied the send() api to my tools.py and it worked.


On Jul 30, 3:03 am, mdipierro mdipie...@cs.depaul.edu wrote:
 Please try the code in trunk. If the message is 'html/html' it
 should be sent automatically in html.

 On Jul 29, 3:00 am, Rohan yourbuddyro...@gmail.com wrote:



  I need to send reset password mail as html, so i created

  in db.py

  auth.messages.reset_password = [None, htmlSome html + Click on
  below link to reset your password\n\n
  http://'+request.env.http_host+URL(r=request,c='account',f='user',args=['re 
  set_password'])+'/%(key)s
  /html]

  in tools.py request_reset_password api, tries to generate key and
  substitute in the message above

  self.settings.mailer.send(to=form.vars.email,

  subject=self.messages.reset_password_subject,

  message=self.messages.reset_password % \

  dict(key=reset_password_key))

  but in case of reset_password message is tuple or list, the above
  substitution will result in an error.

  Any pointers how to send html message?


Re: [web2py] Re: Why I hate Django by Cal Henderson

2010-07-30 Thread Michele Comitini
3) black magic IMHO.  Would be nice to have some well defined path for the
programmer to work on this, so
   that it could be seen as a separate layer for db configuration/tuning so
that models can be left almost untouched
   on architectural changes.



2010/7/29 mdipierro mdipie...@cs.depaul.edu

 The speaker raises some good issue with Django and some do apply to
 web2py

 Aside for the many jokes which are indeed funny he complains about
 scalability and make these valid points:

 1) session should be stored client side for scalability (web2py and
 Django both store them server side, although it it would be trivial to
 have a client side option and it is on my todo list, I will take a
 patch if somebody does this first)

 2) it is important to be able to connect to multiple databases
 depending on the request (Django cannot do it, web2py can) I also just
 added a modification in trunk that allows to do:

   db=DAL([uri1,uri2,uri3])

 and it will try to connect to uri1, then uri2, then uri3. Of course
 you can do

   db=DAL(random_permute(uri1,uri2,uri3))

 to share the load at random. web2py will also try them all in case of
 failure and re-try 5 times.

 3) it would be nice if the ORM and DAL were to be smart about de-
 normalization and about multiple db connection. There is a lot that
 can be done in this direction. web2py allows an easy API to
 denormalize many2many:

   # define some shortcuts
   D,F=db.define_table, Field
   # define a table dog, a person, and ownership
   d=D('dog',F('name'))
   p=D('person',F('name'),F('dogs'))
   L=D('ownership',F('person',p),F('dog',d))
   # denormalize p.dogs
   p.dogs.requires=IS_IN_DB(db,d.id,d.name,multiple=True)
   # p.dogs will be used in forms, when it changes update L
   def f(form):
 db(L.person==form.vars.id).delete()
 [L.insert(person=form.var.id,dog=k) for k in
 form.request_vars.dogs]
   crud.settings.create_onaccept.person.append(f)
   crud.settings.update_onaccept.person.append(f)

 In principle  the job of the last 5 lines could be automated and be
 done under the hood (what the user speaks about). It would be too much
 magic but it would be convenient. We have been discussing some of
 this.

 On Jul 29, 2:53 pm, Vidul Petrov vidul.r...@gmail.com wrote:
  Django (the opposite of RoR) sucks likes RoR (the Denmark salesman vs
  the desparate Kanzas Python programmers ambitions to create everything
  out of nothing).
 
  Probably you know what's the definition of the Nobel winners for
  intellect - adequacy.
 
  And in order to achieve adequacy we need compromises - web2py.
 
  On Jul 29, 7:08 pm, Wobmofo muito...@gmail.com wrote:
 
   Cal Henderson delivered a very enterteining keynote at DjangoCon 2008.
   Go watch the video if you haven't, it's really funny !
 http://www.youtube.com/watch?v=i6Fr65PFqfk



[web2py] New features not documented in PDF book (2 ed)

2010-07-30 Thread DenesL
New features not documented in the PDF book (2nd edition)
as highlights in release order sequence (newest to oldest).

If you find posts detailing the use of a specific feature
in this list, email me to add them to the next revision.

You can contribute by updating the online book
http://web2py.com/book

1.81.5
- fixed memcache that broke a few versions ago
- fixed a process starvation issue with the built-in web server.
  This caused occasionally slow response time on high traffic.
  The fix is temporary but seems to be effective.
http://groups.google.com/group/web2py/msg/57c87f1229346db5

video about latest developments (a bit noisy)
http://www.vimeo.com/13485916

1.81.4
- crud forms work with .load now.
- Usual bug-fixes.
http://groups.google.com/group/web2py/msg/6ea765ac301984c3

1.81.2
- bug fix for 1.81.1

1.81.1
*** DO NOT USE, auth broken ***
This is an important release.
There are many small but very important changes:
- New welcome app: better look, superfish menu and jQuery 1.4.2
- Increased security. It means you can place {{=}} inside
  tag attributes without worry about injections.
- RPX slice code moved into web2py core.
- Usual bug-fixes.
http://groups.google.com/group/web2py/msg/2549ac3ec205caf0

1.80.1
- MARKMIN helper (no backward compatibility promise yet)
- self._last_reference (no backward compatibility promise yet)
- IS_EQUAL_TO
- zh-tw and better internationalization page
- better crud.search
- Rocket interfaces
- db.table.field.uploadseparate=True
- SCOPE_IDENTITY for MSSQL
- fixed email attachment issue
- fixed problem with groupby and IS_IN_DB
- other bug fixes
- new implementation for local_import
- ajax(..,...,null)
- fixed Chrome bug in calendar.js
- experimental scrips/web2py-setup-fedora.sh
- generic.load
http://groups.google.com/group/web2py/msg/0d1d902cfacf073a

1.79.2
- fixed simplejson version conflict
http://groups.google.com/group/web2py/msg/2cfecc49b8c823ce

1.79.1
- x509 emails
- attachment and html in Mail on GAE
- fixed docstring in SQLTABLE
- TAG(html) parse html into helpers
  (experimental, still some problems with unicode)
- DIV.elements(find=re.compile())
- DIV.flatten()
- DIV.elements('') supports jQuery syntax in ''
- better it-it.py and it.py
Many bug fixes:
- improved support for DAL and joins in postgresql/oracle
- bug fixes in html.py
- fixed an issue with registration_key==None
- fixed bug in gql.py
- fixed problem with multiple and checkboxes
- fixed bug in GAE
- restored 2.4 compatibility
- auth.update() when pictures in profile
- formstyle can be a function
- escape in sanitizer
- add missing settings
- find and exclude return empty Rows instead of []
- simplejson 2.1.1 should fix compatibility problems
- added sms_utils and Authorize.net in contrib
http://groups.google.com/group/web2py/msg/a4ba611b04a1cd85

1.78.1
- new template system allows {{block name}}{{end}}
- fixed mime headers in emails, included PGP in emails
- automatic database retry connect when pooling and lost connections
- OPTGROUP helper
- web2py_ajax_trap captures all form submissions
- multicolumn checkwidget and arbitrary chars in multiple IS_IN_SET
- Québécois for welcome
- crud.search()
- DAL(...migrate,fake_migrate)

1.77.3
small fixes and code cleanup
(no post announcing it)

1.77.2
fixed z-index in calendars
http://groups.google.com/group/web2py/msg/5b1e436c7bd281a9

1.77.1
- Replaced CherryPy with Rocket web server
- CacheOnDisk allows to specify a folder
  http://groups.google.com/group/web2py/msg/3d73aca7763d53c2
- IS_DATE/DATETIME can handle any year since 0
- SQLTABLE(...,headers='fieldname:capitalize')
- Field().with_alias
- has_membership(group=...,role=...)
- db.define_table(username=True)
- gluon.tools.prettydate
- can specify hostname in routes_out (same syntax as routes in)
- db.table.bulk_insert([...records...]) now works on GAE
- IS_EMAIL validates on 'localhost'
- welcome/views/layout.html uses ez.css
- mail attachments support utf8
- works with PyPy
- better Firebird support
- better Oracle support
- cron supports days of week
- SQLFORM(...,formstyle=table3cols)
  or table2cols or divs or ul
  http://groups.google.com/group/web2py/msg/9823ffc7410fd3e4
- crud.settings.formstyle
- web2py.py -f folder allows to specify locations of applications
- better/faster regex in template works in Jython
- fixed lots of small bugs
http://groups.google.com/group/web2py/msg/cf4baa5b7a5f73be

1.76.5
Fixed a typo in auth that created some registration problems
(no post announcing it)

1.76.4
- SQLTABLE(db(db.auth_user.id0).select(),
headers='fieldname:capitalize')
- Oracle limitby improved
- fixed migrations in Firebird
- gluon/contrib/login_methods/linkedin_account.py
- cron/newcron fixes
(no post announcing it)

1.76.3
repost of 1.76.2 with crud captcha fix
http://groups.google.com/group/web2py/browse_thread/thread/658c72a8c08040d9#

1.76.2
*** use 1.76.3 ***
Main changes include:
1) major fix in cron (yet again)
2) auth.settings.login_captcha and 

[web2py] [Feature Request] js mimifier

2010-07-30 Thread Michele Comitini
1) it is nice to have the ability to debug javascript that comes with
web2py.
2) it is a waste of bandwith to send full script.

You can partially solve 2) if you work behind  web server capable of sending
compressed/gzip contents to clients willing to accept it,
so that you can put all your jscript libraries human readable and have them
compressed on the fly before transmission.

Anyway IMHO web2py can do much better by using a mimifier similar to this:
http://www.crockford.com/javascript/jsmin.py.txt

The idea would be that in production mode a mimified version is generated of
js inside the static dir once, else static js is served
unchanged and debuggable.

mic


Re: [web2py] Re: question/suggestion about URL, controller

2010-07-30 Thread rochacbruno
I have a lot of code wrote in this sintax, But, ig its wrong, no problem to 
replace.

Will this still works?

_href=URL(request.application,'plugin_wiki','page',args=[row,])

Sent from my iPhone

On 30/07/2010, at 04:05, mdipierro mdipie...@cs.depaul.edu wrote:

 You are right but it only breaks backward compatibility in a case
 where things would be misleading. Here are some example:
 
 # old syntax that still works
 URL('a','c','f')
 URL(a='a',c='c',f='f')
 URL(f='f',r=request)
 
 #new syntax that resulted in an error before
 URL('f')
 URL('c','f')
 URL(f='f')
 URL(c='c',f='f')
 
 ## changed of behaviour
 URL('a',r=request)
 was /a/current_controller/current_function
 now
 was /current_app/current_controller/a
 
 I.e. the change of behavior only occurs if the user explicitly
 specifies r and a (without naming a)  but not f. I.e. if the user is
 specifying redundant information that may be conflicting (because a
 may differ from r.application). Users should not be doing this anyway.
 I have never seen anybody doing this.
 
 Did I miss something? can you see any other case when the behavior
 would change?
 
 What do other people think?
 
 Massimo
 
 
 
 
 
 
 
 
 
 
 
 
 On Jul 29, 8:27 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 Massimo, you cannot
 
 I am sorry but that would break backwards compatibility.
 
 Say if in certain apps you have this (in alot of the earlier apps on
 web2py.com do this too)
 
 URL(request.application, 'static', 'logo.png')
 
 Or
 
 URL(request.application, 'default', 'index')
 
 Unfortunately, we cannot re-arrange the variables defined in URL from this 
 order
 
 def URL(
 a=None,
 c=None,
 f=None,
 r=None,
 args=[],
 vars={},
 anchor='',
 extension=None,
 env=None
 ):
 
 --
 Thadeus
 
 On Thu, Jul 29, 2010 at 8:23 PM, Michele Comitini
 
 michele.comit...@gmail.com wrote:
 thumbs up!
 
 2010/7/30 mdipierro mdipie...@cs.depaul.edu
 
 I took it one step further...
 
 URL()
 /app/default/index
 URL('test')
 /app/default/test
 def test(): return 'test'
 URL(test)
 /app/default/test
 URL('static','filename')
 /app/static/filename
 URL('other','static','filename')
 /other/static/filename
 
 No more r=, c=, f= needed but all optional.
 
 On Jul 28, 6:28 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 SORRY! =D
 
 --
 Thadeus
 
 On Wed, Jul 28, 2010 at 6:22 PM, mdipierro mdipie...@cs.depaul.edu
 wrote:
 WOW. Uploading to trunk. Now I need to revise the book again. :-(
 
 On Jul 28, 5:51 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 URL(r=request, c='hello', f='world', args=['hi'],
 vars={'q':'greetings'}, anchor='the_world')
 
 '/welcome/hello/world/hi#the_world?q=greetings' URL(c='hello',
 f='world', args=['hi'], vars={'q':'greetings'}, anchor='the_world')
 
 '/welcome/hello/world/hi#the_world?q=greetings'
 
 Attached is the diff
 
 This should not effect any current usages of URL, but from this point
 forward we shouldn't have to specify r=request!
 
 --
 Thadeus
 
 On Wed, Jul 28, 2010 at 5:21 PM, mdipierro mdipie...@cs.depaul.edu
 wrote:
 ok
 
 On Jul 28, 4:52 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 For a little more advanced version of what Massimo just posted:
 
 This allows you to use both.
 
 URL(r=request, c=controller, f=.)
 and
 URL(c=controller, f=function.)
 
 http://packages.python.org/web2py_utils/init.html#gurlhttp://hg.thade..
 
 The reason we have to pass the request to URL each time is because
 it
 is just imported into the context. Since it is just a python
 function,
 it has no knowledge of request.
 
 Why can't we do something like gURL from within web2py? When
 building
 the context, why can't we make URL a loaded function that will get
 request passed to it, exactly how gURL works.
 
 Effectively, we won't have to pass request into URL function
 anymore... ever.
 
 If your interested, I can work on the patch.
 
 --
 Thadeus
 
 On Wed, Jul 28, 2010 at 3:56 PM, mdipierro
 mdipie...@cs.depaul.edu wrote:
 1) It is a bit more complex because of static, appadmin, and
 admin.
 You can map
 
 /function/var1/var2
 
 into
 
 /app/controller/function/var1/var2
 
 using a file routes.py
  --- begin file
 routes_in=[
  ('/admin/$anything','/admin/$anything'),
  ('/static/$anything','/app/static/$anything'),
  ('/appadmin/$anything','/app/appadmin/$anything'),
  ('/$anything','/app/default/$anything'),
 ]
 routes_out=[(y,x) for (x,y) in routes_in]
 - end file
 
 2) in db.py define
 
 def url(f,args={},vars={}):
  return URL(r=request,f=f,args=args,vars=vars)
 def go(f,args={},vars={},flash=''):
  session.flash=flash
  return go(url(f=f,args=args,vars=vars))
 
 and use
 
url('index')
 
 or
 
   go('index',flash='you are being redirected')
 
 I do it all the time
 
 On Jul 28, 3:29 pm, VP vtp2...@gmail.com wrote:
 I'm a newbie, so my questions probably have easy answers, but
 anyway.
 Among a few things, there are two I don't understand and think
 can be
 simplified.
 
 1. this 

[web2py] Re: question/suggestion about URL, controller

2010-07-30 Thread mdipierro
Yes. Your example will work.

The only case in where you would get wrong behaviour if you do:

URL('otherapp',r=request) (*)
or
URL('otherapp','othercontroller',r=request) (**)

I.e. if you say the URL is in the current request (r=request) and stil
you specify the 'otherapp' and/or the 'othercontroller' but not a
'otherfunction'. If you specify a function either by

URL('otherapp','othercontroller','otherfunction',...)
or
URL(..,f='otherfunction',...)

there is no change of behavior.

I argue that (*) and (**) where wrong because misleading to begin
with.





On Jul 30, 7:18 am, rochacbruno rochacbr...@gmail.com wrote:
 I have a lot of code wrote in this sintax, But, ig its wrong, no problem to 
 replace.

 Will this still works?

 _href=URL(request.application,'plugin_wiki','page',args=[row,])

 Sent from my iPhone

 On 30/07/2010, at 04:05, mdipierro mdipie...@cs.depaul.edu wrote:

  You are right but it only breaks backward compatibility in a case
  where things would be misleading. Here are some example:

  # old syntax that still works
  URL('a','c','f')
  URL(a='a',c='c',f='f')
  URL(f='f',r=request)

  #new syntax that resulted in an error before
  URL('f')
  URL('c','f')
  URL(f='f')
  URL(c='c',f='f')

  ## changed of behaviour
  URL('a',r=request)
  was /a/current_controller/current_function
  now
  was /current_app/current_controller/a

  I.e. the change of behavior only occurs if the user explicitly
  specifies r and a (without naming a)  but not f. I.e. if the user is
  specifying redundant information that may be conflicting (because a
  may differ from r.application). Users should not be doing this anyway.
  I have never seen anybody doing this.

  Did I miss something? can you see any other case when the behavior
  would change?

  What do other people think?

  Massimo

  On Jul 29, 8:27 pm, Thadeus Burgess thade...@thadeusb.com wrote:
  Massimo, you cannot

  I am sorry but that would break backwards compatibility.

  Say if in certain apps you have this (in alot of the earlier apps on
  web2py.com do this too)

  URL(request.application, 'static', 'logo.png')

  Or

  URL(request.application, 'default', 'index')

  Unfortunately, we cannot re-arrange the variables defined in URL from this 
  order

  def URL(
      a=None,
      c=None,
      f=None,
      r=None,
      args=[],
      vars={},
      anchor='',
      extension=None,
      env=None
      ):

  --
  Thadeus

  On Thu, Jul 29, 2010 at 8:23 PM, Michele Comitini

  michele.comit...@gmail.com wrote:
  thumbs up!

  2010/7/30 mdipierro mdipie...@cs.depaul.edu

  I took it one step further...

  URL()
  /app/default/index
  URL('test')
  /app/default/test
  def test(): return 'test'
  URL(test)
  /app/default/test
  URL('static','filename')
  /app/static/filename
  URL('other','static','filename')
  /other/static/filename

  No more r=, c=, f= needed but all optional.

  On Jul 28, 6:28 pm, Thadeus Burgess thade...@thadeusb.com wrote:
  SORRY! =D

  --
  Thadeus

  On Wed, Jul 28, 2010 at 6:22 PM, mdipierro mdipie...@cs.depaul.edu
  wrote:
  WOW. Uploading to trunk. Now I need to revise the book again. :-(

  On Jul 28, 5:51 pm, Thadeus Burgess thade...@thadeusb.com wrote:
  URL(r=request, c='hello', f='world', args=['hi'],
  vars={'q':'greetings'}, anchor='the_world')

  '/welcome/hello/world/hi#the_world?q=greetings' URL(c='hello',
  f='world', args=['hi'], vars={'q':'greetings'}, anchor='the_world')

  '/welcome/hello/world/hi#the_world?q=greetings'

  Attached is the diff

  This should not effect any current usages of URL, but from this point
  forward we shouldn't have to specify r=request!

  --
  Thadeus

  On Wed, Jul 28, 2010 at 5:21 PM, mdipierro mdipie...@cs.depaul.edu
  wrote:
  ok

  On Jul 28, 4:52 pm, Thadeus Burgess thade...@thadeusb.com wrote:
  For a little more advanced version of what Massimo just posted:

  This allows you to use both.

  URL(r=request, c=controller, f=.)
  and
  URL(c=controller, f=function.)

 http://packages.python.org/web2py_utils/init.html#gurlhttp://hg.thade..

  The reason we have to pass the request to URL each time is because
  it
  is just imported into the context. Since it is just a python
  function,
  it has no knowledge of request.

  Why can't we do something like gURL from within web2py? When
  building
  the context, why can't we make URL a loaded function that will get
  request passed to it, exactly how gURL works.

  Effectively, we won't have to pass request into URL function
  anymore... ever.

  If your interested, I can work on the patch.

  --
  Thadeus

  On Wed, Jul 28, 2010 at 3:56 PM, mdipierro
  mdipie...@cs.depaul.edu wrote:
  1) It is a bit more complex because of static, appadmin, and
  admin.
  You can map

  /function/var1/var2

  into

  /app/controller/function/var1/var2

  using a file routes.py
   --- begin file
  routes_in=[
   ('/admin/$anything','/admin/$anything'),
   ('/static/$anything','/app/static/$anything'),
   

Re: [web2py] Re: question/suggestion about URL, controller

2010-07-30 Thread Michele Comitini
yes


2010/7/30 rochacbruno rochacbr...@gmail.com

 I have a lot of code wrote in this sintax, But, ig its wrong, no problem to
 replace.

 Will this still works?

 _href=URL(request.application,'plugin_wiki','page',args=[row,])

 Sent from my iPhone

 On 30/07/2010, at 04:05, mdipierro mdipie...@cs.depaul.edu wrote:

 You are right but it only breaks backward compatibility in a case
 where things would be misleading. Here are some example:

 # old syntax that still works
 URL('a','c','f')
 URL(a='a',c='c',f='f')
 URL(f='f',r=request)

 #new syntax that resulted in an error before
 URL('f')
 URL('c','f')
 URL(f='f')
 URL(c='c',f='f')

 ## changed of behaviour
 URL('a',r=request)
 was /a/current_controller/current_function
 now
 was /current_app/current_controller/a

 I.e. the change of behavior only occurs if the user explicitly
 specifies r and a (without naming a)  but not f. I.e. if the user is
 specifying redundant information that may be conflicting (because a
 may differ from r.application). Users should not be doing this anyway.
 I have never seen anybody doing this.

 Did I miss something? can you see any other case when the behavior
 would change?

 What do other people think?

 Massimo












 On Jul 29, 8:27 pm, Thadeus Burgess thade...@thadeusb.com wrote:

 Massimo, you cannot


 I am sorry but that would break backwards compatibility.


 Say if in certain apps you have this (in alot of the earlier apps on

 web2py.com do this too)


 URL(request.application, 'static', 'logo.png')


 Or


 URL(request.application, 'default', 'index')


 Unfortunately, we cannot re-arrange the variables defined in URL from this
 order


 def URL(

 a=None,

 c=None,

 f=None,

 r=None,

 args=[],

 vars={},

 anchor='',

 extension=None,

 env=None

 ):


 --

 Thadeus


 On Thu, Jul 29, 2010 at 8:23 PM, Michele Comitini


 michele.comit...@gmail.com wrote:

 thumbs up!


 2010/7/30 mdipierro mdipie...@cs.depaul.edu


 I took it one step further...


 URL()

 /app/default/index

 URL('test')

 /app/default/test

 def test(): return 'test'

 URL(test)

 /app/default/test

 URL('static','filename')

 /app/static/filename

 URL('other','static','filename')

 /other/static/filename


 No more r=, c=, f= needed but all optional.


 On Jul 28, 6:28 pm, Thadeus Burgess thade...@thadeusb.com wrote:

 SORRY! =D


 --

 Thadeus


 On Wed, Jul 28, 2010 at 6:22 PM, mdipierro mdipie...@cs.depaul.edu

 wrote:

 WOW. Uploading to trunk. Now I need to revise the book again. :-(


 On Jul 28, 5:51 pm, Thadeus Burgess thade...@thadeusb.com wrote:

 URL(r=request, c='hello', f='world', args=['hi'],

 vars={'q':'greetings'}, anchor='the_world')


 '/welcome/hello/world/hi#the_world?q=greetings' URL(c='hello',

 f='world', args=['hi'], vars={'q':'greetings'}, anchor='the_world')


 '/welcome/hello/world/hi#the_world?q=greetings'


 Attached is the diff


 This should not effect any current usages of URL, but from this point

 forward we shouldn't have to specify r=request!


 --

 Thadeus


 On Wed, Jul 28, 2010 at 5:21 PM, mdipierro mdipie...@cs.depaul.edu

 wrote:

 ok


 On Jul 28, 4:52 pm, Thadeus Burgess thade...@thadeusb.com wrote:

 For a little more advanced version of what Massimo just posted:


 This allows you to use both.


 URL(r=request, c=controller, f=.)

 and

 URL(c=controller, f=function.)


 http://packages.python.org/web2py_utils/init.html#gurlhttp://hg.thade
 ..


 The reason we have to pass the request to URL each time is because

 it

 is just imported into the context. Since it is just a python

 function,

 it has no knowledge of request.


 Why can't we do something like gURL from within web2py? When

 building

 the context, why can't we make URL a loaded function that will get

 request passed to it, exactly how gURL works.


 Effectively, we won't have to pass request into URL function

 anymore... ever.


 If your interested, I can work on the patch.


 --

 Thadeus


 On Wed, Jul 28, 2010 at 3:56 PM, mdipierro

 mdipie...@cs.depaul.edu wrote:

 1) It is a bit more complex because of static, appadmin, and

 admin.

 You can map


 /function/var1/var2


 into


 /app/controller/function/var1/var2


 using a file routes.py

  --- begin file

 routes_in=[

  ('/admin/$anything','/admin/$anything'),

  ('/static/$anything','/app/static/$anything'),

  ('/appadmin/$anything','/app/appadmin/$anything'),

  ('/$anything','/app/default/$anything'),

 ]

 routes_out=[(y,x) for (x,y) in routes_in]

 - end file


 2) in db.py define


 def url(f,args={},vars={}):

  return URL(r=request,f=f,args=args,vars=vars)

 def go(f,args={},vars={},flash=''):

  session.flash=flash

  return go(url(f=f,args=args,vars=vars))


 and use


url('index')


 or


   go('index',flash='you are being redirected')


 I do it all the time


 On Jul 28, 3:29 pm, VP vtp2...@gmail.com wrote:

 I'm a newbie, so my questions probably have easy answers, but

 

Re: [web2py] Re: keepvalues per field?

2010-07-30 Thread Johann Spies
On 26 July 2010 13:44, mdipierro mdipie...@cs.depaul.edu wrote:
 You can use

 db.table.field.default=previous_form.vars.field

 to propagate the values forward..

Where do I do this?   I suppose the controller is the correct place,
but do I do it in the same environment where I would use keepvalues?
I don't want the values to be written directly to the database.   The
db.table.field.default is confusing me a little bit.

Also:  where can I read a little bit about previous_form?  I did not
find anything in the book.  Maybe it is something for the new book.

Regards
Johann


-- 
    Be not deceived; God is not mocked: for whatsoever a
     man soweth, that shall he also reap.
                                  Galatians 6:7


[web2py] Re: keepvalues per field?

2010-07-30 Thread mdipierro
a, has, current, please=db.define_table, Field, request.vars, crud

the_thing=a('thing', has('name'), has('category'))

my_things = db(thing.id0)

def index():
 the_thing.category.default = current.category
 form = please.create(the_thing)
 things = my_things.select()
 return dict(form = form, things = things)

On Jul 30, 7:47 am, Johann Spies johann.sp...@gmail.com wrote:
 On 26 July 2010 13:44, mdipierro mdipie...@cs.depaul.edu wrote:

  You can use

  db.table.field.default=previous_form.vars.field

  to propagate the values forward..

 Where do I do this?   I suppose the controller is the correct place,
 but do I do it in the same environment where I would use keepvalues?
 I don't want the values to be written directly to the database.   The
 db.table.field.default is confusing me a little bit.

 Also:  where can I read a little bit about previous_form?  I did not
 find anything in the book.  Maybe it is something for the new book.

 Regards
 Johann

 --
     Be not deceived; God is not mocked: for whatsoever a
      man soweth, that shall he also reap.
                                   Galatians 6:7


[web2py] FreeTDS returns MS SQL money type as Python float, not Decimal

2010-07-30 Thread mwolfe02
For background, refer to related questions on SO:
http://stackoverflow.com/questions/3364699/
http://stackoverflow.com/questions/3371795/

I'm developing my app on Windows, but will be deploying it on a Linux
server.  The following lines are from the top of my db.py:

if os.name=='posix':  #Ubuntu
db = DAL('mssql://user:p...@10.0.8.30/TaxDB?DRIVER={FreeTDS}',
migrate=False)
elif os.name=='nt':   #Windows
db = DAL('mssql://u...@127.0.0.1/TaxDB_Dev?
Trusted_Connection=Yes', migrate=False)

The problem I am running into is that on Windows, my MS SQL money
fields are returned as Python Decimals.  However, on Linux, those same
fields are returned as floats.  I think the issue is with FreeTDS.
The above lines are the _only_ lines that are different between my
production and development versions.  Obviously, the environments
themselves are vastly different.

Is there an alternative to FreeTDS to connect to SQL Server from
Linux?  Do I need to provide some additional info in my connection
string?  Am I just stuck because I'm accessing SQL Server from Linux?

Thanks in advance for any insight.


Re: [web2py] FreeTDS returns MS SQL money type as Python float, not Decimal

2010-07-30 Thread Michele Comitini
you can try with mxodbc http://www.egenix.com/products/python/mxODBC/

2010/7/30 mwolfe02 michael.joseph.wo...@gmail.com

 For background, refer to related questions on SO:
 http://stackoverflow.com/questions/3364699/
 http://stackoverflow.com/questions/3371795/

 I'm developing my app on Windows, but will be deploying it on a Linux
 server.  The following lines are from the top of my db.py:

 if os.name=='posix':  #Ubuntu
db = 
 DAL('mssql://user:p...@10.0.8.30/TaxDB?DRIVER={FreeTDS}http://user:p...@10.0.8.30/TaxDB?DRIVER=%7BFreeTDS%7D
 ',
 migrate=False)
 elif os.name=='nt':   #Windows
db = DAL('mssql://u...@127.0.0.1/TaxDB_Dev?
 Trusted_Connection=Yes', migrate=False)

 The problem I am running into is that on Windows, my MS SQL money
 fields are returned as Python Decimals.  However, on Linux, those same
 fields are returned as floats.  I think the issue is with FreeTDS.
 The above lines are the _only_ lines that are different between my
 production and development versions.  Obviously, the environments
 themselves are vastly different.

 Is there an alternative to FreeTDS to connect to SQL Server from
 Linux?  Do I need to provide some additional info in my connection
 string?  Am I just stuck because I'm accessing SQL Server from Linux?

 Thanks in advance for any insight.


[web2py] Re: FreeTDS returns MS SQL money type as Python float, not Decimal

2010-07-30 Thread mwolfe02
Ideally, I'd like to avoid having to purchase a commercial product.
Plus, I don't think it would work.  mxODBC appears to be a replacement
for pyodbc.  It looks like mxODBC uses FreeTDS just like pyodbc.  The
problem appears to be with FreeTDS, so mxODBC doesn't look like it
would be a fix for my particular problem.  In fact, mxODBC says as
much itself:

(From the mxODBC change log, Changes from 2.0.7 to 3.0.0:
http://www.egenix.com/products/python/mxODBC/changelog.html)

Added new experimental subpackage mx.ODBC.FreeTDS which allows
connecting to MS SQL Server from Unix. This is still far from even
being called alpha due to the current lack of implementation support
of many important ODBC APIs in the FreeTDS ODBC driver.

The problem still seems to be FreeTDS.

On Jul 30, 9:42 am, Michele Comitini michele.comit...@gmail.com
wrote:
 you can try with mxodbchttp://www.egenix.com/products/python/mxODBC/

 2010/7/30 mwolfe02 michael.joseph.wo...@gmail.com



  For background, refer to related questions on SO:
 http://stackoverflow.com/questions/3364699/
 http://stackoverflow.com/questions/3371795/

  I'm developing my app on Windows, but will be deploying it on a Linux
  server.  The following lines are from the top of my db.py:

  if os.name=='posix':  #Ubuntu
     db = 
  DAL('mssql://user:p...@10.0.8.30/TaxDB?DRIVER={FreeTDS}http://user:p...@10.0.8.30/TaxDB?DRIVER=%7BFreeTDS%7D
  ',
  migrate=False)
  elif os.name=='nt':   #Windows
     db = DAL('mssql://u...@127.0.0.1/TaxDB_Dev?
  Trusted_Connection=Yes', migrate=False)

  The problem I am running into is that on Windows, my MS SQL money
  fields are returned as Python Decimals.  However, on Linux, those same
  fields are returned as floats.  I think the issue is with FreeTDS.
  The above lines are the _only_ lines that are different between my
  production and development versions.  Obviously, the environments
  themselves are vastly different.

  Is there an alternative to FreeTDS to connect to SQL Server from
  Linux?  Do I need to provide some additional info in my connection
  string?  Am I just stuck because I'm accessing SQL Server from Linux?

  Thanks in advance for any insight.


[web2py] Re: FreeTDS returns MS SQL money type as Python float, not Decimal

2010-07-30 Thread mdipierro
Are they both connecting to the same database?
Can you provide an example of how you insert and how you extract data?

This is to understand the issue better. In fact
gluon/sql.py contains the following code:


...
elif field.type[:7] == 'decimal' and value != None:
decimals = [int(x) for x in
field.type[8:-1].split(',')][-1]
if field._db._dbname == 'sqlite':
value = ('%.'+str(decimals)+'f') % value
if not isinstance(value,decimal.Decimal):
value = decimal.Decimal(str(value))
...

so technically even if the database where to return float (wrong),
web2py should still return decimal. Is this the case for you?



On Jul 30, 8:35 am, mwolfe02 michael.joseph.wo...@gmail.com wrote:
 For background, refer to related questions on 
 SO:http://stackoverflow.com/questions/3364699/http://stackoverflow.com/questions/3371795/

 I'm developing my app on Windows, but will be deploying it on a Linux
 server.  The following lines are from the top of my db.py:

 if os.name=='posix':  #Ubuntu
     db = DAL('mssql://user:p...@10.0.8.30/TaxDB?DRIVER={FreeTDS}',
 migrate=False)
 elif os.name=='nt':   #Windows
     db = DAL('mssql://u...@127.0.0.1/TaxDB_Dev?
 Trusted_Connection=Yes', migrate=False)

 The problem I am running into is that on Windows, my MS SQL money
 fields are returned as Python Decimals.  However, on Linux, those same
 fields are returned as floats.  I think the issue is with FreeTDS.
 The above lines are the _only_ lines that are different between my
 production and development versions.  Obviously, the environments
 themselves are vastly different.

 Is there an alternative to FreeTDS to connect to SQL Server from
 Linux?  Do I need to provide some additional info in my connection
 string?  Am I just stuck because I'm accessing SQL Server from Linux?

 Thanks in advance for any insight.


[web2py] fun with metaclasses

2010-07-30 Thread mdipierro
http://gluonframework.wordpress.com/2010/07/30/web2py-and-metaclasses/


[web2py] Re: FreeTDS returns MS SQL money type as Python float, not Decimal

2010-07-30 Thread mdipierro
can you insert with db.table.insert(decimalfield=decimal(...))?

On Jul 30, 9:43 am, mwolfe02 michael.joseph.wo...@gmail.com wrote:
 I'm using .executesql.  I added a line to sql.py for debugging
 purposes.  It returns the second column of the first row of results (a
 SUM of a SQL Server money column):

 diff --git a/gluon/sql.py b/gluon/sql.py
 --- a/gluon/sql.py
 +++ b/gluon/sql.py
 @@ -1389,6 +1389,7 @@
              data = self._cursor.fetchall()
              # convert the list for each row into a dictionary so it's
              # easier to work with. row['field_name'] rather than
 row[0]
 +            raise RuntimeError(type(data[0][1]))
              return [dict(zip(fields,row)) for row in data]
          # see if any results returned from database
          try:

 When I run on Windows, I get:

 RuntimeError: class 'decimal.Decimal'

 When I run on Linux, I get:

 RuntimeError: type 'float'

 On Jul 30, 10:32 am, mdipierro mdipie...@cs.depaul.edu wrote:

  Are they both connecting to the same database?
  Can you provide an example of how you insert and how you extract data?

  This is to understand the issue better. In fact
  gluon/sql.py contains the following code:

  ...
  elif field.type[:7] == 'decimal' and value != None:
                      decimals = [int(x) for x in
  field.type[8:-1].split(',')][-1]
                      if field._db._dbname == 'sqlite':
                          value = ('%.'+str(decimals)+'f') % value
                      if not isinstance(value,decimal.Decimal):
                          value = decimal.Decimal(str(value))
  ...

  so technically even if the database where to return float (wrong),
  web2py should still return decimal. Is this the case for you?

  On Jul 30, 8:35 am, mwolfe02 michael.joseph.wo...@gmail.com wrote:

   For background, refer to related questions on 
   SO:http://stackoverflow.com/questions/3364699/http://stackoverflow.com/q...

   I'm developing my app on Windows, but will be deploying it on a Linux
   server.  The following lines are from the top of my db.py:

   if os.name=='posix':  #Ubuntu
       db = DAL('mssql://user:p...@10.0.8.30/TaxDB?DRIVER={FreeTDS}',
   migrate=False)
   elif os.name=='nt':   #Windows
       db = DAL('mssql://u...@127.0.0.1/TaxDB_Dev?
   Trusted_Connection=Yes', migrate=False)

   The problem I am running into is that on Windows, my MS SQL money
   fields are returned as Python Decimals.  However, on Linux, those same
   fields are returned as floats.  I think the issue is with FreeTDS.
   The above lines are the _only_ lines that are different between my
   production and development versions.  Obviously, the environments
   themselves are vastly different.

   Is there an alternative to FreeTDS to connect to SQL Server from
   Linux?  Do I need to provide some additional info in my connection
   string?  Am I just stuck because I'm accessing SQL Server from Linux?

   Thanks in advance for any insight.


Re: [web2py] Re: question/suggestion about URL, controller

2010-07-30 Thread Jonathan Lundell
On Jul 30, 2010, at 12:05 AM, mdipierro wrote:

 You are right but it only breaks backward compatibility in a case
 where things would be misleading. Here are some example:
 
 # old syntax that still works
 URL('a','c','f')
 URL(a='a',c='c',f='f')
 URL(f='f',r=request)
 
 #new syntax that resulted in an error before
 URL('f')
 URL('c','f')
 URL(f='f')
 URL(c='c',f='f')
 
 ## changed of behaviour
 URL('a',r=request)
 was /a/current_controller/current_function
 now
 was /current_app/current_controller/a
 
 I.e. the change of behavior only occurs if the user explicitly
 specifies r and a (without naming a)  but not f. I.e. if the user is
 specifying redundant information that may be conflicting (because a
 may differ from r.application). Users should not be doing this anyway.
 I have never seen anybody doing this.
 
 Did I miss something? can you see any other case when the behavior
 would change?
 
 What do other people think?

I'm not looking at the code, but if that's really the only case that breaks, I 
agree that it would be very strange for someone to count on it. (I assume that 
you didn't intend the second 'was' in the last example.)

Re: [web2py] Re: FreeTDS returns MS SQL money type as Python float, not Decimal

2010-07-30 Thread Michele Comitini
2010/7/30 mwolfe02 michael.joseph.wo...@gmail.com

 Ideally, I'd like to avoid having to purchase a commercial product.


Alas you are using a commercial product.
indeed this is what you should look at:
http://www.egenix.com/products/python/mxODBCConnect/

That said it could be just a problem with the python adapter of freetds
pymssql.

Plus, I don't think it would work.  mxODBC appears to be a replacement
 for pyodbc.  It looks like mxODBC uses FreeTDS just like pyodbc.  The
 problem appears to be with FreeTDS, so mxODBC doesn't look like it
 would be a fix for my particular problem.  In fact, mxODBC says as
 much itself:




 (From the mxODBC change log, Changes from 2.0.7 to 3.0.0:
 http://www.egenix.com/products/python/mxODBC/changelog.html)

 Added new experimental subpackage mx.ODBC.FreeTDS which allows
 connecting to MS SQL Server from Unix. This is still far from even
 being called alpha due to the current lack of implementation support
 of many important ODBC APIs in the FreeTDS ODBC driver.

 The problem still seems to be FreeTDS.

 On Jul 30, 9:42 am, Michele Comitini michele.comit...@gmail.com
 wrote:
  you can try with mxodbchttp://www.egenix.com/products/python/mxODBC/
 
  2010/7/30 mwolfe02 michael.joseph.wo...@gmail.com
 
 
 
   For background, refer to related questions on SO:
  http://stackoverflow.com/questions/3364699/
  http://stackoverflow.com/questions/3371795/
 
   I'm developing my app on Windows, but will be deploying it on a Linux
   server.  The following lines are from the top of my db.py:
 
   if os.name=='posix':  #Ubuntu
  db = 
   DAL('mssql://user:p...@10.0.8.30/TaxDB?DRIVER={FreeTDS}http://user:p...@10.0.8.30/TaxDB?DRIVER=%7BFreeTDS%7D
 http://user:p...@10.0.8.30/TaxDB?DRIVER=%7BFreeTDS%7D
   ',
   migrate=False)
   elif os.name=='nt':   #Windows
  db = DAL('mssql://u...@127.0.0.1/TaxDB_Dev?
   Trusted_Connection=Yes', migrate=False)
 
   The problem I am running into is that on Windows, my MS SQL money
   fields are returned as Python Decimals.  However, on Linux, those same
   fields are returned as floats.  I think the issue is with FreeTDS.
   The above lines are the _only_ lines that are different between my
   production and development versions.  Obviously, the environments
   themselves are vastly different.
 
   Is there an alternative to FreeTDS to connect to SQL Server from
   Linux?  Do I need to provide some additional info in my connection
   string?  Am I just stuck because I'm accessing SQL Server from Linux?
 
   Thanks in advance for any insight.



[web2py] Re: Webfaction deployment

2010-07-30 Thread Iceberg
webfaction day2: the auto-logout problem and why


Many coincidence lead to the auto-logout (lost session) problem.
Here is a how-to which you shall not follow. :-)

Problem: Even the web2py welcome app on webfaction tends to ask me to
re-login often, due to something is wrong with the session.

How to reproduce the problem:

1. Follow the official latest stable source install script [1] to
setup web2py as normal.

2. Setup an http site for normal use, and an httpS site for admin. And
as usual, both sites map / as URL path to the same web2py instance.

3. Due to lack of domain resource at the beginning, I setup both sites
with the same only domain I have, MY_ACCOUNT.webfactional.com.  (This
is coincidence 1. I should better use different domain names, such as
www.top_level_domain.com for normal site, and
admin.top_level_domain.com for the admin site.) (And, later I know
that I can use the ip string as a second domain, to avoid all later
problem.)

4. Visit http://MY_ACCOUNT.webfactional.com/welcome/default/index ,
register a new web2py welcome account, then login, you will see a
Welcome your_first_name at the upper-right corner.

5. Use SAME browser, open a new tab, to visit
https://MY_ACCOUNT.webfactional.com/appadmin/index, page shows up
fine. (This is coincidence 2. If I use another browser to open a new
window hence a new session, I should be fine.)

6. At this moment, the session file is somehow replaced, so when you
use your same browser to visit 
http://MY_ACCOUNT.webfactional.com/welcome/default/index
, you will notice you have been automatically logout.

Now you see, two coincidence together lead to the auto-logout problem.
No wonder few webfaction-web2py users met same problem. But it did
cost me several hours to trace down the culprit. What a day2 lesson in
my webfactoin life. :-/

Sincerely,
 Iceberg, 2010-Jul-30, 22:22(PM), Fri

[1] http://wiki.webfaction.com/wiki/Web2py-LatestSource


[web2py] Re: Webfaction deployment

2010-07-30 Thread mdipierro
of course ;-)

appadmin sets

session.secure()

which turns the session cookie into a secure cookie and it cannot go
over http, only https.

You can disable this by commenting session.secure() in appadmin.py

Massimo

On Jul 30, 10:14 am, Iceberg iceb...@21cn.com wrote:
 webfaction day2: the auto-logout problem and why
 

 Many coincidence lead to the auto-logout (lost session) problem.
 Here is a how-to which you shall not follow. :-)

 Problem: Even the web2py welcome app on webfaction tends to ask me to
 re-login often, due to something is wrong with the session.

 How to reproduce the problem:

 1. Follow the official latest stable source install script [1] to
 setup web2py as normal.

 2. Setup an http site for normal use, and an httpS site for admin. And
 as usual, both sites map / as URL path to the same web2py instance.

 3. Due to lack of domain resource at the beginning, I setup both sites
 with the same only domain I have, MY_ACCOUNT.webfactional.com.  (This
 is coincidence 1. I should better use different domain names, such 
 aswww.top_level_domain.comfor normal site, and
 admin.top_level_domain.com for the admin site.) (And, later I know
 that I can use the ip string as a second domain, to avoid all later
 problem.)

 4. Visithttp://MY_ACCOUNT.webfactional.com/welcome/default/index,
 register a new web2py welcome account, then login, you will see a
 Welcome your_first_name at the upper-right corner.

 5. Use SAME browser, open a new tab, to 
 visithttps://MY_ACCOUNT.webfactional.com/appadmin/index, page shows up
 fine. (This is coincidence 2. If I use another browser to open a new
 window hence a new session, I should be fine.)

 6. At this moment, the session file is somehow replaced, so when you
 use your same browser to 
 visithttp://MY_ACCOUNT.webfactional.com/welcome/default/index
 , you will notice you have been automatically logout.

 Now you see, two coincidence together lead to the auto-logout problem.
 No wonder few webfaction-web2py users met same problem. But it did
 cost me several hours to trace down the culprit. What a day2 lesson in
 my webfactoin life. :-/

 Sincerely,
              Iceberg, 2010-Jul-30, 22:22(PM), Fri

 [1]http://wiki.webfaction.com/wiki/Web2py-LatestSource


Re: [web2py] Re: FreeTDS returns MS SQL money type as Python float, not Decimal

2010-07-30 Thread Michael Wolfe
Touché!  Point taken on the commercial software :)

As a fall-back plan, there is an acceptable workaround.  I can
explicitly convert the floats I receive into Decimals.  Based on
Massimo's post, it looks like this will only be an issue for money
fields returned from a .executesql statement.  For all other queries
where I can leverage the DAL, I think web2py will handle things just
fine.

I'm going to post a message to the FreeTDS message board and see what
I can learn.


On Fri, Jul 30, 2010 at 11:08 AM, Michele Comitini
michele.comit...@gmail.com wrote:


 2010/7/30 mwolfe02 michael.joseph.wo...@gmail.com

 Ideally, I'd like to avoid having to purchase a commercial product.

 Alas you are using a commercial product.
 indeed this is what you should look at:
 http://www.egenix.com/products/python/mxODBCConnect/

 That said it could be just a problem with the python adapter of freetds
 pymssql.

 Plus, I don't think it would work.  mxODBC appears to be a replacement
 for pyodbc.  It looks like mxODBC uses FreeTDS just like pyodbc.  The
 problem appears to be with FreeTDS, so mxODBC doesn't look like it
 would be a fix for my particular problem.  In fact, mxODBC says as
 much itself:




 (From the mxODBC change log, Changes from 2.0.7 to 3.0.0:
 http://www.egenix.com/products/python/mxODBC/changelog.html)

 Added new experimental subpackage mx.ODBC.FreeTDS which allows
 connecting to MS SQL Server from Unix. This is still far from even
 being called alpha due to the current lack of implementation support
 of many important ODBC APIs in the FreeTDS ODBC driver.

 The problem still seems to be FreeTDS.

 On Jul 30, 9:42 am, Michele Comitini michele.comit...@gmail.com
 wrote:
  you can try with mxodbchttp://www.egenix.com/products/python/mxODBC/
 
  2010/7/30 mwolfe02 michael.joseph.wo...@gmail.com
 
 
 
   For background, refer to related questions on SO:
  http://stackoverflow.com/questions/3364699/
  http://stackoverflow.com/questions/3371795/
 
   I'm developing my app on Windows, but will be deploying it on a Linux
   server.  The following lines are from the top of my db.py:
 
   if os.name=='posix':  #Ubuntu
      db =
   DAL('mssql://user:p...@10.0.8.30/TaxDB?DRIVER={FreeTDS}http://user:p...@10.0.8.30/TaxDB?DRIVER=%7BFreeTDS%7D
   ',
   migrate=False)
   elif os.name=='nt':   #Windows
      db = DAL('mssql://u...@127.0.0.1/TaxDB_Dev?
   Trusted_Connection=Yes', migrate=False)
 
   The problem I am running into is that on Windows, my MS SQL money
   fields are returned as Python Decimals.  However, on Linux, those same
   fields are returned as floats.  I think the issue is with FreeTDS.
   The above lines are the _only_ lines that are different between my
   production and development versions.  Obviously, the environments
   themselves are vastly different.
 
   Is there an alternative to FreeTDS to connect to SQL Server from
   Linux?  Do I need to provide some additional info in my connection
   string?  Am I just stuck because I'm accessing SQL Server from Linux?
 
   Thanks in advance for any insight.



Re: [web2py] Re: encrypt source code

2010-07-30 Thread Michele Comitini
This is not possible in general.
If you do not want anyone to copy something than do not show it.
Think of writing a book that no one can read...

Maybe copyright could be the right way to protect you work?

2010/7/29 ilovesss2004 yyiillu...@gmail.com

 Now I know the web app will work just with the pyc files, and others
 can not view the source code from pyc files. But the source code can
 still be viewed in web browser (I mean the source code of html and
 javascript at the client side). Is there a method to encrypt the
 source code by a language that the web browser knows so that the
 source code will be unreadable but still readable to web browser?

 On Jul 29, 5:41 pm, mdipierro mdipie...@cs.depaul.edu wrote:
  It depends of what you mean by HTML.
 
  say you have views/default/index.html which extends views/layout.html.
 
  When you bytecode compile the two .html files are merged, turned into
  a python program and this is bytecode compiled.
 
  Now you can distribute your app without the .html files and it will
  work.
 
  You can still somewhat infer the html from the .pyc files but it is
  not trivial since there is not a 1-1 map.
 
  Massimo
 
  On Jul 29, 9:23 am, ilovesss2004 yyiillu...@gmail.com wrote:
 
 
 
   But the html files are also part of the web app. Is there someway to
   encrypt them by use of web2py or python programming?
 
   On Jul 29, 4:15 pm, Jean-Guy jean...@gmail.com wrote:
 
Of course yes! It is the HTML nature and the Web paradigm is based on
this state of affairs...
 
Maybe the python code embeded could be compiled too, but really not
 sure
about that... Massimo could be a better help on that.
 
Jonhy
 
On 2010-07-29 10:12, ilovesss2004 wrote:
 
 source code of html files are still viewable.



[web2py] Re: FreeTDS returns MS SQL money type as Python float, not Decimal

2010-07-30 Thread mwolfe02
Massimo,

Per your first post:

If I run the query using DAL, I get a Decimal type back for both
environments.  Of course, there is no way for web2py to make that
coercion for fields returned from .executesql.  Since that minimizes
the pain greatly for me, I think I will just go ahead with explicitly
converting to Decimals when working with .executesql.

If I learn anything with reference to FreeTDS I'll be sure to come
back and post that here.

Thanks to you and Michele for the help.

On Jul 30, 11:19 am, Michael Wolfe michael.joseph.wo...@gmail.com
wrote:
 Touché!  Point taken on the commercial software :)

 As a fall-back plan, there is an acceptable workaround.  I can
 explicitly convert the floats I receive into Decimals.  Based on
 Massimo's post, it looks like this will only be an issue for money
 fields returned from a .executesql statement.  For all other queries
 where I can leverage the DAL, I think web2py will handle things just
 fine.

 I'm going to post a message to the FreeTDS message board and see what
 I can learn.

 On Fri, Jul 30, 2010 at 11:08 AM, Michele Comitini



 michele.comit...@gmail.com wrote:

  2010/7/30 mwolfe02 michael.joseph.wo...@gmail.com

  Ideally, I'd like to avoid having to purchase a commercial product.

  Alas you are using a commercial product.
  indeed this is what you should look at:
 http://www.egenix.com/products/python/mxODBCConnect/

  That said it could be just a problem with the python adapter of freetds
  pymssql.

  Plus, I don't think it would work.  mxODBC appears to be a replacement
  for pyodbc.  It looks like mxODBC uses FreeTDS just like pyodbc.  The
  problem appears to be with FreeTDS, so mxODBC doesn't look like it
  would be a fix for my particular problem.  In fact, mxODBC says as
  much itself:

  (From the mxODBC change log, Changes from 2.0.7 to 3.0.0:
 http://www.egenix.com/products/python/mxODBC/changelog.html)

  Added new experimental subpackage mx.ODBC.FreeTDS which allows
  connecting to MS SQL Server from Unix. This is still far from even
  being called alpha due to the current lack of implementation support
  of many important ODBC APIs in the FreeTDS ODBC driver.

  The problem still seems to be FreeTDS.

  On Jul 30, 9:42 am, Michele Comitini michele.comit...@gmail.com
  wrote:
   you can try with mxodbchttp://www.egenix.com/products/python/mxODBC/

   2010/7/30 mwolfe02 michael.joseph.wo...@gmail.com

For background, refer to related questions on SO:
   http://stackoverflow.com/questions/3364699/
   http://stackoverflow.com/questions/3371795/

I'm developing my app on Windows, but will be deploying it on a Linux
server.  The following lines are from the top of my db.py:

if os.name=='posix':  #Ubuntu
   db =
DAL('mssql://user:p...@10.0.8.30/TaxDB?DRIVER={FreeTDS}http://user:p...@10.0.8.30/TaxDB?DRIVER=%7BFreeTDS%7D
',
migrate=False)
elif os.name=='nt':   #Windows
   db = DAL('mssql://u...@127.0.0.1/TaxDB_Dev?
Trusted_Connection=Yes', migrate=False)

The problem I am running into is that on Windows, my MS SQL money
fields are returned as Python Decimals.  However, on Linux, those same
fields are returned as floats.  I think the issue is with FreeTDS.
The above lines are the _only_ lines that are different between my
production and development versions.  Obviously, the environments
themselves are vastly different.

Is there an alternative to FreeTDS to connect to SQL Server from
Linux?  Do I need to provide some additional info in my connection
string?  Am I just stuck because I'm accessing SQL Server from Linux?

Thanks in advance for any insight.


Re: [web2py] Re: encrypt source code

2010-07-30 Thread Jonathan Lundell
On Jul 30, 2010, at 8:32 AM, Michele Comitini wrote:

 This is not possible in general.
 If you do not want anyone to copy something than do not show it.
 Think of writing a book that no one can read...

Right. 

It's worth making a distinction, too, about how an application gets 
distributed. If you're delivering a service over the net, then the .pyc files 
are unreadable, but so are .py files. To the extent that you can embed your IP 
on the server rather than in the code (html or JS) that must be delivered to 
the client, the more you'll protect.

OTOH, if you're delivering the app itself to someone who will run it on their 
own server, then .pyc files are not all that secure against reverse 
engineering. Python compilation must be regarded as a form of obfuscation 
merely.

But do we care?

http://stackoverflow.com/questions/261638/how-do-i-protect-python-code



 
 Maybe copyright could be the right way to protect you work?
 
 2010/7/29 ilovesss2004 yyiillu...@gmail.com
 Now I know the web app will work just with the pyc files, and others
 can not view the source code from pyc files. But the source code can
 still be viewed in web browser (I mean the source code of html and
 javascript at the client side). Is there a method to encrypt the
 source code by a language that the web browser knows so that the
 source code will be unreadable but still readable to web browser?
 
 On Jul 29, 5:41 pm, mdipierro mdipie...@cs.depaul.edu wrote:
  It depends of what you mean by HTML.
 
  say you have views/default/index.html which extends views/layout.html.
 
  When you bytecode compile the two .html files are merged, turned into
  a python program and this is bytecode compiled.
 
  Now you can distribute your app without the .html files and it will
  work.
 
  You can still somewhat infer the html from the .pyc files but it is
  not trivial since there is not a 1-1 map.
 
  Massimo
 
  On Jul 29, 9:23 am, ilovesss2004 yyiillu...@gmail.com wrote:
 
 
 
   But the html files are also part of the web app. Is there someway to
   encrypt them by use of web2py or python programming?
 
   On Jul 29, 4:15 pm, Jean-Guy jean...@gmail.com wrote:
 
Of course yes! It is the HTML nature and the Web paradigm is based on
this state of affairs...
 
Maybe the python code embeded could be compiled too, but really not sure
about that... Massimo could be a better help on that.
 
Jonhy
 
On 2010-07-29 10:12, ilovesss2004 wrote:
 
 source code of html files are still viewable.
 




[web2py] rewrite url using routes.py

2010-07-30 Thread tandnk50
HI,
can I rewrite url using routes.py? where, url repesented by domain
name.
I tried to follow routes.example.py but it didn't work

routes_in = (('.*:/favicon.ico', '/examples/static/favicon.ico'),
 ('.*:/robots.txt', '/examples/static/robots.txt'),
 (('http://www.mydomain.com/init/news/index/0/14', '/
sonn')))

please help.
Thanks


[web2py] Re: fun with metaclasses

2010-07-30 Thread VP
This is really nice.  Please do more of this.

On Jul 30, 9:35 am, mdipierro mdipie...@cs.depaul.edu wrote:
 http://gluonframework.wordpress.com/2010/07/30/web2py-and-metaclasses/


Re: [web2py] Re: fun with metaclasses

2010-07-30 Thread Michele Comitini
:D

2010/7/30 VP vtp2...@gmail.com

 This is really nice.  Please do more of this.

 On Jul 30, 9:35 am, mdipierro mdipie...@cs.depaul.edu wrote:
  http://gluonframework.wordpress.com/2010/07/30/web2py-and-metaclasses/



[web2py] Re: fun with metaclasses

2010-07-30 Thread mikech
Very nice - Dzoned http://www.dzone.com/links/r/web2py_and_metaclasses.html

Mike

On Jul 30, 7:35 am, mdipierro mdipie...@cs.depaul.edu wrote:
 http://gluonframework.wordpress.com/2010/07/30/web2py-and-metaclasses/


Re: [web2py] rewrite url using routes.py

2010-07-30 Thread Vasile Ermicioi
rename routes.example.py to routes.py


Re: [web2py] Re: fun with metaclasses

2010-07-30 Thread Jonathan Lundell
On Jul 30, 2010, at 9:19 AM, VP wrote:

 This is really nice.  Please do more of this.
 
 On Jul 30, 9:35 am, mdipierro mdipie...@cs.depaul.edu wrote:
 http://gluonframework.wordpress.com/2010/07/30/web2py-and-metaclasses/

My initial reaction is the opposite. The result might be more readable, but it 
doesn't strike me as more writable.

What would be most helpful for me would be a deeper explanation (in the book) 
of what's going on behind the existing DAL magic syntax, rather than adding 
yet another layer of magic.




[web2py] Re: fun with metaclasses

2010-07-30 Thread Iceberg
On Jul 31, 1:15 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Jul 30, 2010, at 9:19 AM, VP wrote:
  On Jul 30, 9:35 am, mdipierro mdipie...@cs.depaul.edu wrote:
 http://gluonframework.wordpress.com/2010/07/30/web2py-and-metaclasses/

  This is really nice.  Please do more of this.

 My initial reaction is the opposite. The result might be more readable, but 
 it doesn't strike me as more writable.

 What would be most helpful for me would be a deeper explanation (in the book) 
 of what's going on behind the existing DAL magic syntax, rather than adding 
 yet another layer of magic.

You make a good point, Jonathan. And I think there is a underlying
question here. Which kind of audience is web2py targeting to?  If for
developers, the existing DAL syntax is already powerful and magical
enough (the document is also good, here it is. 
http://web2py.com/book/default/chapter/06
). Developers don't need another layer which is more fancy but not
more powerful.


[web2py] Re: Final Day for WAE Submissions!

2010-07-30 Thread Iceberg
On Jul 31, 2:12 am, NetAdmin mr.netad...@gmail.com wrote:
 Web2py Application Exhibition

 Submissions must be e-mailed before
 12:59pm pm CST July 30, 2010

 Do you have a Web2py app that you'd like to show the world?
 If so, you may be interested in the Web2py Application Exhibition.

 The WAE is a way to...
 1. Demonstrate what can be done with Web2py.
 2. Share and learn about useful web2py, python, Javascript, jQuery
 etc. techniques.
 3. Earn some money toward that new  you've been craving.

 Projects will be judged in the following areas.

 Ease of use
 Usefulness
 Visual Appeal

 The Rules
 1. Applications must be submitted no later than July 30, 2010

 2. Source must be included with your submissions.

 3. If the application is written by a team, Massimo can NOT be
 part of the team.

 4. After a 2 week review period, on August 15, 2010, the
 winners will be announced on the web2py-users list.

 5. The 1st place winner will receive $100 US Dollars,
 2nd place will receive $50

 6. You must enjoy using Web2py!

 Massimo is not affiliated with this exhibition, ( maybe he'll help
 judge if I can twist his arm ) so, if you have any questions or
 comments, I can be contacted on this forum or via gmail

 mr.netadmin


Will there be a showcase for all the submitted work? Or the winner
(and runner up) will only be announced after an undisclosed selection
phase?