[web2py] Re: upload bug in filename

2010-06-15 Thread Swell
don't really know but i tried with that filename :

aaa.pdf

(which containt 111 a if you trust me :) and get the error ticket ,
showing this last call

File "C:\Users\M\Desktop\web2py_src\web2py\gluon\sql.py", line 2699,
in store
dest_file = open(pathfilename, 'wb')
IOError: [Errno 2] No such file or directory: 'C:\\Users\\M\\Desktop\
\web2py_src\\web2py\\applications\\Library/databases\\..\\uploads\
\books.file.acf7b28c26fb29c3.6161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161.pdf'
(the filename is 205 characters long ,but pathfilename is proably
bigger). Do you know if the 255  limit is python limit ? Where does it
come from ?

any idea how to sort it out without changing the pathfilename to a
shorter version(actually the generated filename could be changed to
something shorter but i don t know where it is generated )?

M


BTW , i use 1.79.2


On 15 juin, 05:32, Thadeus Burgess  wrote:
> how long is the filename?
>
> Isn't there like a 255 char limit to filenames?
> --
> Thadeus
>
>
>
> On Mon, Jun 14, 2010 at 4:58 PM, Swell  wrote:
> > Hi ,
> >  I tried to send a file with a form containing a upload
> > field( actually it is a SQLFORM). When i try to add a new record with
> > the administrative db interface , it breaks if the filename if very
> > long ( not sure where it comes from ).
>
> > Any idea?
>
> > Thx


[web2py] Re: upload bug in filename

2010-06-15 Thread Yarko Tymciurak
It looks like something else might be wrong here...  how are you
getting these filenames?

On Jun 15, 2:37 am, Swell  wrote:
> don't really know but i tried with that filename :
>
> aaa 
> .pdf
>
> (which containt 111 a if you trust me :) and get the error ticket ,
> showing this last call
>
> File "C:\Users\M\Desktop\web2py_src\web2py\gluon\sql.py", line 2699,
> in store
>     dest_file = open(pathfilename, 'wb')
> IOError: [Errno 2] No such file or directory: 'C:\\Users\\M\\Desktop\
> \web2py_src\\web2py\\applications\\Library/databases\\..\\uploads\
> \books.file.acf7b28c26fb29c3.6161616161616161616161616161616161616161616161 
> 616161616161616161616161616161616161616161616161616161616161616161616161616 
> 161616161616161616161616161616161616161616161616161.pdf'
> (the filename is 205 characters long ,but pathfilename is proably
> bigger). Do you know if the 255  limit is python limit ? Where does it
> come from ?
>
> any idea how to sort it out without changing the pathfilename to a
> shorter version(actually the generated filename could be changed to
> something shorter but i don t know where it is generated )?
>
> M
>
> BTW , i use 1.79.2
>
> On 15 juin, 05:32, Thadeus Burgess  wrote:
>
>
>
> > how long is the filename?
>
> > Isn't there like a 255 char limit to filenames?
> > --
> > Thadeus
>
> > On Mon, Jun 14, 2010 at 4:58 PM, Swell  wrote:
> > > Hi ,
> > >  I tried to send a file with a form containing a upload
> > > field( actually it is a SQLFORM). When i try to add a new record with
> > > the administrative db interface , it breaks if the filename if very
> > > long ( not sure where it comes from ).
>
> > > Any idea?
>
> > > Thx


[web2py] Re: working with views or stored procedures.

2010-06-15 Thread Sky
Thank you Jose,
but I couldn't find out if you used define_table or not?
can you drop me a piece of your code?
i get 'invalid query' error when i query on my views.

thanks .

On Jun 14, 4:06 pm, Jose  wrote:
> I am working with a legacy database and am using many views, so as to
> bridging differences with tables. All the views will create a numeric
> id field for compatibility, but not in use.
>
> Jose


[web2py] Re: checking if table exists in database

2010-06-15 Thread mika
so what I can do if I have database already created? I would like
simply to connect db and see if tables exists...
by the way, metadata used by web2py to recognize tables created by
itself is working only on sqlite, or on other db also?


On Jun 11, 3:46 pm, mdipierro  wrote:
> if you set migrate=True web2py does the check for you and eventually
> creates tables. It can only detect tables if they were created by
> web2py itself since it uses metadata for that purpose.
>


[web2py] crud does not support labels for forms. am i wrong ?

2010-06-15 Thread Sky
as i looked in source code of crud ( tools.py ) you can't change the
'lables' property of SQLForm returned from crud.create or crud.update
methods.
so I added new parameter to create and update methods of crud to be
used in constructing SQLForm.

def update(
self,
table,
record,
next=DEFAULT,
onvalidation=DEFAULT,
onaccept=DEFAULT,
ondelete=DEFAULT,
log=DEFAULT,
message=DEFAULT,
deletable=DEFAULT,
labels=None,# HHM: added by Hassan
):
...
...
form = SQLFORM(
table,
record,
hidden=dict(_next=next),
showid=self.settings.showid,
submit_button=self.messages.submit_button,
delete_label=self.messages.delete_label,
deletable=deletable,
upload=self.settings.download_url,
labels=labels,# HHM: added by Hassan
)



[web2py] Re: Unable to connect to mysql DB - sql.py mod

2010-06-15 Thread The Czar
When I tried to enter a bacl slashed field (Odyssey\'s), it failed. So
I guess the default behavior is effectively NO_BACKSLASH_ESCAPES

On Jun 14, 11:23 pm, mdipierro  wrote:
> what is the default bahvior?
>
> On Jun 14, 9:51 am, The Czar  wrote:
>
> > I just checked the docs for the older version (4.1) SQL Modes. There
> > is no mention of the NO_BACKSLASH_ESCAPES mode.
>
> >http://dev.mysql.com/doc/refman/4.1/en/server-sql-mode.html
>
> > We have some unintended consequences. I'm surprised it doesn't
> > complain about this.
>
> > On Jun 14, 5:06 am, mdipierro  wrote:
>
> > > This line:
>
> > >             self._execute("SET sql_mode='NO_BACKSLASH_ESCAPES';")
>
> > > is important for security issues. SQL injections may be possible if
> > > you comment it. I do not know why it does not work on your system. It
> > > should
>
> > >http://mysql.linux.cz/doc/refman/5.5/en/server-sql-mode.html#sqlmode_...
>
> > > On Jun 13, 5:11 pm, The Czar  wrote:
>
> > > > For some reason, attempted connection to a mysql v4.1.25 db on FreeBSD
> > > > fails. The web2py is the latest version - but it happened on earlier
> > > > versions also. The error & db.py for the application failing looks
> > > > like this:
>
> > > > Error traceback
>
> > > > Traceback (most recent call last):
> > > >   File "/m/content/www/data/web2py-1-79-2/gluon/restricted.py", line
> > > > 178, in restricted
> > > >     exec ccode in environment
> > > >   File "/m/content/www/data/web2py-1-79-2/applications/myapp/models/
> > > > db.py", line 15, in 
> > > >     db = DAL('mysql://login:pas...@192.168.1.2/myapp') # use mySQL
> > > >   File "/m/content/www/data/web2py-1-79-2/gluon/sql.py", line 3855, in
> > > > DAL
> > > >     raise RuntimeError, "Failure to connect to DB. Tried 5 times"
> > > > RuntimeError: Failure to connect to DB. Tried 5 times
>
> > > > In file: /m/content/www/data/web2py-1-79-2/applications/myapp/models/
> > > > db.py
>
> > > > # -*- coding: utf-8 -*-
>
> > > > #
> > > > ## This scaffolding model makes your app work on Google App Engine too
> > > > #
>
> > > > if request.env.web2py_runtime_gae:            # if running on Google
> > > > App Engine
> > > >     db = DAL('gae')                           # connect to Google
> > > > BigTable
> > > >     session.connect(request, response, db=db) # and store sessions and
> > > > tickets there
> > > > else:                                         # else use a normal
> > > > relational database
> > > >     db = DAL('mysql://login:pas...@192.168.1.2/myapp') # use mySQL
>
> > > > =
> > > > Now if I comment out line 934 in gluon/sql.py, it connects without
> > > > error! The line looks like this:
> > > >  self._execute("SET sql_mode='NO_BACKSLASH_ESCAPES';")
>
> > > > This has been the case from rel. 1.76 to current 1.79.2.  Any ideas
> > > > about this error & work around. I don't always remember to make the
> > > > change for new releases and that causes unnecessary delay .
>
> > > > Thanks.


[web2py] Re: working with views or stored procedures.

2010-06-15 Thread Jose


On 15 jun, 05:12, Sky  wrote:
> Thank you Jose,
> but I couldn't find out if you used define_table or not?
> can you drop me a piece of your code?
> i get 'invalid query' error when i query on my views.
>

They are declared in the same way that a real table. Then you can
create queries, use them to link to other tables, etc.

In my specific case, no insert or update records, but if your database
engine accepts, there would be drawbacks.
One more thing, the view does not necessarily have to contain fields
for a single table, but can have as many joins as you like, that use
is transparent.

Jose


[web2py] Re: Internal error

2010-06-15 Thread Cory Coager
Any idea why sqlite is not working?


Re: [web2py] Re: my app instead of welcome app???

2010-06-15 Thread Jean-Guy

On 2010-06-15 02:45, mdipierro wrote:

se you do not have too, you can use ruotes already for this
purpose.
   
I read somewhere that we should modify the route in apache conf... I 
know I am not very precise I will try to found back the post of doc files...


What the best practice?

Jonhy


Re: [web2py] Re: my app instead of welcome app???

2010-06-15 Thread Jean-Guy

On 2010-06-15 02:45, mdipierro wrote:

se you do not have too, you can use ruotes already for this
purpose.
   

Here : http://www.web2py.com/AlterEgo/default/show/42


[web2py] where are the auth table model?

2010-06-15 Thread Jean-Guy

Hello,

I would like to get the auth tables models to implement them in my app 
cause web2py complain that they already are define when I move change 
from dev to prod database within the same app...


I had found those models, can't remember where they were... ;-)

Jonhy


[web2py] Re: where are the auth table model?

2010-06-15 Thread Pai
there's an option to customized it.  see below

http://web2py.com/book/default/section/8/1?search=Customizing+Auth

hope this helps :)

Pai

On Jun 15, 10:17 am, Jean-Guy  wrote:
> Hello,
>
> I would like to get the auth tables models to implement them in my app
> cause web2py complain that they already are define when I move change
> from dev to prod database within the same app...
>
> I had found those models, can't remember where they were... ;-)
>
> Jonhy


Re: [web2py] Re: where are the auth table model?

2010-06-15 Thread Jean-Guy

On 2010-06-15 11:36, Pai wrote:

there's an option to customized it.  see below

http://web2py.com/book/default/section/8/1?search=Customizing+Auth

hope this helps :)

Pai

On Jun 15, 10:17 am, Jean-Guy  wrote:
   

Hello,

I would like to get the auth tables models to implement them in my app
cause web2py complain that they already are define when I move change
from dev to prod database within the same app...

I had found those models, can't remember where they were... ;-)

Jonhy
 
Read it the others tables are missing, I found the model in .py files 
somewhere... Still searching for.


Thanks anyway it appreciate.

Jonhy


Re: [web2py] Re: my app instead of welcome app???

2010-06-15 Thread Thadeus Burgess
bah, whats the use.

--
Thadeus





On Tue, Jun 15, 2010 at 10:14 AM, Jean-Guy  wrote:
> On 2010-06-15 02:45, mdipierro wrote:
>
> se you do not have too, you can use ruotes already for this
> purpose.
>
>
> Here : http://www.web2py.com/AlterEgo/default/show/42


[web2py] Trouble doing manual insert of upload file

2010-06-15 Thread weheh
# model
db.define_table('srcfile',
  Field('name','upload',length=50,label=T('Upload
file'),autodelete=True,
uploadseparate=True,
requires=(
  IS_UPLOAD_FILENAME(extension='pdf|txt|doc|htm|html|xml|ppt'),
  IS_LENGTH(500,10))
),
  )

# controller
...
file_form=SQLFORM.factory(db.auth_user,db.othertable,db.srcfile)
...
if
file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
 db.srcfile.insert(
name=db.srcfile.name.store(
  request.vars.name.file,request.vars.name.filename),
)
...

Problem is, file gets uploaded into
  no_table.name/a2/
no_table.name.a24060930d31d0c1.313234363931322e747874.txt
prior to the insert. After the insert, there is a folder
  srcfile.name/b1/srcfile.name.b192a5e35dc5081e.
313234363931322e747874.txt
except that the file is empty.

Question: is this a bug, or do I need to explicitly copy from the
source to the destination? If the latter, what would the rationale be
for creating the destination file without copying the contents from
the source?


Re: [web2py] Re: my app instead of welcome app???

2010-06-15 Thread Jonathan Lundell
On Jun 14, 2010, at 8:40 PM, Richard wrote:

> would that go against the web2py philosophy of having no configuration
> files?

Not really. It could go in routes.py, which already (potentially) exists.

> 
> 
> On Jun 15, 1:33 pm, Thadeus Burgess  wrote:
>> Why can't we configure the default name of 'init' ?
> 




[web2py] Re: checking if table exists in database

2010-06-15 Thread Yarko Tymciurak
The first question you might answer is:  how would you do this without
web2py?  What are your steps?

Then, you can ask - how does web2py get into this, and what web2py
facilities (if any) do something like this?

A few observations:

If you 'create' a web2py table definition for an existing table, you
only need to define the fields you will be accessing.
This should be a good way to make a test table definition, with just
one field,  so that you can test if a table already exists
(set migrate=False in your test table definition - see
http://web2py.com/book/default/section/6/4 for more info).

... anything you could not (or would not want to) do simply in web2py
API calls, you can write sql and "send" it from web2py.
That means your first "exercise" of "how would I do this without
web2py" can become directly useful.

Some other sections that might be helpful:
http://web2py.com/book/default/section/6/7
http://web2py.com/book/default/section/6/4?search=executesql

- Yarko


On Jun 15, 3:30 am, mika  wrote:
> so what I can do if I have database already created? I would like
> simply to connect db and see if tables exists...
> by the way, metadata used by web2py to recognize tables created by
> itself is working only on sqlite, or on other db also?
>
> On Jun 11, 3:46 pm, mdipierro  wrote:
>
>
>
> > if you set migrate=True web2py does the check for you and eventually
> > creates tables. It can only detect tables if they were created by
> > web2py itself since it uses metadata for that purpose.


Re: [web2py] Re: my app instead of welcome app???

2010-06-15 Thread Jean-Guy

On 2010-06-15 11:47, Thadeus Burgess wrote:

bah, whats the use.

--
Thadeus





On Tue, Jun 15, 2010 at 10:14 AM, Jean-Guy  wrote:
   

On 2010-06-15 02:45, mdipierro wrote:

se you do not have too, you can use ruotes already for this
purpose.


Here : http://www.web2py.com/AlterEgo/default/show/42
 

Just specify the app to load by default...

Jonhy


[web2py] Re: where are the auth table model?

2010-06-15 Thread annet
Hi Johny,

I am facing the same problem, since there seems to be no proper
solution I use the following workaround:

I move everything that has to do with auth to its own db_01 file and
define all my tables in a separate db_00.py file. Now every time a
table definition changes, and I save db_00.py auth doesn't complain
about the already existing tables.

Now when I move the app containing auth to the deployment environment
I delete the auth_ tables from both the app and PostgreSQL in the
development environment. Once on the server, I open and save db_01.py,
which creates the auth_ tables on the server.

Every time I upgrade the app on the server I remove the auth_ .table
and sql.log from the databases folder, pack all, upload and install
the app on the server, and put the auth_ .table and sql.log files back
into the databases folder.

I know this is awkward, but I tried everything else, setting
fake_migrate=False etc. but none of this solved the problem, whereas
this procedure works for me.


I posted a similar question on 6th January, to which Massimo posted
the following reply:

""Tables have to be redefined (at the web2py level) every time you
need them. Therefore you must call auth.define_tables() or, as far as
web2py is concerned, they do not exist. When you define them at the
web2py level, if migrate=False, web2py assumes thay also exist in the
DB, if migrate=True it does not assumes that and looks into the .table
files.""


Kind regards,

Annet.


Re: [web2py] Re: my app instead of welcome app???

2010-06-15 Thread Thadeus Burgess
I ment... whats the use attempting to convince Massimo that this is a
good idea although many community members want it. He has been against
this suggestion for the last year that I have been using web2py and
this has been brought up many times, and he probably won't ever change
his mind, so we should just stop arguing the topic.

--
Thadeus





On Tue, Jun 15, 2010 at 12:05 PM, Jean-Guy  wrote:
> On 2010-06-15 11:47, Thadeus Burgess wrote:
>>
>> bah, whats the use.
>>
>> --
>> Thadeus
>>
>>
>>
>>
>>
>> On Tue, Jun 15, 2010 at 10:14 AM, Jean-Guy  wrote:
>>
>>>
>>> On 2010-06-15 02:45, mdipierro wrote:
>>>
>>> se you do not have too, you can use ruotes already for this
>>> purpose.
>>>
>>>
>>> Here : http://www.web2py.com/AlterEgo/default/show/42
>>>
>
> Just specify the app to load by default...
>
> Jonhy
>


[web2py] Date picker widget

2010-06-15 Thread greenpoise
How is it called? I have a custom form (no SQLForm) how would I get
the date picker to come out??


D.


Re: [web2py] Re: my app instead of welcome app???

2010-06-15 Thread Jean-Guy

On 2010-06-15 13:16, Thadeus Burgess wrote:

I ment... whats the use attempting to convince Massimo that this is a
good idea although many community members want it. He has been against
this suggestion for the last year that I have been using web2py and
this has been brought up many times, and he probably won't ever change
his mind, so we should just stop arguing the topic.

--
Thadeus





On Tue, Jun 15, 2010 at 12:05 PM, Jean-Guy  wrote:
   

On 2010-06-15 11:47, Thadeus Burgess wrote:
 

bah, whats the use.

--
Thadeus





On Tue, Jun 15, 2010 at 10:14 AM, Jean-Guywrote:

   

On 2010-06-15 02:45, mdipierro wrote:

se you do not have too, you can use ruotes already for this
purpose.


Here : http://www.web2py.com/AlterEgo/default/show/42

 

Just specify the app to load by default...

Jonhy

 

That works pretty much OK :

routes_in = (('/', '/yourappname/'),)



The only thing is the information should be made easily available in doc 
in the deployment recipe section... Then when come the time to push a 
site in prod the user has not to search or ask the mailing-list.




Jonhy




[web2py] Re: Defining db.py for the first time problem (db references possible?)

2010-06-15 Thread zsouthboy
Hi Yarko,

Thanks for the help!
I had initially tried doing what the introductory docs show (which is
marking a reference like ("image", db.image) for a column), which
fails because there is no member 'image' of db yet.
Then I consulted the technical docs and saw that instead "reference
image" should be used instead, so tried that, thinking that it would
be used as a placeholder (and filled in correctly later).
When that failed, I posted here.

The DAL doesn't recurse to allow this situation? Does anyone know
why / why not? When I get a chance I'll look at gluon and see how
trivial it would be to do, even in a hacky way.

I do have a separate issue now: following what you've suggested, I now
get complaints from gluon that referenced tables have duplicate field
names as the table being defined - did I miss something obvious? That
seems like there should be no issue doing so. (you can get this error
by simply copying and pasting the suggested fix you responded to me
with into a test db.py, even). Duplicate field names, but they're in
separate tables, so why the error?

Traceback (most recent call last):
  File "gluon/restricted.py", line 178, in restricted
exec ccode in environment
  File "/var/www/web2py/applications/golb/models/db.py", line 93, in

Field('published', 'boolean'))
  File "gluon/sql.py", line 1304, in define_table
t._create_references()
  File "gluon/sql.py", line 1579, in _create_references
raise SyntaxError, 'Field: table %s has same name as a field in
referenced table %s' % (self._tablename, referee._tablename)
SyntaxError: Field: table image has same name as a field in referenced
table person


[web2py] Re: rocket.ssl not found

2010-06-15 Thread The Czar
Take a look @ this thread...http://groups.google.com/group/web2py/
browse_thread/thread/704f055f74bfc8ed

On Jun 14, 1:25 pm, davidjensen  wrote:
> I am running 1.79.2 on red hat enterprise linux with python 2.5 on a
> hosting service with static ip and using port 8080. I have openssl.
>
> I am getting the error message
>
> use "kill -SIGTERM 2457" to shutdown the web2py server
> Traceback (most recent call last):
>   File "web2py.py", line 20, in 
>     gluon.widget.start(cron=True)
>   File "/var/www/html/web2py/gluon/widget.py", line 863, in start
>     path=options.folder)
>   File "/var/www/html/web2py/gluon/main.py", line 622, in __init__
>     elif not rocket.ssl:
> AttributeError: 'module' object has no attribute 'ssl'
>
> python 2.5 has no ssl module and rocket does try to import ssl with an
> exception handler. Also, main.py repeats code around where the
> rocket.ssl is.
>
> I would like to get this going, but I am also reporting what appears
> to be  errors.


[web2py] Does DAL supports creating DBs?

2010-06-15 Thread Phyo Arkar
Hello all

I am just wondering if DAL supports creating DBs before loading in
models?

I am Thinking about developing a DB Admin for web2py , which will
going to work like phpMyadmin.
But i am not sure how DAL of Web2py can create DBs. I think we have to
use python-mysql to do the work?


db=MySQLdb.connect(user='root')
cur =db.cursor()
cur.execute('CREATE DATABASE testdb')





Re: [web2py] Does DAL supports creating DBs?

2010-06-15 Thread Jean-Guy

On 2010-06-15 15:03, Phyo Arkar wrote:

ot sure how DAL of Web2py can create DBs. I think we have to
use python-mysql to do the work?
   

When you define a model web2py create the database for you!!

You have to tell wich RDBMS you use...

db=DAL  
('sqlite://storage.sqlite')

For you :


'mysql://username:passw...@localhost/test'


http://web2py.com/book/default/section/6/2?search=mysql


Jonhy


[web2py] Re: where are the auth table model?

2010-06-15 Thread weheh
Annet: just to be sure you understand ... to do a custom auth you
need:

from gluon.tools import *
auth=Auth(globals(),db)

auth_table=db.define_table(
  auth.settings.table_user_name,
  # required fields
  Field('email',length=128,label=T('Email'),default='',unique=True),
 
Field('password','password',readable=False,label=T('Password'),requires=CRYPT()),
  Field('first_name',length=128,label=T('First name'),default='').
  Field('last_name',length=128,label=T('Last name'),default=''),
  ...
  Field('my_other_field',)
  ...
)

# THIS STATEMENT MUST COME AFTER TABLE DEFINITION AND BEFORE
VALIDATORS
auth.settings.table_user=auth_table

auth.define_tables()# creates all needed tables for auth


I don't know whether the problems you're having might stem from not
following this structure.


[web2py] Writing good documentation

2010-06-15 Thread b00m_chef
http://jacobian.org/writing/great-documentation/


[web2py] Re: Does DAL supports creating DBs?

2010-06-15 Thread Phyo Arkar
 i meant Databases, i know it creates Tables.

db=DAL('mysql://username:passw...@localhost/test' )  #means you have a
database named test

In my case , Database is non-existance , well a user input name of
database to create , lets say testdb and it creates.



On Jun 15, 7:55 pm, Jean-Guy  wrote:
> On 2010-06-15 15:03, Phyo Arkar wrote:> ot sure how DAL of Web2py can create 
> DBs. I think we have to
> > use python-mysql to do the work?
>
> When you define a model web2py create the database for you!!
>
> You have to tell wich RDBMS you use...
>
> db=DAL  
> ('sqlite://storage.sqlite')
>
> For you :
>
> 'mysql://username:passw...@localhost/test'
>
> http://web2py.com/book/default/section/6/2?search=mysql
>
> Jonhy


[web2py] How to change the /default

2010-06-15 Thread Jean-Guy

Hello,

I would remove completly default folder in my app... I changed many 
files to not use default folder anymore, but logout function and 
initialization of the app still require to reach default/index.html


I change my routes.py that way as Massimo wrote :

routes_in = (('/', '/app/newfolderIwant/'),

Jonhy




Re: [web2py] Re: Does DAL supports creating DBs?

2010-06-15 Thread Jean-Guy

On 2010-06-15 17:01, Phyo Arkar wrote:

  i meant Databases, i know it creates Tables.

db=DAL('mysql://username:passw...@localhost/test' )  #means you have a
database named test

In my case , Database is non-existance , well a user input name of
database to create , lets say testdb and it creates.



On Jun 15, 7:55 pm, Jean-Guy  wrote:
   

On 2010-06-15 15:03, Phyo Arkar wrote:>  ot sure how DAL of Web2py can create 
DBs. I think we have to
 

use python-mysql to do the work?
   

When you define a model web2py create the database for you!!

You have to tell wich RDBMS you use...

db=DAL('sqlite://storage.sqlite')

For you :

'mysql://username:passw...@localhost/test'

http://web2py.com/book/default/section/6/2?search=mysql

Jonhy
 

No you have to create manually the empty database in mysql.

Maybe I didn't understand what you were expecting.

Jonhy




Re: [web2py] Re: Documentation on moving common code into modules?

2010-06-15 Thread David Mitchell
Thanks everyone,

Didn't work for me for a while, then I rewired my brain from "Ruby-mode" to
"Python-mode" and was off and running!

Dave M.

On 15 June 2010 10:48, weheh  wrote:

> +1 regarding Yarko's suggestion. Putting common code into modules is
> probably the easiest way to have it visible to all controllers. It
> seems a little kludgy at first, but you get used to it. The one thing
> to be aware of is that models get executed in alphabetic order. So you
> may want to stick a number or letter at the beginning of the model
> name, like A_, B_, C_, etc. to control order of execution. Like I
> said, a little kludgy, but you get used to it. You will not have this
> issue if you use the modules approach.


Re: [web2py] Re: sqlite modeller

2010-06-15 Thread Doug Warren
The problem I found with the web2py exporting though is that it dumps
it based on how you drew it on the page, top left first working to the
right then the next row etc...  So if you happened to placed a foreign
key on a lower section of the paper than where you're using it, you'll
get an import error...

On Mon, Jun 14, 2010 at 12:57 AM, Yarko Tymciurak
 wrote:
> The generic www sql modeler is:
>
> http://code.google.com/p/wwwsqldesigner/
>
> Not sure if anyone has been tracking this, but the code does have
> web2py (and sqlite) generation in the source tree.
>
> - Yarko
>
> On Jun 13, 9:13 pm, nhisyam  wrote:
>> Hi everyone,
>>
>> I am looking for the link for a webpage which allow users to draft/
>> draw database model which then can be exported as sqlite file. I have
>> clicked the link few times (long time ago) which was available from
>> web2py website. However now I couldn't find it anywhere. I totally
>> forgot the name and I'm seeking anyone's help to give me the link.
>>
>> It was a website for which user can just create new table, edit and
>> links the table graphically which is then can be exported as sqlite.
>>
>> If anyone know the link, please do help me. Thanks.
>>
>> (I have look around, but couldn't find it. It's hard to find when I
>> don't the remember the name of this website)
>>
>> Thanks in advance.
>>
>> Best regards,
>> --nhisyam


[web2py] Looking for web2py AJAX "recipes"

2010-06-15 Thread David Mitchell
Hello all,

I've got a bunch of AJAX pages to create, with tasks like:
- pick a selection from a drop-down list
- based on that selection, populate another drop-down list

- start typing in a text field
- with each character typed, do a search in a DB table for fields matching
the string typed and display options for selection

(not quite AJAX, but close)
- enter a date in a date field
- constrain other date fields on the same form so that they must be either
before or after the first-entered date

- allow someone to enter a long random string into a field, or press a
"Generate random string" button to have the string populated with suitable
random characters

Is there anything like an "AJAX recipes" page for web2py out there?
 Googling didn't come up with anything useful, but I thought some of these
are pretty common tasks and someone may have gathered code samples together
to demonstrate how it is done in web2py.

Thanks and regards

Dave M.


[web2py] Re: Does DAL supports creating DBs?

2010-06-15 Thread Phyo Arkar
What i am doing is a Webbased DBA like phpMyAdmin.

That can be done by executing cursor



import MySQLdb
db=MySQLdb.connect(user='root')
db.cursor().execute('CREATE DATABASE casedb')


It would be easy to implement in DAL too.

On Jun 15, 9:20 pm, Jean-Guy  wrote:
> On 2010-06-15 17:01, Phyo Arkar wrote:
>
> >   i meant Databases, i know it creates Tables.
>
> > db=DAL('mysql://username:passw...@localhost/test' )  #means you have a
> > database named test
>
> > In my case , Database is non-existance , well a user input name of
> > database to create , lets say testdb and it creates.
>
> > On Jun 15, 7:55 pm, Jean-Guy  wrote:
>
> >> On 2010-06-15 15:03, Phyo Arkar wrote:>  ot sure how DAL of Web2py can 
> >> create DBs. I think we have to
>
> >>> use python-mysql to do the work?
>
> >> When you define a model web2py create the database for you!!
>
> >> You have to tell wich RDBMS you use...
>
> >> db=DAL('sqlite://storage.sqlite')
>
> >> For you :
>
> >> 'mysql://username:passw...@localhost/test'
>
> >>http://web2py.com/book/default/section/6/2?search=mysql
>
> >> Jonhy
>
> No you have to create manually the empty database in mysql.
>
> Maybe I didn't understand what you were expecting.
>
> Jonhy


[web2py] Re: Does DAL supports creating DBs?

2010-06-15 Thread Phyo Arkar
This works.
db=MySQLdb.connect(user='root')
cur =db.cursor()
cur.execute('CREATE DATABASE testdb')

On Jun 15, 9:20 pm, Jean-Guy  wrote:
> On 2010-06-15 17:01, Phyo Arkar wrote:
>
> >   i meant Databases, i know it creates Tables.
>
> > db=DAL('mysql://username:passw...@localhost/test' )  #means you have a
> > database named test
>
> > In my case , Database is non-existance , well a user input name of
> > database to create , lets say testdb and it creates.
>
> > On Jun 15, 7:55 pm, Jean-Guy  wrote:
>
> >> On 2010-06-15 15:03, Phyo Arkar wrote:>  ot sure how DAL of Web2py can 
> >> create DBs. I think we have to
>
> >>> use python-mysql to do the work?
>
> >> When you define a model web2py create the database for you!!
>
> >> You have to tell wich RDBMS you use...
>
> >> db=DAL('sqlite://storage.sqlite')
>
> >> For you :
>
> >> 'mysql://username:passw...@localhost/test'
>
> >>http://web2py.com/book/default/section/6/2?search=mysql
>
> >> Jonhy
>
> No you have to create manually the empty database in mysql.
>
> Maybe I didn't understand what you were expecting.
>
> Jonhy


[web2py] Re: working with views or stored procedures.

2010-06-15 Thread Yarko Tymciurak

On Jun 15, 7:13 am, Jose  wrote:
> On 15 jun, 05:12, Sky  wrote:
>
> > Thank you Jose,
> > but I couldn't find out if you used define_table or not?
> > can you drop me a piece of your code?
> > i get 'invalid query' error when i query on my views.
>
> They are declared in the same way that a real table. Then you can
> create queries, use them to link to other tables, etc.

So you create a view in your db (not in web2py), and it sounds like
Jose included a field called "id".

On the web2py end, you would create a define_table definition, with
"migrate=False", which will prevent generation of any SQL to modify
the table - you would just match your define_table fields with what
you know you created in your view (note:  a table definition in web2py
does NOT need to specify an "entire" SQL table as it exists on the db
- only the fields that your web2py app will be accessing - so you can
make test connections very quickly, simply).

>
> In my specific case, no insert or update records, but if your database
> engine accepts, there would be drawbacks.

Performance of views can vary - so if you're doing any serious work,
you should pay attention to performance effects of views on your
particular server.


> One more thing, the view does not necessarily have to contain fields
> for a single table, but can have as many joins as you like, that use
> is transparent.
>
> Jose


[web2py] Re: my app instead of welcome app???

2010-06-15 Thread Yarko Tymciurak
On Jun 15, 1:05 pm, Jean-Guy  wrote:
> On 2010-06-15 13:16, Thadeus Burgess wrote:
>
>
>
> > I ment... whats the use attempting to convince Massimo that this is a
> > good idea although many community members want it. He has been against
> > this suggestion for the last year that I have been using web2py and
> > this has been brought up many times, and he probably won't ever change
> > his mind, so we should just stop arguing the topic.
>
> > --
> > Thadeus
>
> > On Tue, Jun 15, 2010 at 12:05 PM, Jean-Guy  wrote:
>
> >> On 2010-06-15 11:47, Thadeus Burgess wrote:
>
> >>> bah, whats the use.
>
> >>> --
> >>> Thadeus
>
> >>> On Tue, Jun 15, 2010 at 10:14 AM, Jean-Guy    wrote:
>
>  On 2010-06-15 02:45, mdipierro wrote:
>
>  se you do not have too, you can use ruotes already for this
>  purpose.
>
>  Here :http://www.web2py.com/AlterEgo/default/show/42
>
> >> Just specify the app to load by default...
>
> >> Jonhy
>
> That works pretty much OK :
>
> routes_in = (('/', '/yourappname/'),)

 and don't forget  routes_out, and routes_error  for this to
work like  init or welcome, you have to think about it a bit.

While routes.py is _general_ it is not as simple & straightforward as
a command line or other kind of config option would be (note: there
are already configuration parameters currently held in parameters.py
 Massimo is just against, I think, a rampant explosion of these -
wants to limit them).

Thadeus points out this:   it's a very common request, an often used
thing (yes you _can_ just link or rename your app to applications/
init!!!  and why wouldn't you???).

I think the simpler solution (simpler than routes.py) is - when
deploying, link your app to applicaitons/init --- it is simple, it
will behave as you want, and the only "operating system" that I can
think of that doesn't have directory level symbolic links is
(possibly)   Windows.

I think there are already 2 ways to do this, one flexible (routes),
one simple (link your app to init) - and the only possible complainers
would be those deploying on windows, and even for them a simple
solution is simply renaming their desired app to init.

As Thadeus points out (albeit for different reasons) there is no real
reason to argue this.

Done!

Regards,
- Yarko

>
> The only thing is the information should be made easily available in doc
> in the deployment recipe section... Then when come the time to push a
> site in prod the user has not to search or ask the mailing-list.
>
> Jonhy


[web2py] Re: where are the auth table model?

2010-06-15 Thread Yarko Tymciurak
On Jun 15, 10:39 am, Jean-Guy  wrote:
> On 2010-06-15 11:36, Pai wrote:
>
>
>
> > there's an option to customized it.  see below
>
> >http://web2py.com/book/default/section/8/1?search=Customizing+Auth
>
> > hope this helps :)
>
> > Pai
>
> > On Jun 15, 10:17 am, Jean-Guy  wrote:
>
> >> Hello,
>
> >> I would like to get the auth tables models to implement them in my app
> >> cause web2py complain that they already are define when I move change
> >> from dev to prod database within the same app...

Read what you said here:   You change the definition of your auth
table (e.g. define it yourself) - and when you move to production,
that table already exists in your production database.

What are you "moving" when you say "you move change"?


>
> >> I had found those models, can't remember where they were... ;-)
>
> >> Jonhy
>
> Read it the others tables are missing, I found the model in .py files
> somewhere... Still searching for.

What do you mean "others tables are missing"?   Did you include
auth.define_tables() in the correct order?

Look at that referenced book link again.

Then - if you still need help, tell us what you are doing in a way
that someone _could_ reproduce, and help you with.

- Yarko

>
> Thanks anyway it appreciate.
>
> Jonhy


[web2py] Any Server side File management appliance in python?

2010-06-15 Thread Phyo Arkar
Hi All

Is there any appliance with Server Side file brower , or any other
python webapp have it?  I am bored to do my own and going to use if
there anything out there. Like Net2ftp .

Already existed in Appliances? Or somewhere else?


Regards


Phyo.


[web2py] Unpredictable sqlite3.dll version being loaded by web2py.exe

2010-06-15 Thread Salvor Hardin
It would be great if web2py.exe loads sqlite3.dll from the same
directory as web2py.exe.

Unfortunately, web2py loads C:\Windows\System32\sqlite3.dll which is
the most unpredictable version of sqlite3.dll on Windows.

I didn't realize this until I tried replacing C:\web2py\sqlite3.dll
with an encryption-enabled version.  I confirmed using Process
Explorer to see which sqlite3.dll was loaded by web2py.exe.

I have 3 different sqlite3.dll, and this is the ideal load order:

1.  C:\Web2py\sqlite3.dll -- bundled with web2py
2.  C:\Python25\DLLs\sqlite3.dll -- bundled with Python
3.  C:\Windows\System32\sqlite3.dll -- very old version installed by
unknown software (unpredictable)


[web2py] Re: WordPressClone/PyPress GAE fix

2010-06-15 Thread Richard
awesome! I am looking for a simple web2py blog system to run on GAE.

in your message "for" got connected with the url:
http://www.molhokwai.net/blog


On Jun 15, 7:12 pm, molhokwai  wrote:
> Hello there...
>
> Implemented fixes to run PyPress on GAE 
> (Seehttp://www.molhokwai.net/blogforhow it's working...).
> Code fixes attached, and complete .w2p app also.
>
> Thanks all.
> ---
> *M*ayou *N*kensa *P*enda *N*gué
> +32 489 33 71 
> 51,molhok...@gmail.com,skype:molhokwaihttp://www.google.com/profiles/molhokwai
>
>  web2py.app.blog.w2p
> 56KViewDownload
>
>  WorpdressClone_GAE_Fix.zip
> 10KViewDownload


[web2py] Re: WordPressClone/PyPress GAE fix

2010-06-15 Thread Richard
do you have a public repository for your updates?

Also there seems to already be a version of pypress on GAE since 09:
http://pp4gae.appspot.com/


On Jun 16, 10:14 am, Richard  wrote:
> awesome! I am looking for a simple web2py blog system to run on GAE.
>
> in your message "for" got connected with the url:http://www.molhokwai.net/blog
>
> On Jun 15, 7:12 pm, molhokwai  wrote:
>
> > Hello there...
>
> > Implemented fixes to run PyPress on GAE 
> > (Seehttp://www.molhokwai.net/blogforhowit's working...).
> > Code fixes attached, and complete .w2p app also.
>
> > Thanks all.
> > ---
> > *M*ayou *N*kensa *P*enda *N*gué
> > +32 489 33 71 
> > 51,molhok...@gmail.com,skype:molhokwaihttp://www.google.com/profiles/molhokwai
>
> >  web2py.app.blog.w2p
> > 56KViewDownload
>
> >  WorpdressClone_GAE_Fix.zip
> > 10KViewDownload


[web2py] code broke, help

2010-06-15 Thread greenpoise
Ok this used to work:

def qryfecha():

form=FORM (H1(TABLE
(TR(('From:',INPUT(_name="desde",_class='date',_id="desde",requires=IS_DATE())),
 
('To:',INPUT(_name="to",_class='date',_id="to",default=request.now,requires=IS_DATE(),
INPUT(_type='submit')))

fromvar=request.vars.desde
tovar=request.vars.to

rows = db((db.orden.fechaorden >= fromvar)&(db.orden.fechaorden <=
tovar)).select(db.orden.waitertip.sum())
for row in rows: print
row[db.orden.waitertip.sum()]

return dict(form=form,rows=rows)




not anymore. Leads?



[web2py] Re: code broke, help

2010-06-15 Thread mr.freeze
Do you get an error? If so, can you show the traceback?

On Jun 15, 8:01 pm, greenpoise  wrote:
> Ok this used to work:
>
> def qryfecha():
>
>     form=FORM (H1(TABLE
> (TR(('From:',INPUT(_name="desde",_class='date',_id="desde",requires=IS_DATE 
> ())),
>
> ('To:',INPUT(_name="to",_class='date',_id="to",default=request.now,requires 
> =IS_DATE(),
> INPUT(_type='submit')))
>
>     fromvar=request.vars.desde
>     tovar=request.vars.to
>
>     rows = db((db.orden.fechaorden >= fromvar)&(db.orden.fechaorden <=
> tovar)).select(db.orden.waitertip.sum())
>     for row in rows: print
>     row[db.orden.waitertip.sum()]
>
>     return dict(form=form,rows=rows)
>
> not anymore. Leads?


[web2py] Re: code broke, help

2010-06-15 Thread greenpoise
here it is:

Error traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.



Traceback (most recent call last):
  File "/home/danel/Applications/web2py/gluon/restricted.py", line
178, in restricted
exec ccode in environment
  File "/home/danel/Applications/web2py/applications/shroomV2/
controllers/default.py", line 314, in 
  File "/home/danel/Applications/web2py/gluon/globals.py", line 96, in

self._caller = lambda f: f()
  File "/home/danel/Applications/web2py/gluon/tools.py", line 2036, in
f
return action(*a, **b)
  File "/home/danel/Applications/web2py/applications/shroomV2/
controllers/default.py", line 245, in qryfecha
rows = db((db.orden.fechaorden >= fromvar)&(db.orden.fechaorden <=
tovar)).select(db.orden.waitertip.sum())
  File "/home/danel/Applications/web2py/gluon/sql.py", line 2483, in
__ge__
return Query(self, '>=', value)
  File "/home/danel/Applications/web2py/gluon/sql.py", line 2866, in
__init__
raise SyntaxError, 'Operation %s can\'t be used with None' % op
SyntaxError: Operation >= can't be used with None


On Jun 15, 9:37 pm, "mr.freeze"  wrote:
> Do you get an error? If so, can you show the traceback?
>
> On Jun 15, 8:01 pm, greenpoise  wrote:
>
> > Ok this used to work:
>
> > def qryfecha():
>
> >     form=FORM (H1(TABLE
> > (TR(('From:',INPUT(_name="desde",_class='date',_id="desde",requires=IS_DATE 
> > ())),
>
> > ('To:',INPUT(_name="to",_class='date',_id="to",default=request.now,requires 
> > =IS_DATE(),
> > INPUT(_type='submit')))
>
> >     fromvar=request.vars.desde
> >     tovar=request.vars.to
>
> >     rows = db((db.orden.fechaorden >= fromvar)&(db.orden.fechaorden <=
> > tovar)).select(db.orden.waitertip.sum())
> >     for row in rows: print
> >     row[db.orden.waitertip.sum()]
>
> >     return dict(form=form,rows=rows)
>
> > not anymore. Leads?


[web2py] Re: sqlite modeller

2010-06-15 Thread Yarko Tymciurak
...in the years we've been looking at this tool on these forums (and
it is a cool tool), it just never really seemed justified in practice.

It always seems easiest to code up your tables.   It does make for
nice documentation images, though

YMMV

On Jun 15, 4:46 pm, Doug Warren  wrote:
> The problem I found with the web2py exporting though is that it dumps
> it based on how you drew it on the page, top left first working to the
> right then the next row etc...  So if you happened to placed a foreign
> key on a lower section of the paper than where you're using it, you'll
> get an import error...
>
> On Mon, Jun 14, 2010 at 12:57 AM, Yarko Tymciurak
>
>
>
>  wrote:
> > The generic www sql modeler is:
>
> >http://code.google.com/p/wwwsqldesigner/
>
> > Not sure if anyone has been tracking this, but the code does have
> > web2py (and sqlite) generation in the source tree.
>
> > - Yarko
>
> > On Jun 13, 9:13 pm, nhisyam  wrote:
> >> Hi everyone,
>
> >> I am looking for the link for a webpage which allow users to draft/
> >> draw database model which then can be exported as sqlite file. I have
> >> clicked the link few times (long time ago) which was available from
> >> web2py website. However now I couldn't find it anywhere. I totally
> >> forgot the name and I'm seeking anyone's help to give me the link.
>
> >> It was a website for which user can just create new table, edit and
> >> links the table graphically which is then can be exported as sqlite.
>
> >> If anyone know the link, please do help me. Thanks.
>
> >> (I have look around, but couldn't find it. It's hard to find when I
> >> don't the remember the name of this website)
>
> >> Thanks in advance.
>
> >> Best regards,
> >> --nhisyam


[web2py] Re: code broke, help

2010-06-15 Thread mr.freeze
I would just check that fromvar and tovar are not None before getting
the rows.

On Jun 15, 8:40 pm, greenpoise  wrote:
> here it is:
>
> Error traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
>
> Traceback (most recent call last):
>   File "/home/danel/Applications/web2py/gluon/restricted.py", line
> 178, in restricted
>     exec ccode in environment
>   File "/home/danel/Applications/web2py/applications/shroomV2/
> controllers/default.py", line 314, in 
>   File "/home/danel/Applications/web2py/gluon/globals.py", line 96, in
> 
>     self._caller = lambda f: f()
>   File "/home/danel/Applications/web2py/gluon/tools.py", line 2036, in
> f
>     return action(*a, **b)
>   File "/home/danel/Applications/web2py/applications/shroomV2/
> controllers/default.py", line 245, in qryfecha
>     rows = db((db.orden.fechaorden >= fromvar)&(db.orden.fechaorden <=
> tovar)).select(db.orden.waitertip.sum())
>   File "/home/danel/Applications/web2py/gluon/sql.py", line 2483, in
> __ge__
>     return Query(self, '>=', value)
>   File "/home/danel/Applications/web2py/gluon/sql.py", line 2866, in
> __init__
>     raise SyntaxError, 'Operation %s can\'t be used with None' % op
> SyntaxError: Operation >= can't be used with None
>
> On Jun 15, 9:37 pm, "mr.freeze"  wrote:
>
>
>
> > Do you get an error? If so, can you show the traceback?
>
> > On Jun 15, 8:01 pm, greenpoise  wrote:
>
> > > Ok this used to work:
>
> > > def qryfecha():
>
> > >     form=FORM (H1(TABLE
> > > (TR(('From:',INPUT(_name="desde",_class='date',_id="desde",requires=IS_DATE
> > >  ())),
>
> > > ('To:',INPUT(_name="to",_class='date',_id="to",default=request.now,requires
> > >  =IS_DATE(),
> > > INPUT(_type='submit')))
>
> > >     fromvar=request.vars.desde
> > >     tovar=request.vars.to
>
> > >     rows = db((db.orden.fechaorden >= fromvar)&(db.orden.fechaorden <=
> > > tovar)).select(db.orden.waitertip.sum())
> > >     for row in rows: print
> > >     row[db.orden.waitertip.sum()]
>
> > >     return dict(form=form,rows=rows)
>
> > > not anymore. Leads?


[web2py] Re: Unpredictable sqlite3.dll version being loaded by web2py.exe

2010-06-15 Thread Yarko Tymciurak

On Jun 15, 6:29 pm, Salvor Hardin  wrote:
> It would be great if web2py.exe loads sqlite3.dll from the same
> directory as web2py.exe.
>
> Unfortunately, web2py loads C:\Windows\System32\sqlite3.dll which is
> the most unpredictable version of sqlite3.dll on Windows.


Hmmm  this may have to do with your library load path;   I'm not
sure what that is for windows, but if it's loading the way you say, I
would look at your user environment, for I would guess it is doing the
same for your normal python executions (I would have suggested the
source distro of web2py, except I expect you will still run into this,
because I suspect it has to do with your dynamic library load order
for your user instance).

Let us know what you find.


> I didn't realize this until I tried replacing C:\web2py\sqlite3.dll
> with an encryption-enabled version.  I confirmed using Process
> Explorer to see which sqlite3.dll was loaded by web2py.exe.
>
> I have 3 different sqlite3.dll, and this is the ideal load order:
>
> 1.  C:\Web2py\sqlite3.dll -- bundled with web2py
> 2.  C:\Python25\DLLs\sqlite3.dll -- bundled with Python
> 3.  C:\Windows\System32\sqlite3.dll -- very old version installed by
> unknown software (unpredictable)


[web2py] Re: Looking for web2py AJAX "recipes"

2010-06-15 Thread GoldenTiger
http://www.web2pyslices.com is usefull for me

On 15 jun, 23:48, David Mitchell  wrote:
> Hello all,
>
> I've got a bunch of AJAX pages to create, with tasks like:
> - pick a selection from a drop-down list
> - based on that selection, populate another drop-down list
>
> - start typing in a text field
> - with each character typed, do a search in a DB table for fields matching
> the string typed and display options for selection
>
> (not quite AJAX, but close)
> - enter a date in a date field
> - constrain other date fields on the same form so that they must be either
> before or after the first-entered date
>
> - allow someone to enter a long random string into a field, or press a
> "Generate random string" button to have the string populated with suitable
> random characters
>
> Is there anything like an "AJAX recipes" page for web2py out there?
>  Googling didn't come up with anything useful, but I thought some of these
> are pretty common tasks and someone may have gathered code samples together
> to demonstrate how it is done in web2py.
>
> Thanks and regards
>
> Dave M.


[web2py] Re: Any Server side File management appliance in python?

2010-06-15 Thread GoldenTiger
http://elrte.ru/en/elfinder

I have found this usefull file manager, a python webapp, you will like
it

On 16 jun, 01:06, Phyo Arkar  wrote:
> Hi All
>
> Is there any appliance with Server Side file brower , or any other
> python webapp have it?  I am bored to do my own and going to use if
> there anything out there. Like Net2ftp .
>
> Already existed in Appliances? Or somewhere else?
>
> Regards
>
> Phyo.


[web2py] Re: Defining db.py for the first time problem (db references possible?)

2010-06-15 Thread Yarko Tymciurak

On Jun 15, 1:56 pm, zsouthboy  wrote:
> Hi Yarko,
>
> Thanks for the help!
> I had initially tried doing what the introductory docs show (which is
> marking a reference like ("image", db.image) for a column), which
> fails because there is no member 'image' of db yet.
> Then I consulted the technical docs and saw that instead "reference
> image" should be used instead, so tried that, thinking that it would
> be used as a placeholder (and filled in correctly later).
> When that failed, I posted here.
>
> The DAL doesn't recurse to allow this situation? Does anyone know
> why / why not? When I get a chance I'll look at gluon and see how
> trivial it would be to do, even in a hacky way.

... consider dropping this from your vocabulary: " even in a hacky
way...";

>
> I do have a separate issue now: following what you've suggested, I now
> get complaints from gluon that referenced tables have duplicate field
> names as the table being defined - did I miss something obvious? That
> seems like there should be no issue doing so. (you can get this error

Yes, it seems so:   in gluon/(dal|sql).py, in
Table._create_references(), there's:

if self._tablename in referee.fields:

with no comments - so beyond the shallow, immediate reading for that
line, we have no clue
as to the motivation / reasoning for this particular constraint
(reverse engineering every little thing
just to try to get what intended...  besides being no better than
guessing, mind-reading,
also gets tedious).If you simply rename db.person.image to
something w/o the 'image' (tablename),
e.g.  db.person.image_id  --- this goes away.

As to forward references:
I commented out the lines in Table._create_references()  (and the
exception it raises), and __get__ errors come, so there is at least
that simple get/set work to do to get forward references; not sure if
there would be anything else.   Commented code _sure would be nice_!

- Yarko

> by simply copying and pasting the suggested fix you responded to me
> with into a test db.py, even). Duplicate field names, but they're in
> separate tables, so why the error?
>
> Traceback (most recent call last):
>   File "gluon/restricted.py", line 178, in restricted
>     exec ccode in environment
>   File "/var/www/web2py/applications/golb/models/db.py", line 93, in
> 
>     Field('published', 'boolean'))
>   File "gluon/sql.py", line 1304, in define_table
>     t._create_references()
>   File "gluon/sql.py", line 1579, in _create_references
>     raise SyntaxError, 'Field: table %s has same name as a field in
> referenced table %s' % (self._tablename, referee._tablename)
> SyntaxError: Field: table image has same name as a field in referenced
> table person


Re: [web2py] Re: Documentation on moving common code into modules?

2010-06-15 Thread Thadeus Burgess
web2py does NOT follow normal python conventions. You are writing
web2py code not python code =)

--
Thadeus





On Tue, Jun 15, 2010 at 4:41 PM, David Mitchell  wrote:
> Thanks everyone,
> Didn't work for me for a while, then I rewired my brain from "Ruby-mode" to
> "Python-mode" and was off and running!
> Dave M.
>
> On 15 June 2010 10:48, weheh  wrote:
>>
>> +1 regarding Yarko's suggestion. Putting common code into modules is
>> probably the easiest way to have it visible to all controllers. It
>> seems a little kludgy at first, but you get used to it. The one thing
>> to be aware of is that models get executed in alphabetic order. So you
>> may want to stick a number or letter at the beginning of the model
>> name, like A_, B_, C_, etc. to control order of execution. Like I
>> said, a little kludgy, but you get used to it. You will not have this
>> issue if you use the modules approach.
>


[web2py] Re: Unpredictable sqlite3.dll version being loaded by web2py.exe

2010-06-15 Thread Salvor Hardin


On Jun 15, 9:12 pm, Yarko Tymciurak 
wrote:
> On Jun 15, 6:29 pm, Salvor Hardin  wrote:
>
> > It would be great if web2py.exe loads sqlite3.dll from the same
> > directory as web2py.exe.
>
> > Unfortunately, web2py loads C:\Windows\System32\sqlite3.dll which is
> > the most unpredictable version of sqlite3.dll on Windows.
>
> Hmmm  this may have to do with your library load path;   I'm not
> sure what that is for windows, but if it's loading the way you say, I
> would look at your user environment, for I would guess it is doing the
> same for your normal python executions (I would have suggested the
> source distro of web2py, except I expect you will still run into this,
> because I suspect it has to do with your dynamic library load order
> for your user instance).
>
> Let us know what you find.
>

I got an unexpected result.

C:\Python25\python.exe loads C:\Python25\Dlls\sqlite3.dll when I issue
"import sqlite3"

And, C:\web2py\web2py.exe loads C:\Windows\system32\sqlite3.dll
immediately (before pressing Start Server button.)

FWIW, in my Win32 apps,  I specify the full path when calling
LoadLibrary() for DLLs bundled with my app.  I usually grab the
current process's .exe path and then prefix that to DLL names.
Otherwise, I have to deal with the insanity of Windows having multiple
different DLL search orders depending on external factors as described
here:

Dynamic-Link Library Search Order
http://msdn.microsoft.com/en-us/library/ms682586(VS.85).aspx

Makes me want to throw Windows out the window.


[web2py] Re: Unpredictable sqlite3.dll version being loaded by web2py.exe

2010-06-15 Thread Yarko Tymciurak

On Jun 15, 10:26 pm, Salvor Hardin  wrote:
> On Jun 15, 9:12 pm, Yarko Tymciurak 
> wrote:
>
>
>
>
>
> > On Jun 15, 6:29 pm, Salvor Hardin  wrote:
>
> > > It would be great if web2py.exe loads sqlite3.dll from the same
> > > directory as web2py.exe.
>
> > > Unfortunately, web2py loads C:\Windows\System32\sqlite3.dll which is
> > > the most unpredictable version of sqlite3.dll on Windows.
>
> > Hmmm  this may have to do with your library load path;   I'm not
> > sure what that is for windows, but if it's loading the way you say, I
> > would look at your user environment, for I would guess it is doing the
> > same for your normal python executions (I would have suggested the
> > source distro of web2py, except I expect you will still run into this,
> > because I suspect it has to do with your dynamic library load order
> > for your user instance).
>
> > Let us know what you find.
>
> I got an unexpected result.
>
> C:\Python25\python.exe loads C:\Python25\Dlls\sqlite3.dll when I issue
> "import sqlite3"
>
> And, C:\web2py\web2py.exe loads C:\Windows\system32\sqlite3.dll
> immediately (before pressing Start Server button.)

If that is the case, then the dynamic load order may be an artifact of
whoever ran py2exe to generate the web2py.exe (in other words, _their_
system is the problem, and it propogated to you).

But the good news - if you're python pulls in the correct sqlite ---
is you will be all set if you just use the source version of web2py.

In the meantime, we can let Massimo sort through / ask more questions
as he needs to fix web2py.exe generation.

- Yarko
>
> FWIW, in my Win32 apps,  I specify the full path when calling
> LoadLibrary() for DLLs bundled with my app.  I usually grab the
> current process's .exe path and then prefix that to DLL names.
> Otherwise, I have to deal with the insanity of Windows having multiple
> different DLL search orders depending on external factors as described
> here:
>
> Dynamic-Link Library Search 
> Orderhttp://msdn.microsoft.com/en-us/library/ms682586(VS.85).aspx
>
> Makes me want to throw Windows out the window.


[web2py] Re: crud does not support labels for forms. am i wrong ?

2010-06-15 Thread mdipierro
No because this should be done with

db.table.field.label='new label'

On Jun 15, 3:57 am, Sky  wrote:
> as i looked in source code of crud ( tools.py ) you can't change the
> 'lables' property of SQLForm returned from crud.create or crud.update
> methods.
> so I added new parameter to create and update methods of crud to be
> used in constructing SQLForm.
>
>     def update(
>         self,
>         table,
>         record,
>         next=DEFAULT,
>         onvalidation=DEFAULT,
>         onaccept=DEFAULT,
>         ondelete=DEFAULT,
>         log=DEFAULT,
>         message=DEFAULT,
>         deletable=DEFAULT,
>                 labels=None,# HHM: added by Hassan
>         ):
> ...
> ...
> form = SQLFORM(
>             table,
>             record,
>             hidden=dict(_next=next),
>             showid=self.settings.showid,
>             submit_button=self.messages.submit_button,
>             delete_label=self.messages.delete_label,
>             deletable=deletable,
>             upload=self.settings.download_url,
>                         labels=labels,# HHM: added by Hassan
>             )


[web2py] Re: Unable to connect to mysql DB - sql.py mod

2010-06-15 Thread mdipierro
I think it is the opposite. You are vulnerable to injections.

On Jun 15, 5:35 am, The Czar  wrote:
> When I tried to enter a bacl slashed field (Odyssey\'s), it failed. So
> I guess the default behavior is effectively NO_BACKSLASH_ESCAPES
>
> On Jun 14, 11:23 pm, mdipierro  wrote:
>
> > what is the default bahvior?
>
> > On Jun 14, 9:51 am, The Czar  wrote:
>
> > > I just checked the docs for the older version (4.1) SQL Modes. There
> > > is no mention of the NO_BACKSLASH_ESCAPES mode.
>
> > >http://dev.mysql.com/doc/refman/4.1/en/server-sql-mode.html
>
> > > We have some unintended consequences. I'm surprised it doesn't
> > > complain about this.
>
> > > On Jun 14, 5:06 am, mdipierro  wrote:
>
> > > > This line:
>
> > > >             self._execute("SET sql_mode='NO_BACKSLASH_ESCAPES';")
>
> > > > is important for security issues. SQL injections may be possible if
> > > > you comment it. I do not know why it does not work on your system. It
> > > > should
>
> > > >http://mysql.linux.cz/doc/refman/5.5/en/server-sql-mode.html#sqlmode_...
>
> > > > On Jun 13, 5:11 pm, The Czar  wrote:
>
> > > > > For some reason, attempted connection to a mysql v4.1.25 db on FreeBSD
> > > > > fails. The web2py is the latest version - but it happened on earlier
> > > > > versions also. The error & db.py for the application failing looks
> > > > > like this:
>
> > > > > Error traceback
>
> > > > > Traceback (most recent call last):
> > > > >   File "/m/content/www/data/web2py-1-79-2/gluon/restricted.py", line
> > > > > 178, in restricted
> > > > >     exec ccode in environment
> > > > >   File "/m/content/www/data/web2py-1-79-2/applications/myapp/models/
> > > > > db.py", line 15, in 
> > > > >     db = DAL('mysql://login:pas...@192.168.1.2/myapp') # use mySQL
> > > > >   File "/m/content/www/data/web2py-1-79-2/gluon/sql.py", line 3855, in
> > > > > DAL
> > > > >     raise RuntimeError, "Failure to connect to DB. Tried 5 times"
> > > > > RuntimeError: Failure to connect to DB. Tried 5 times
>
> > > > > In file: /m/content/www/data/web2py-1-79-2/applications/myapp/models/
> > > > > db.py
>
> > > > > # -*- coding: utf-8 -*-
>
> > > > > #
> > > > > ## This scaffolding model makes your app work on Google App Engine too
> > > > > #
>
> > > > > if request.env.web2py_runtime_gae:            # if running on Google
> > > > > App Engine
> > > > >     db = DAL('gae')                           # connect to Google
> > > > > BigTable
> > > > >     session.connect(request, response, db=db) # and store sessions and
> > > > > tickets there
> > > > > else:                                         # else use a normal
> > > > > relational database
> > > > >     db = DAL('mysql://login:pas...@192.168.1.2/myapp') # use mySQL
>
> > > > > =
> > > > > Now if I comment out line 934 in gluon/sql.py, it connects without
> > > > > error! The line looks like this:
> > > > >  self._execute("SET sql_mode='NO_BACKSLASH_ESCAPES';")
>
> > > > > This has been the case from rel. 1.76 to current 1.79.2.  Any ideas
> > > > > about this error & work around. I don't always remember to make the
> > > > > change for new releases and that causes unnecessary delay .
>
> > > > > Thanks.


[web2py] Re: Internal error

2010-06-15 Thread mdipierro
No. the error you reported was with postgresql 8.1. What is the
problem with sqlite?

On Jun 15, 7:57 am, Cory Coager  wrote:
> Any idea why sqlite is not working?


[web2py] Re: Trouble doing manual insert of upload file

2010-06-15 Thread mdipierro
May be a bug. can you try?

file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
 request.vars.name.file.seek(0) ### add this line
 db.srcfile.insert(
name=db.srcfile.name.store(
  request.vars.name.file,request.vars.name.filename),
)

On Jun 15, 11:02 am, weheh  wrote:
> # model
> db.define_table('srcfile',
>   Field('name','upload',length=50,label=T('Upload
> file'),autodelete=True,
>     uploadseparate=True,
>     requires=(
>       IS_UPLOAD_FILENAME(extension='pdf|txt|doc|htm|html|xml|ppt'),
>       IS_LENGTH(500,10))
>     ),
>   )
>
> # controller
> ...
> file_form=SQLFORM.factory(db.auth_user,db.othertable,db.srcfile)
> ...
> if
> file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
>      db.srcfile.insert(
>         name=db.srcfile.name.store(
>           request.vars.name.file,request.vars.name.filename),
>         )
> ...
>
> Problem is, file gets uploaded into
>   no_table.name/a2/
> no_table.name.a24060930d31d0c1.313234363931322e747874.txt
> prior to the insert. After the insert, there is a folder
>   srcfile.name/b1/srcfile.name.b192a5e35dc5081e.
> 313234363931322e747874.txt
> except that the file is empty.
>
> Question: is this a bug, or do I need to explicitly copy from the
> source to the destination? If the latter, what would the rationale be
> for creating the destination file without copying the contents from
> the source?


[web2py] Re: Trouble doing manual insert of upload file

2010-06-15 Thread mdipierro
Actually this would work but it is not the best way, ... the problem
is that the storage is already performed by accepts so you must do
simply

file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
  db.srcfile.insert(name=form.vars.name)



On Jun 15, 10:44 pm, mdipierro  wrote:
> May be a bug. can you try?
>
> file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
>      request.vars.name.file.seek(0) ### add this line
>      db.srcfile.insert(
>         name=db.srcfile.name.store(
>           request.vars.name.file,request.vars.name.filename),
>         )
>
> On Jun 15, 11:02 am, weheh  wrote:
>
> > # model
> > db.define_table('srcfile',
> >   Field('name','upload',length=50,label=T('Upload
> > file'),autodelete=True,
> >     uploadseparate=True,
> >     requires=(
> >       IS_UPLOAD_FILENAME(extension='pdf|txt|doc|htm|html|xml|ppt'),
> >       IS_LENGTH(500,10))
> >     ),
> >   )
>
> > # controller
> > ...
> > file_form=SQLFORM.factory(db.auth_user,db.othertable,db.srcfile)
> > ...
> > if
> > file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
> >      db.srcfile.insert(
> >         name=db.srcfile.name.store(
> >           request.vars.name.file,request.vars.name.filename),
> >         )
> > ...
>
> > Problem is, file gets uploaded into
> >   no_table.name/a2/
> > no_table.name.a24060930d31d0c1.313234363931322e747874.txt
> > prior to the insert. After the insert, there is a folder
> >   srcfile.name/b1/srcfile.name.b192a5e35dc5081e.
> > 313234363931322e747874.txt
> > except that the file is empty.
>
> > Question: is this a bug, or do I need to explicitly copy from the
> > source to the destination? If the latter, what would the rationale be
> > for creating the destination file without copying the contents from
> > the source?


[web2py] Re: rocket.ssl not found

2010-06-15 Thread mdipierro
There should be a more graceful report about this error... Tim?

On Jun 15, 1:57 pm, The Czar  wrote:
> Take a look @ this thread...http://groups.google.com/group/web2py/
> browse_thread/thread/704f055f74bfc8ed
>
> On Jun 14, 1:25 pm, davidjensen  wrote:
>
> > I am running 1.79.2 on red hat enterprise linux with python 2.5 on a
> > hosting service with static ip and using port 8080. I have openssl.
>
> > I am getting the error message
>
> > use "kill -SIGTERM 2457" to shutdown the web2py server
> > Traceback (most recent call last):
> >   File "web2py.py", line 20, in 
> >     gluon.widget.start(cron=True)
> >   File "/var/www/html/web2py/gluon/widget.py", line 863, in start
> >     path=options.folder)
> >   File "/var/www/html/web2py/gluon/main.py", line 622, in __init__
> >     elif not rocket.ssl:
> > AttributeError: 'module' object has no attribute 'ssl'
>
> > python 2.5 has no ssl module and rocket does try to import ssl with an
> > exception handler. Also, main.py repeats code around where the
> > rocket.ssl is.
>
> > I would like to get this going, but I am also reporting what appears
> > to be  errors.


[web2py] Re: Unpredictable sqlite3.dll version being loaded by web2py.exe

2010-06-15 Thread Salvor Hardin
On Jun 15, 10:31 pm, Yarko Tymciurak 
wrote:
> On Jun 15, 10:26 pm, Salvor Hardin  wrote:
>
> > I got an unexpected result.
>
> > C:\Python25\python.exe loads C:\Python25\Dlls\sqlite3.dll when I issue
> > "import sqlite3"
>
> > And, C:\web2py\web2py.exe loads C:\Windows\system32\sqlite3.dll
> > immediately (before pressing Start Server button.)
>
> If that is the case, then the dynamic load order may be an artifact of
> whoever ran py2exe to generate the web2py.exe (in other words, _their_
> system is the problem, and it propogated to you).
>
> But the good news - if you're python pulls in the correct sqlite ---
> is you will be all set if you just use the source version of web2py.
>
> In the meantime, we can let Massimo sort through / ask more questions
> as he needs to fix web2py.exe generation.
>
> - Yarko
>

On Windows XP SP1 and newer, web2py.exe can call SetDllDirectory(path)
-- but it requires defining _WIN32_WINNT as 0x0502.  It'll make web2py
apps more reliable/predictable on Windows but users still running
Windows 2000 will need to run from source version.

"After calling SetDllDirectory, the DLL search path is:

1. The directory from which the application loaded.
2. The directory specified by the lpPathName parameter.
3. The system directory. [e.g. often C:\Windows\System32]
4. The 16-bit system directory. [e.g. often C:\Windows\System]
5. The Windows directory. Use the GetWindowsDirectory function to get
the path of this directory.
6. The directories that are listed in the PATH environment variable.

To revert to the default search path used by LoadLibrary and
LoadLibraryEx, call SetDllDirectory with NULL. This also restores safe
DLL search mode based on the SafeDllSearchMode registry value.

To compile an application that uses this function, define _WIN32_WINNT
as 0x0502 or later."

Source: http://msdn.microsoft.com/en-us/library/ms686203(v=VS.85).aspx


[web2py] Re: code broke, help

2010-06-15 Thread mdipierro
This should never have worked.

On Jun 15, 8:57 pm, "mr.freeze"  wrote:
> I would just check that fromvar and tovar are not None before getting
> the rows.
>
> On Jun 15, 8:40 pm, greenpoise  wrote:
>
> > here it is:
>
> > Error traceback
>
> > 1.
> > 2.
> > 3.
> > 4.
> > 5.
> > 6.
> > 7.
> > 8.
> > 9.
> > 10.
> > 11.
> > 12.
> > 13.
> > 14.
> > 15.
> > 16.
>
> > Traceback (most recent call last):
> >   File "/home/danel/Applications/web2py/gluon/restricted.py", line
> > 178, in restricted
> >     exec ccode in environment
> >   File "/home/danel/Applications/web2py/applications/shroomV2/
> > controllers/default.py", line 314, in 
> >   File "/home/danel/Applications/web2py/gluon/globals.py", line 96, in
> > 
> >     self._caller = lambda f: f()
> >   File "/home/danel/Applications/web2py/gluon/tools.py", line 2036, in
> > f
> >     return action(*a, **b)
> >   File "/home/danel/Applications/web2py/applications/shroomV2/
> > controllers/default.py", line 245, in qryfecha
> >     rows = db((db.orden.fechaorden >= fromvar)&(db.orden.fechaorden <=
> > tovar)).select(db.orden.waitertip.sum())
> >   File "/home/danel/Applications/web2py/gluon/sql.py", line 2483, in
> > __ge__
> >     return Query(self, '>=', value)
> >   File "/home/danel/Applications/web2py/gluon/sql.py", line 2866, in
> > __init__
> >     raise SyntaxError, 'Operation %s can\'t be used with None' % op
> > SyntaxError: Operation >= can't be used with None
>
> > On Jun 15, 9:37 pm, "mr.freeze"  wrote:
>
> > > Do you get an error? If so, can you show the traceback?
>
> > > On Jun 15, 8:01 pm, greenpoise  wrote:
>
> > > > Ok this used to work:
>
> > > > def qryfecha():
>
> > > >     form=FORM (H1(TABLE
> > > > (TR(('From:',INPUT(_name="desde",_class='date',_id="desde",requires=IS_DATE
> > > >  ())),
>
> > > > ('To:',INPUT(_name="to",_class='date',_id="to",default=request.now,requires
> > > >  =IS_DATE(),
> > > > INPUT(_type='submit')))
>
> > > >     fromvar=request.vars.desde
> > > >     tovar=request.vars.to
>
> > > >     rows = db((db.orden.fechaorden >= fromvar)&(db.orden.fechaorden <=
> > > > tovar)).select(db.orden.waitertip.sum())
> > > >     for row in rows: print
> > > >     row[db.orden.waitertip.sum()]
>
> > > >     return dict(form=form,rows=rows)
>
> > > > not anymore. Leads?


[web2py] Re: Looking for web2py AJAX "recipes"

2010-06-15 Thread mdipierro
Not sure if that helps you but there is an ajax chapter in http:/
web2py.com/book

On Jun 15, 4:48 pm, David Mitchell  wrote:
> Hello all,
>
> I've got a bunch of AJAX pages to create, with tasks like:
> - pick a selection from a drop-down list
> - based on that selection, populate another drop-down list
>
> - start typing in a text field
> - with each character typed, do a search in a DB table for fields matching
> the string typed and display options for selection
>
> (not quite AJAX, but close)
> - enter a date in a date field
> - constrain other date fields on the same form so that they must be either
> before or after the first-entered date
>
> - allow someone to enter a long random string into a field, or press a
> "Generate random string" button to have the string populated with suitable
> random characters
>
> Is there anything like an "AJAX recipes" page for web2py out there?
>  Googling didn't come up with anything useful, but I thought some of these
> are pretty common tasks and someone may have gathered code samples together
> to demonstrate how it is done in web2py.
>
> Thanks and regards
>
> Dave M.


[web2py] Re: Defining db.py for the first time problem (db references possible?)

2010-06-15 Thread mdipierro
Because I think if you have a table1 that reference a table2 and a
table2 that reference table1 something is wrong. I am not even sure
all the database backends support that. think about it, you cannot
insert a record in table1 without the record in table2 to reference
and vice versa. The proper way to handle this is to have a table that
links table1 and table2.

Anyway you can still do things like

db.define_table('person',
  Field('username', 'string'),
  Field('image', 'integer'),   #  a forward reference to db.image
)

db.define_table('image',
  Field('image', 'upload'),
  Field('owner', db.person))

db.person.image.requires=IS_EMPTY_OR(IS_IN_DB(db,'image.id'))
db.person.image.represent=lambda id:
A('link',_href=URL(r=request,f='download',args=db.image[id].image))

On Jun 15, 10:24 pm, Yarko Tymciurak 
wrote:
> On Jun 15, 1:56 pm, zsouthboy  wrote:
>
> > Hi Yarko,
>
> > Thanks for the help!
> > I had initially tried doing what the introductory docs show (which is
> > marking a reference like ("image", db.image) for a column), which
> > fails because there is no member 'image' of db yet.
> > Then I consulted the technical docs and saw that instead "reference
> > image" should be used instead, so tried that, thinking that it would
> > be used as a placeholder (and filled in correctly later).
> > When that failed, I posted here.
>
> > The DAL doesn't recurse to allow this situation? Does anyone know
> > why / why not? When I get a chance I'll look at gluon and see how
> > trivial it would be to do, even in a hacky way.
>
> ... consider dropping this from your vocabulary: " even in a hacky
> way...";
>
>
>
> > I do have a separate issue now: following what you've suggested, I now
> > get complaints from gluon that referenced tables have duplicate field
> > names as the table being defined - did I miss something obvious? That
> > seems like there should be no issue doing so. (you can get this error
>
> Yes, it seems so:   in gluon/(dal|sql).py, in
> Table._create_references(), there's:
>
>     if self._tablename in referee.fields:
>
> with no comments - so beyond the shallow, immediate reading for that
> line, we have no clue
> as to the motivation / reasoning for this particular constraint
> (reverse engineering every little thing
> just to try to get what intended...  besides being no better than
> guessing, mind-reading,
> also gets tedious).    If you simply rename db.person.image to
> something w/o the 'image' (tablename),
> e.g.  db.person.image_id  --- this goes away.
>
> As to forward references:
> I commented out the lines in Table._create_references()  (and the
> exception it raises), and __get__ errors come, so there is at least
> that simple get/set work to do to get forward references; not sure if
> there would be anything else.   Commented code _sure would be nice_!
>
> - Yarko
>
> > by simply copying and pasting the suggested fix you responded to me
> > with into a test db.py, even). Duplicate field names, but they're in
> > separate tables, so why the error?
>
> > Traceback (most recent call last):
> >   File "gluon/restricted.py", line 178, in restricted
> >     exec ccode in environment
> >   File "/var/www/web2py/applications/golb/models/db.py", line 93, in
> > 
> >     Field('published', 'boolean'))
> >   File "gluon/sql.py", line 1304, in define_table
> >     t._create_references()
> >   File "gluon/sql.py", line 1579, in _create_references
> >     raise SyntaxError, 'Field: table %s has same name as a field in
> > referenced table %s' % (self._tablename, referee._tablename)
> > SyntaxError: Field: table image has same name as a field in referenced
> > table person


[web2py] Re: Unpredictable sqlite3.dll version being loaded by web2py.exe

2010-06-15 Thread mdipierro
I guess this may be an issue in the order in sys.path. Will look into
this next week as I return from this conference.

On Jun 15, 6:29 pm, Salvor Hardin  wrote:
> It would be great if web2py.exe loads sqlite3.dll from the same
> directory as web2py.exe.
>
> Unfortunately, web2py loads C:\Windows\System32\sqlite3.dll which is
> the most unpredictable version of sqlite3.dll on Windows.
>
> I didn't realize this until I tried replacing C:\web2py\sqlite3.dll
> with an encryption-enabled version.  I confirmed using Process
> Explorer to see which sqlite3.dll was loaded by web2py.exe.
>
> I have 3 different sqlite3.dll, and this is the ideal load order:
>
> 1.  C:\Web2py\sqlite3.dll -- bundled with web2py
> 2.  C:\Python25\DLLs\sqlite3.dll -- bundled with Python
> 3.  C:\Windows\System32\sqlite3.dll -- very old version installed by
> unknown software (unpredictable)


[web2py] Re: Trouble doing manual insert of upload file

2010-06-15 Thread weheh
Nice and simple. Thanks Massimo.

But FWIW, this doesn't rename the no_table.name.blahblah.txt file to
srcfile_table.name.blahblah.txt, which may or may not be the right
thing to do -- I'm not sure. Since I am uploading everything through
the factory form, all fields are no_table fields. Since I eventually
store them in their respective tables, it seems logical that they go
into the corresponding (correctly named) folder/filenames --
srcfile_table/ab/srcfile_table.name.blahblah.txt. What do you think?



On Jun 15, 11:46 pm, mdipierro  wrote:
> Actually this would work but it is not the best way, ... the problem
> is that the storage is already performed by accepts so you must do
> simply
>
> file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
>       db.srcfile.insert(name=form.vars.name)
>
> On Jun 15, 10:44 pm, mdipierro  wrote:
>
> > May be a bug. can you try?
>
> > file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
> >      request.vars.name.file.seek(0) ### add this line
> >      db.srcfile.insert(
> >         name=db.srcfile.name.store(
> >           request.vars.name.file,request.vars.name.filename),
> >         )
>
> > On Jun 15, 11:02 am, weheh  wrote:
>
> > > # model
> > > db.define_table('srcfile',
> > >   Field('name','upload',length=50,label=T('Upload
> > > file'),autodelete=True,
> > >     uploadseparate=True,
> > >     requires=(
> > >       IS_UPLOAD_FILENAME(extension='pdf|txt|doc|htm|html|xml|ppt'),
> > >       IS_LENGTH(500,10))
> > >     ),
> > >   )
>
> > > # controller
> > > ...
> > > file_form=SQLFORM.factory(db.auth_user,db.othertable,db.srcfile)
> > > ...
> > > if
> > > file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
> > >      db.srcfile.insert(
> > >         name=db.srcfile.name.store(
> > >           request.vars.name.file,request.vars.name.filename),
> > >         )
> > > ...
>
> > > Problem is, file gets uploaded into
> > >   no_table.name/a2/
> > > no_table.name.a24060930d31d0c1.313234363931322e747874.txt
> > > prior to the insert. After the insert, there is a folder
> > >   srcfile.name/b1/srcfile.name.b192a5e35dc5081e.
> > > 313234363931322e747874.txt
> > > except that the file is empty.
>
> > > Question: is this a bug, or do I need to explicitly copy from the
> > > source to the destination? If the latter, what would the rationale be
> > > for creating the destination file without copying the contents from
> > > the source?


[web2py] Re: Trouble doing manual insert of upload file

2010-06-15 Thread weheh
Yes -- this works, too, but perhaps it's a little "ugly". I prefer the
other method (but see previous post).

On Jun 15, 11:44 pm, mdipierro  wrote:
> May be a bug. can you try?
>
> file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
>      request.vars.name.file.seek(0) ### add this line
>      db.srcfile.insert(
>         name=db.srcfile.name.store(
>           request.vars.name.file,request.vars.name.filename),
>         )
>
> On Jun 15, 11:02 am, weheh  wrote:
>
> > # model
> > db.define_table('srcfile',
> >   Field('name','upload',length=50,label=T('Upload
> > file'),autodelete=True,
> >     uploadseparate=True,
> >     requires=(
> >       IS_UPLOAD_FILENAME(extension='pdf|txt|doc|htm|html|xml|ppt'),
> >       IS_LENGTH(500,10))
> >     ),
> >   )
>
> > # controller
> > ...
> > file_form=SQLFORM.factory(db.auth_user,db.othertable,db.srcfile)
> > ...
> > if
> > file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
> >      db.srcfile.insert(
> >         name=db.srcfile.name.store(
> >           request.vars.name.file,request.vars.name.filename),
> >         )
> > ...
>
> > Problem is, file gets uploaded into
> >   no_table.name/a2/
> > no_table.name.a24060930d31d0c1.313234363931322e747874.txt
> > prior to the insert. After the insert, there is a folder
> >   srcfile.name/b1/srcfile.name.b192a5e35dc5081e.
> > 313234363931322e747874.txt
> > except that the file is empty.
>
> > Question: is this a bug, or do I need to explicitly copy from the
> > source to the destination? If the latter, what would the rationale be
> > for creating the destination file without copying the contents from
> > the source?


[web2py] Re: Trouble doing manual insert of upload file

2010-06-15 Thread mdipierro
aha, you can do this

file_form=SQLFORM.factory(,table_name='srcfile')
file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
  db.srcfile.insert(name=form.vars.name)

On Jun 16, 12:34 am, weheh  wrote:
> Nice and simple. Thanks Massimo.
>
> But FWIW, this doesn't rename the no_table.name.blahblah.txt file to
> srcfile_table.name.blahblah.txt, which may or may not be the right
> thing to do -- I'm not sure. Since I am uploading everything through
> the factory form, all fields are no_table fields. Since I eventually
> store them in their respective tables, it seems logical that they go
> into the corresponding (correctly named) folder/filenames --
> srcfile_table/ab/srcfile_table.name.blahblah.txt. What do you think?
>
> On Jun 15, 11:46 pm, mdipierro  wrote:
>
> > Actually this would work but it is not the best way, ... the problem
> > is that the storage is already performed by accepts so you must do
> > simply
>
> > file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
> >       db.srcfile.insert(name=form.vars.name)
>
> > On Jun 15, 10:44 pm, mdipierro  wrote:
>
> > > May be a bug. can you try?
>
> > > file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
> > >      request.vars.name.file.seek(0) ### add this line
> > >      db.srcfile.insert(
> > >         name=db.srcfile.name.store(
> > >           request.vars.name.file,request.vars.name.filename),
> > >         )
>
> > > On Jun 15, 11:02 am, weheh  wrote:
>
> > > > # model
> > > > db.define_table('srcfile',
> > > >   Field('name','upload',length=50,label=T('Upload
> > > > file'),autodelete=True,
> > > >     uploadseparate=True,
> > > >     requires=(
> > > >       IS_UPLOAD_FILENAME(extension='pdf|txt|doc|htm|html|xml|ppt'),
> > > >       IS_LENGTH(500,10))
> > > >     ),
> > > >   )
>
> > > > # controller
> > > > ...
> > > > file_form=SQLFORM.factory(db.auth_user,db.othertable,db.srcfile)
> > > > ...
> > > > if
> > > > file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
> > > >      db.srcfile.insert(
> > > >         name=db.srcfile.name.store(
> > > >           request.vars.name.file,request.vars.name.filename),
> > > >         )
> > > > ...
>
> > > > Problem is, file gets uploaded into
> > > >   no_table.name/a2/
> > > > no_table.name.a24060930d31d0c1.313234363931322e747874.txt
> > > > prior to the insert. After the insert, there is a folder
> > > >   srcfile.name/b1/srcfile.name.b192a5e35dc5081e.
> > > > 313234363931322e747874.txt
> > > > except that the file is empty.
>
> > > > Question: is this a bug, or do I need to explicitly copy from the
> > > > source to the destination? If the latter, what would the rationale be
> > > > for creating the destination file without copying the contents from
> > > > the source?


[web2py] Re: Trouble doing manual insert of upload file

2010-06-15 Thread weheh
I don't think this will work since my factory is using multiple
tables.

I don't mean to digress, but another question is, how to open the file
during the onvalidation? I need to open the file and read it in to
check the contents for stuff that will determine whether it's valid or
not. I've tried:

text=URL(r=request,c='default',f='download',args=form.vars.name)

I've also tried

text=open(os.path.join(request.folder,'uploads',form.vars.name),'rb').read()

and other variations, but so far, can't seem to get it to work.

On Jun 16, 2:17 am, mdipierro  wrote:
> aha, you can do this
>
> file_form=SQLFORM.factory(,table_name='srcfile')
> file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
>       db.srcfile.insert(name=form.vars.name)
>
> On Jun 16, 12:34 am, weheh  wrote:
>
> > Nice and simple. Thanks Massimo.
>
> > But FWIW, this doesn't rename the no_table.name.blahblah.txt file to
> > srcfile_table.name.blahblah.txt, which may or may not be the right
> > thing to do -- I'm not sure. Since I am uploading everything through
> > the factory form, all fields are no_table fields. Since I eventually
> > store them in their respective tables, it seems logical that they go
> > into the corresponding (correctly named) folder/filenames --
> > srcfile_table/ab/srcfile_table.name.blahblah.txt. What do you think?
>
> > On Jun 15, 11:46 pm, mdipierro  wrote:
>
> > > Actually this would work but it is not the best way, ... the problem
> > > is that the storage is already performed by accepts so you must do
> > > simply
>
> > > file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
> > >       db.srcfile.insert(name=form.vars.name)
>
> > > On Jun 15, 10:44 pm, mdipierro  wrote:
>
> > > > May be a bug. can you try?
>
> > > > file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
> > > >      request.vars.name.file.seek(0) ### add this line
> > > >      db.srcfile.insert(
> > > >         name=db.srcfile.name.store(
> > > >           request.vars.name.file,request.vars.name.filename),
> > > >         )
>
> > > > On Jun 15, 11:02 am, weheh  wrote:
>
> > > > > # model
> > > > > db.define_table('srcfile',
> > > > >   Field('name','upload',length=50,label=T('Upload
> > > > > file'),autodelete=True,
> > > > >     uploadseparate=True,
> > > > >     requires=(
> > > > >       IS_UPLOAD_FILENAME(extension='pdf|txt|doc|htm|html|xml|ppt'),
> > > > >       IS_LENGTH(500,10))
> > > > >     ),
> > > > >   )
>
> > > > > # controller
> > > > > ...
> > > > > file_form=SQLFORM.factory(db.auth_user,db.othertable,db.srcfile)
> > > > > ...
> > > > > if
> > > > > file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
> > > > >      db.srcfile.insert(
> > > > >         name=db.srcfile.name.store(
> > > > >           request.vars.name.file,request.vars.name.filename),
> > > > >         )
> > > > > ...
>
> > > > > Problem is, file gets uploaded into
> > > > >   no_table.name/a2/
> > > > > no_table.name.a24060930d31d0c1.313234363931322e747874.txt
> > > > > prior to the insert. After the insert, there is a folder
> > > > >   srcfile.name/b1/srcfile.name.b192a5e35dc5081e.
> > > > > 313234363931322e747874.txt
> > > > > except that the file is empty.
>
> > > > > Question: is this a bug, or do I need to explicitly copy from the
> > > > > source to the destination? If the latter, what would the rationale be
> > > > > for creating the destination file without copying the contents from
> > > > > the source?


[web2py] Re: where are the auth table model?

2010-06-15 Thread annet
Hi Richard,

> I don't know whether the problems you're having might stem from not
> following this structure.

I am pretty sure I got the structure right, Massimo helped me sort
that out.

auth.settings.table_user = db.define_table('auth_user',
Field('first_name',length=24,default=''),
Field('last_name',length=42,default=''),
 
Field('bedrijf_id',db.bedrijf,default='',notnull=True,ondelete='CASCADE',writable=False,
readable=False),
Field(...),
Field('reset_password_key',length=512,default='',writable=False,
readable=False))

db.auth_user.first_name.requires=...

auth.define_tables()


When I moved my PostgreSQL database from development to production, I
did not have authentication and authorization enabled. After
developing a CSM app on the database, I had to run auth.define_tables
in the production environment to add the auth_ tables to the
production database. This could only be done with an empty databases
folder in the CMS app. Now every time I update/upgrade the cms
application I empty the databases folder, to prevent the .table files
from being overwritten.

The auth_... already exists problem also occurred when I extended my
database with a new table, to prevent this from happening I put all my
table definition in a separate db_xx.py file.

I am very much aware that these are layman solutions, and I am very
much looking forward to the day I come up with am more professional
solution.


Kind regards,

Annet.


[web2py] Re: Trouble doing manual insert of upload file

2010-06-15 Thread mdipierro
Try this:

file_form=SQLFORM.factory(db.auth_user,db.othertable,db.srcfile)
...
if FORM.accepts(file_form,request.vars,formname='file_form'): # no
upload

 check_file_in(file_form) # same as onvalidation

 if not file_form.errors:
db.srcfile.insert(
   name=db.srcfile.name.store(
 request.vars.name.file,request.vars.name.filename),
)

On Jun 16, 1:29 am, weheh  wrote:
> I don't think this will work since my factory is using multiple
> tables.
>
> I don't mean to digress, but another question is, how to open the file
> during the onvalidation? I need to open the file and read it in to
> check the contents for stuff that will determine whether it's valid or
> not. I've tried:
>
> text=URL(r=request,c='default',f='download',args=form.vars.name)
>
> I've also tried
>
> text=open(os.path.join(request.folder,'uploads',form.vars.name),'rb').read()
>
> and other variations, but so far, can't seem to get it to work.
>
> On Jun 16, 2:17 am, mdipierro  wrote:
>
> > aha, you can do this
>
> > file_form=SQLFORM.factory(,table_name='srcfile')
> > file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
> >       db.srcfile.insert(name=form.vars.name)
>
> > On Jun 16, 12:34 am, weheh  wrote:
>
> > > Nice and simple. Thanks Massimo.
>
> > > But FWIW, this doesn't rename the no_table.name.blahblah.txt file to
> > > srcfile_table.name.blahblah.txt, which may or may not be the right
> > > thing to do -- I'm not sure. Since I am uploading everything through
> > > the factory form, all fields are no_table fields. Since I eventually
> > > store them in their respective tables, it seems logical that they go
> > > into the corresponding (correctly named) folder/filenames --
> > > srcfile_table/ab/srcfile_table.name.blahblah.txt. What do you think?
>
> > > On Jun 15, 11:46 pm, mdipierro  wrote:
>
> > > > Actually this would work but it is not the best way, ... the problem
> > > > is that the storage is already performed by accepts so you must do
> > > > simply
>
> > > > file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
> > > >       db.srcfile.insert(name=form.vars.name)
>
> > > > On Jun 15, 10:44 pm, mdipierro  wrote:
>
> > > > > May be a bug. can you try?
>
> > > > > file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
> > > > >      request.vars.name.file.seek(0) ### add this line
> > > > >      db.srcfile.insert(
> > > > >         name=db.srcfile.name.store(
> > > > >           request.vars.name.file,request.vars.name.filename),
> > > > >         )
>
> > > > > On Jun 15, 11:02 am, weheh  wrote:
>
> > > > > > # model
> > > > > > db.define_table('srcfile',
> > > > > >   Field('name','upload',length=50,label=T('Upload
> > > > > > file'),autodelete=True,
> > > > > >     uploadseparate=True,
> > > > > >     requires=(
> > > > > >       IS_UPLOAD_FILENAME(extension='pdf|txt|doc|htm|html|xml|ppt'),
> > > > > >       IS_LENGTH(500,10))
> > > > > >     ),
> > > > > >   )
>
> > > > > > # controller
> > > > > > ...
> > > > > > file_form=SQLFORM.factory(db.auth_user,db.othertable,db.srcfile)
> > > > > > ...
> > > > > > if
> > > > > > file_form.accepts(request.vars,formname='file_form',onvalidation=check_file_in):
> > > > > >      db.srcfile.insert(
> > > > > >         name=db.srcfile.name.store(
> > > > > >           request.vars.name.file,request.vars.name.filename),
> > > > > >         )
> > > > > > ...
>
> > > > > > Problem is, file gets uploaded into
> > > > > >   no_table.name/a2/
> > > > > > no_table.name.a24060930d31d0c1.313234363931322e747874.txt
> > > > > > prior to the insert. After the insert, there is a folder
> > > > > >   srcfile.name/b1/srcfile.name.b192a5e35dc5081e.
> > > > > > 313234363931322e747874.txt
> > > > > > except that the file is empty.
>
> > > > > > Question: is this a bug, or do I need to explicitly copy from the
> > > > > > source to the destination? If the latter, what would the rationale 
> > > > > > be
> > > > > > for creating the destination file without copying the contents from
> > > > > > the source?