[web2py] using generateDS & web2py application wizard for making web applications from xsd files

2013-03-18 Thread Bill Thayer
Over the weekend I was working on and exploring the possibility of using 
generateDS.py  to create 
python objects for an xsd file and modifyiing its included django script to 
instead create the web2py.metadata file that comes with the appadmin 
application wizard. Anybody have thoughts or experience?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: RuntimeError: Unable to handle upload

2013-02-05 Thread Bill Thayer
Hi Alan. Seeing your code must have helped because I did get it to run. 

The following shows a demo script with functions to upload a file and 
download a file utilizing a table containing a blob field. It worked twice 
on a pdf for me. Note that I had to change the filename type from 'upload' 
to 'string' in order to bypass an error message in the 
dal._attempt_upload(fields).

# -*- coding: cp1252 -*-
import os, sys
from gluon import DAL, Field, fileutils
from easygui import fileopenbox, diropenbox

db = DAL('oracle://...',
 auto_import=True)  ## Still playing with this one to try and avoid 
re-defining table?

db.define_table('wiki_media',
Field('filename', 'upload', uploadfield='filedata'),
Field('title', 'string'),
Field('filedata', 'blob'),
migrate=False, fake_migrate=True)

def upload_file():
"""demonstrate uploading a file to database programatically,
"""
stream=None
file_path=fileopenbox(msg='Pick a file', title='Picking files', 
default=None)
if file_path:
print 'file_path= ' + file_path
stream = open(file_path, 'rb')
else:
print 'file_path undefined'
return None

path,filename = os.path.split(file_path)
#workaround to possible suprise bug in web2py?
db.wiki_media.filename.type='string'

file_id=db.wiki_media.insert(filename=db.wiki_media.filename.store(stream, 
filename=filename, path=path), filedata=stream.read())
db.commit()
stream.close()
if file_id:
print 'file_id=' + str(file_id)
return file_id


def download_file(file_id, table='wiki_media'):
""" In this demo will download the file with the given file_id from the
given table. Table must have a filename field of type upload and a
filedata field of type blob
"""
table = db[table]
if file_id:
print 'file_id=' + str(file_id)
else:
print 'file_id is empty'
return None

directory=diropenbox(title='Select destination directory')

record = table(table.id==file_id)
(filename, stream) = table.filename.retrieve(record.filename)
pathname = os.path.join(directory,filename)

import shutil   #In fileutils.py the developer mentioned he 
suspects a bug in shutil.copyfileobj
#but I didn't know how to get the length of a 
cStringIO object to 
#use fileutils.copystream()

shutil.copyfileobj(stream,open(pathname,'wb'))

stream.close()

return


Hope it helps someone.

-Bill



-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: RuntimeError: Unable to handle upload

2013-02-02 Thread Bill Thayer
Yes. That is what I meant.

On Saturday, February 2, 2013 1:49:55 PM UTC-6, Alan Etkin wrote:
>
> Your code also threw the same error so before I un-commented the if 
>> statements in dal.py I added some print statements
>>
>
> Did you try the store command as I posted it (passing pathname and 
> filename) without changing dal.py? What is the error output?
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: RuntimeError: Unable to handle upload

2013-02-02 Thread Bill Thayer
So I just replaced the first if statement with 'if True:' so that the code 
would execute. Looks like a unicode object does not have an attribute 
'file' 

(InteractiveConsole)
>>> import test_tamoto_rpc as trpc
>>> trpc.upload_file()
C:\Users\bthayer\Documents\car\carfiles.txt
wiki_media.id
wiki_media.filedata
wiki_media.cell_id
wiki_media.lib_id
wiki_media.layout_id
wiki_media.wiki_page
wiki_media.title
wiki_media.meas_id
wiki_media.filename
filename
wiki_media.filename.a8857e792725cc9c.63617266696c65732e747874.txt
Traceback (most recent call last):
  File "", line 1, in 
  File 
"C:\web2py-1045bab06391\web2py-1045bab06391\applications\TAMOTO\private\test_tamoto_rpc.py",
 
line 38, in upload_file
filedata=stream.read())
  File "C:\web2py-1045bab06391\web2py-1045bab06391\gluon\dal.py", line 
8281, in insert
self._attempt_upload(fields)
  File "C:\web2py-1045bab06391\web2py-1045bab06391\gluon\dal.py", line 
8258, in _attempt_upload
new_name = field.store(value.file,filename=value.filename)
AttributeError: 'unicode' object has no attribute 'file'
>>>








-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: RuntimeError: Unable to handle upload

2013-02-02 Thread Bill Thayer
Hi Alan,

Just now getting back to this days later...

Your code also threw the same error so before I un-commented the if 
statements in dal.py I added some print statements and can see the list of 
fields, then the name of the filename field as 'filename' followed by 
wiki_media.filename.9b724ad17775d60e.63617266696c65732e747874.txt

as the value being tested for a 'file' attribute and a 'filename' attribute 
before calling the store function...(again?) This is confusing so I guess 
I'll do as you suggest and take out those lines of code.


>>> import test_tamoto_rpc as trpc
>>> trpc.upload_file()
C:\Users\bthayer\Documents\car\carfiles.txt
wiki_media.id
wiki_media.filedata
wiki_media.cell_id
wiki_media.lib_id
wiki_media.layout_id
wiki_media.wiki_page
wiki_media.title
wiki_media.meas_id
wiki_media.filename
filename
wiki_media.filename.9b724ad17775d60e.63617266696c65732e747874.txt
Traceback (most recent call last):
  File "", line 1, in 
  File 
"C:\web2py-1045bab06391\web2py-1045bab06391\applications\TAMOTO\private\test_tamoto_rpc.py",
 
line 38, in upload_file
filedata=stream.read())
  File "C:\web2py-1045bab06391\web2py-1045bab06391\gluon\dal.py", line 
8280, in insert
self._attempt_upload(fields)
  File "C:\web2py-1045bab06391\web2py-1045bab06391\gluon\dal.py", line 
8262, in _attempt_upload
raise RuntimeError("Unable to handle upload")
RuntimeError: Unable to handle upload
>>>




On Tuesday, January 29, 2013 8:00:58 PM UTC-6, Alan Etkin wrote:
>
> Replacing the store call with this should avoid the error:
>
> file_id=db.wiki_media.insert(filename=db.wiki_media.filename.store(stream,filename
> =, path=file_path)
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: RuntimeError: Unable to handle upload

2013-01-29 Thread Bill Thayer

Hi Allen,

Yes the book has the example as written because I am uploading directly to 
the database. Otherwise I get an error that store requires a value for 
uploadfolder.

Sorry but I've been looking for how t temporarily not let the dal catch the 
error. I tried running my app with the -S option but it's the same result.


Regards,
Bill





On Tuesday, January 29, 2013 5:20:08 AM UTC-6, Alan Etkin wrote:
>
> I am attempting to write a function that will eventually go in to a 
>> migration script to upload legacy data files. As you can see I 
>
>
> "Unable to handle load" is too generic for this case. I'd better 
> temporarily let dal not to catch the error so there's a more precise 
> description of it. Perhaps there are encoding errors when writing the 
> stream output?. BTW, Is that the recommended way of adding upload fields 
> data programatically (calling the .store method)?
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: web2py world conference 2013

2013-01-29 Thread Bill Thayer
I'll mention it on my Dallas Python mailing list too. Don't know how many 
web2py users we have in Texas though.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: How do I import `gluon.dal` from Python shell?

2013-01-28 Thread Bill Thayer
I defined WEB2PY_HOME in my environment variables and then added 
%WEB2PY_HOME% to my path system variable. This way I can change it's value 
depending on the version I am developing on at the time.

-Bill

On Monday, January 28, 2013 9:49:12 AM UTC-6, Alec Taylor wrote:
>
> On Tue, Jan 29, 2013 at 12:07 AM, Bruno Rocha 
> > 
> wrote: 
> > 
> > Is there the option to put the "gluon" folder on your site-packages or 
> > "dist-packages" folder 
> > 
> > Or maybe, start web2py in shell mode? 
> > 
> > -- 
> > 
> > 
> > 
>
> Perfect, thanks. 
>
> Had forgotten about the shell option. 
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] RuntimeError: Unable to handle upload

2013-01-28 Thread Bill Thayer
I am attempting to write a function that will eventually go in to a 
migration script to upload legacy data files. As you can see I use the DAL 
and define the wiki_media table. The function below looks just like the 
example in the 
book.However
 
when I run it from the command line I get an error that the 
_attempt_upload(fields) method cannot handle the upload. See below.

Doe anyone know of a way to insert files into the database with a script? I 
am using an upload field instead of upload directory. Also using a recent 
trunk version of web2py.

import os, sys
from gluon import DAL, Field
from easygui import fileopenbox, diropenbox

db = DAL('oracle://...',
 auto_import=True)
db.define_table('wiki_media',
Field('wiki_page', 'reference wiki_page'),
Field('title', required=True),
Field('filename', 'upload', required=True),
Field("filedata", "blob"),
migrate=False)

db.wiki_media.filename.uploadfield='filedata'

file_id = None
def upload_file():
"""demonstrate uploading a file programmatically,
"""
stream=None
file_path=fileopenbox(msg='Pick a file', title='Choose file', 
default=None)
if file_path:
print 'file_path= '.join([file_path])
stream = open(file_path, 'rb')
else: return None

file_id=db.wiki_media.insert(filename=db.wiki_media.filename.store(stream,file_path),
   filedata=stream.read())
stream.close()
return file_id

Error:
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\bthayer>cd %WEB2PY_HOME%

C:\web2py-1045bab06391\web2py-1045bab06391>cd appl*/TAMOTO

C:\web2py-1045bab06391\web2py-1045bab06391\applications\TAMOTO>cd private

C:\web2py-1045bab06391\web2py-1045bab06391\applications\TAMOTO\private>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] 
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import test_tamoto_rpc as trpc
>>> trpc.upload_file()
C:\Users\bthayer\Documents\car\carfiles.txt
Traceback (most recent call last):
  File "", line 1, in 
  File "test_tamoto_rpc.py", line 33, in upload_file
filedata=stream.read())
  File "C:\web2py-1045bab06391\web2py-1045bab06391\gluon\dal.py", line 
8276, in insert
self._attempt_upload(fields)
  File "C:\web2py-1045bab06391\web2py-1045bab06391\gluon\dal.py", line 
8258, in _attempt_upload
raise RuntimeError("Unable to handle upload")
RuntimeError: Unable to handle upload
>>>

Thanks for your time.
-Bill

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] 'NoneType' object has no attribute 'split'

2013-01-28 Thread Bill Thayer
I think I figured this one out so I am posting the solution. 

On the manages wiki_pages page from the manage pages memu item, I would 
click on a media button and get the error below.

Turns out that in the course of testing my application I had uploaded files 
without a title and web2py does not like media files without a title. Had 
to go in to appadmin and delete the media files without a title and it 
seems to be working now.

The confusing thing is that the error message was wanting to split the 
title at '.' which you might expect for a filename but why a title?

Using
web2py™(2, 4, 1, 'alpha.2', datetime.datetime(2013, 1, 25, 15, 35, 52))
PythonPython 2.7.3: C:\Python27\python.exe (prefix: C:\Python27)


Traceback

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

Traceback (most recent call last):
  File "C:\web2py-1045bab06391\web2py-1045bab06391\gluon\restricted.py", line 
212, in restricted
exec ccode in environment
  File 
"C:/web2py-1045bab06391/web2py-1045bab06391/applications/TAMOTO/controllers/default.py"
 , line 
147, in 
  File "C:\web2py-1045bab06391\web2py-1045bab06391\gluon\globals.py", line 193, 
in 
self._caller = lambda f: f()
  File 
"C:/web2py-1045bab06391/web2py-1045bab06391/applications/TAMOTO/controllers/default.py"
 , line 
10, in index
return auth.wiki()
  File "C:\web2py-1045bab06391\web2py-1045bab06391\gluon\tools.py", line 3344, 
in wiki
wiki = self._wiki()
  File "C:\web2py-1045bab06391\web2py-1045bab06391\gluon\tools.py", line 5047, 
in __call__
return self.editmedia(request.args(1) or 'index')
  File "C:\web2py-1045bab06391\web2py-1045bab06391\gluon\tools.py", line 5222, 
in editmedia
user_signature=False)
  File "C:\web2py-1045bab06391\web2py-1045bab06391\gluon\sqlhtml.py", line 
2286, in grid
value = field.represent(value, row)
  File "C:\web2py-1045bab06391\web2py-1045bab06391\gluon\tools.py", line 5199, 
in 
(id, IS_SLUG.urlify(row.title.split('.')[0]),
AttributeError: 'NoneType' object has no attribute 'split'




-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: ORA-01722: invalid number - Does field order matter?

2013-01-28 Thread Bill Thayer
Hi Massimo,

Is there a way that you know to get the SQL call so that I can verify the 
values are going to the correct place?

Regards,
Bill

On Monday, January 28, 2013 9:48:57 AM UTC-6, Massimo Di Pierro wrote:
>
> You are right that db.table.insert(**args) the order of the args in the 
> INSERT is not specified. This should not be a problem.
>
> If you want to a field to map to NUMBER instead of INT, you can make your 
> own adapter:
>
> from gluon import *
> from gluon.dal import ADAPTERS, OracleAdapter
> class MyOracleAdapter(OracleAdapter): pass
> MyOracleAdapter.types['integre'] = 'number'
> ADAPTERS['oracle'] = MyOracleAdapter
>
>
>
> On Sunday, 27 January 2013 21:22:38 UTC-6, Bill Thayer wrote:
>>
>> Hello,
>>
>> I am borrowing code from the CategoryPlugin 
>> slice<http://www.web2pyslices.com/slice/show/1354/hierarchical-category-tree>and
>>  ran into a unique Oracle error but I suspect that the insert command is 
>> not inserting by named fields. From my stack trace the argument below shows 
>> the columns in the cellview table in a different order than the fields 
>> array.
>>
>> table->id,name,description,left,right
>> fields->description,right,name,left
>> Function argument list
>>
>> (self=, table=> (id,name,description,left,right)>, fields=[(, 'Top 
>> Level'), (, 2), (, 
>> '3mi25gan-on-sic'), (, 1)])
>>
>>
>> I've combed through the OracleAdapter in the dal, changed the 'integer' 
>> mapping from 'INT' to 'NUMBER' because that's what my SQL developer keeps 
>> changing it to. 
>>
>> Anyone have a workaround?
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] ORA-01722: invalid number - Does field order matter?

2013-01-27 Thread Bill Thayer
Hello,

I am borrowing code from the CategoryPlugin 
sliceand
 ran into a unique Oracle error but I suspect that the insert command is 
not inserting by named fields. From my stack trace the argument below shows 
the columns in the cellview table in a different order than the fields 
array.

table->id,name,description,left,right
fields->description,right,name,left
Function argument list

(self=, table=, fields=[(, 'Top 
Level'), (, 2), (, 
'3mi25gan-on-sic'), (, 1)])


I've combed through the OracleAdapter in the dal, changed the 'integer' 
mapping from 'INT' to 'NUMBER' because that's what my SQL developer keeps 
changing it to. 

Anyone have a workaround?

-- 





[web2py] Re: Exposing validators as JSON?

2013-01-21 Thread Bill Thayer
Nice!

Looking for loads_json in serializers.py; Found custom_json instead that 
takes an object, checks it for a custom attribute and a callable. then 
returns the objects custom_json() method...[I call it a method but in 
Python I guess it's an attribute?]...Basically, before calling json() I 
need to decide if I want to override the .default() call or subclass 
JSONEncoder and set session.vars._default_encoder to my subclass.

I'll give the spreadsheet a try as well. So I can avoid the gluon xml code 
being displayed.

Thank you..

Reading the docs and taking notes left them here for searchable reference:
custom_json is a parameter to json() that calls json_parser.dumps...where 
json_parser is either json or simplejson imported
custom_json gets assigned to the defualt parameter in dumps
dumps is found in __init__.py (nice documnetation) and returns the 
JSONEncoder that calls dumps()
notes say; "   ``default(obj)`` is a function that should return a 
serializable version
of obj or raise TypeError. The default simply raises TypeError.






So dumps takes several arguments that are not available if you use the 








On Monday, January 21, 2013 5:20:33 AM UTC-6, Alan Etkin wrote:
>
> > For me, a 'json:reference attributes' field would basically be like a 
> "list: string" field but with only one string
> > holding a json object of a variable list of attributes with their value 
> and unit.
>
> Then you can do simply:
>
> db.define_table(... Field("a_list_of_json_objects", "json"))
>
> When you get the db record, it is represented as Python object for 
> server-side processing. If you stored a json object, then you get a Python 
> dict
>
> For explicit json export do .as_json()
>
> > So the enhancement would: use a select widget ...
>
> It seems to me that you could build a custom widget and assign it to the 
> json field.
>
> > have the ability to assign a grid object for viewing rows where the 
> column names match the fields in the referenced table
>
> Also consider using contrib.spreadsheet and the data argument (for editing 
> a db)
>
> BTW, if you need to do custom deserialize/serialize of json, you can do:
>
> from serializers import loads_json, json
>
>
>
>

-- 





[web2py] Re: Exposing validators as JSON?

2013-01-20 Thread Bill Thayer


On Sunday, January 20, 2013 11:52:59 PM UTC-6, Bill Thayer wrote:
>
> Borrowing code from SQLFORM.dictform I think I'm close to rendering nested 
> dicts dumped from json:
>
> The browser is simply writing a bunch of the 
>  received an error saying:
>  Generator expression must be parenthesized if not sole argument
>
> from contrib.simplejson import loads, dumps
> from types import *
> AUTOTYPES = {
> type(u''): ('unicode', None),   ##Added
> type(''): ('string', None),
> type(True): ('boolean', None),
> type(1): ('integer', IS_INT_IN_RANGE(-1e12, +1e12)),
> type(1.0): ('double', IS_FLOAT_IN_RANGE()),
> type([]): ('list:string', None),
> type({}): ('text', IS_JSON()), ##Added
> type(datetime.date.today()): ('date', IS_DATE()),
> type(datetime.datetime.today()): ('datetime', IS_DATETIME())
> }
> def makefields(dictionary):
> """ Code modified from SQLFORM.dictform to recursivley process nested 
> dicts """
> fields = []
> for key, value in sorted(dictionary.items()):
> #dbg.set_trace()
> t, requires = AUTOTYPES.get(type(value), (None, None))
> if t and isinstance(value,dict): ## added the type checking for 
> value to see if is a dict
> fields.append(SPAN('{}'.format(key))) ## Needed to identify 
> the nested dict
> fields.extend(makefields(value))  ## basic recursion
> elif t:
> fields.append(FIELDSET('{}'.format(key),
>INPUT(_name='{}'.format(key),
>  _type='{}'.format('text'), 
> #perhaps the AUTOTYPES should set t?
>  _value='{}'.format(value),
>  value='{}'.format(value),
>  requires=requires)))
> 
> return fields
>
> @auth.requires_login()
> def edit_parameters():
> """Display a form to edit the parameters rendered from a json object """
>
> table=db[request.args[0]]
> record=table(request.args[1])
> dictionary = record.parameters ## a json field type
>
> form = FORM('Edit Parameters', INPUT(_type='submit'), _action='', 
> _method='post')
> fields=makefields(dictionary)
> form.insert(1,fields)
> 
> dbg.set_trace()
> if form.validate(keepvalues=True):
> record.parameters.update(form.vars)
> table.update(record)
> 
> return form
>
>
>

-- 





[web2py] Re: Exposing validators as JSON?

2013-01-20 Thread Bill Thayer
Borrowing code from SQLFORM.dictform I think I'm close to rendering nested 
dicts dumped from json:

The browser is simply writing a bunch of the 


[web2py] Re: json validation

2013-01-20 Thread Bill Thayer
Thank you,

My revised function looks like this:
def json_parameters(param_names):
"""takes an array of parameter names which are attributes to a design 
cell
then looks up the default value and unit in the attributes table 
and returns an array of json dictionary objects to be inserted in the 
cell's
parameters field as a json object
if param_names = ["L", "len", "R", "INST", "model", "REF"]
{
"L": {
"value": "0.001",
"unit": "nH"
},
"len": {
"value": "1",
"unit": "??m"
},
"R": {
"value": "0.5",
"unit": "Ohm"
},
"INST": {
"value": "i",
"unit": "TEXT"
},
"model": {
"value": "m",
"unit": "TEXT"
},
"REF": {
"value": "r",
"unit": "TEXT"
}
}
}
"""

params={}
for a in param_names:
 #   dbg.set_trace()
rows = 
db(db.attribute.name.lower()==a.lower()).select(db.attribute.name,
  
db.attribute.default_value,
  
db.attribute.unit)
row = rows[0].as_dict()
param=dict(value=row['default_value'],unit=row['unit'])
named={row['name']:param}

params.update(named)
#
return json(params)



On Sunday, January 20, 2013 5:01:35 AM UTC-6, Alan Etkin wrote:
>
> CONTROLLER FUNCTION: (the myobj value is copied from my cell's edit page 
>> after being inserted into my Oracle DB.
>>
>
> The json field type does not validate insert/update for values stored 
> programatically, validation is performed when you send values with the json 
> widget. However, you could validate your input this way:
>
>
> >>> print IS_JSON()("No JSON")[1] is None
> False
> >>> print IS_JSON()('{"a": 1, "b": 2}')[1] is None
> True
>
>

-- 





[web2py] Re: Exposing validators as JSON?

2013-01-20 Thread Bill Thayer
Hi Alan,

Thank you for your work on the json data type. (Sorry for getting your name 
wrong in my other post). These discussions are great for thinking through 
my problem.

Yes I would need to post json data into the database and also search the 
data, display and edit it also. My app is just one tool in a design 
department storing design data for import/export to EDA sofware and test 
lab benches. An 'attributes' table holds different design parameters of 
designs and models. 

For me, a 'json:reference attributes' field would basically be like a 
"list: string" field but with only one string holding a json object of 
a variable list of attributes with their value and unit. The actual 
attributes table simply holds a list of available parameters (with default 
values, types, usage and unit) users can select from to build their 
parameter list. Kind of like a one to many relationship except there is no 
reference to other tables and the list can vary. Perhaps the word reference 
is not quite right then but I was reaching for some way 
to succinctly describe it.

So the enhancement would:
use a select widget for the referenced table used in 
creating/adding/removing "Rows" of values
have the ability to assign a grid object for viewing rows where the column 
names match the fields in the referenced table
perhaps a widget should instead behave like the web2py app wizard where 
another row of blank text fields can be added to edit your values 
-- a drop down would have to be used in place of a select widget with 
editable=referenced_table[field].writable and 
visible=referenced_table[field].readable
match json data types to widgets where multiple always = True.
with json stored as a string then searching should be easy.

This is only my vision so someone else may have a different view of a 
'json:reference my_other_table' usage. 

-Bill










On Sunday, January 20, 2013 12:54:00 PM UTC-6, Alan Etkin wrote:
>
> would a 'json:reference mytable' field type similar to 'list:reference 
>> mytable' or perhaps a format=lambda row: row.json() be possible? 
>>
>
> What would be the enhancement required specifically?
>
> Do you need to PUT/POST json data into a DAL database with a service?
>
> If you need to return the table structure, you can do something like:
>
> table = dict()
> for f in db.:
> if isinstance(f.requires, list):
> requires = [type(r) for r in f.requires]
> else:
> requires = [type(f.requires),]
> table[f.name] = {"default": f.default, "type": f.type, "requires":requires
> }
>
> If you return the table object in the controller, the generic json handler 
> should serialize it automatically. Something similar could be implemented 
> for validation of forms
>
>

-- 





[web2py] Re: 'DAL' object has no attribute 'auth_wiki' - trunk version

2013-01-20 Thread Bill Thayer
Yes. working now. Thanks.



On Friday, January 18, 2013 9:28:27 AM UTC-6, Alan Etkin wrote:
>
> Working on trying out the json support but db won't get past this error.
>
>
> Fixed in trunk. Please check it works for you (it did for me) 
>

-- 





Re: [web2py] json validation

2013-01-19 Thread Bill Thayer
wow I'd never have thought of that - Thanks!

Valid JSON




On Saturday, January 19, 2013 6:37:08 PM UTC-6, Jonathan Lundell wrote:
>
> On 19 Jan 2013, at 4:21 PM, Bill Thayer > 
> wrote:
>
> My app stores EDA information (cad programs for designing microchips) so 
> storing cell attributes in a json object and taking advantage of json rpc 
> would be beneficial. I am trying out Alex's new 'json' data type and with 
> the serializer and IS_JSON() validator. Using the controller function below 
> I've manage to create a json object of cell parameters (aka, attributes). 
> In the function's comments is the output from the function but this output 
> fails validation in http://jsonlint.com/ saying that 
> RESULTS:
>
> Parse error on line 1:
> myobj={"L": [ 
> ^
> Expecting '{', '['
>
>
>
> It looks like you're feeding jsonlint a string of the form "myobj={some 
> json object}" instead of "{some json object}". It's looking for a JSON 
> object, which must begin with { or [, and it's finding 'm'.
>
> CONTROLLER FUNCTION: (the myobj value is copied from my cell's edit page 
> after being inserted into my Oracle DB.
> def json_parameters(param_names):
> """takes an array of parameter names which are attributes to a design 
> cell
> then looks up the default value and unit in the attributes table 
> and returns an array of json dictionary objects to be inserted in the 
> cell's
> parameters field as a json object
> if param_names = ["L", "len", "R", "INST", "model", "REF"]
> myobj={
> "L": [
> "0.001",
> "nH"
> ],
> "len": [
> "1",
> "??m"
> ],
> "R": [
> "0.5",
> "Ohm"
> ],
> "INST": [
> "i",
> "TEXT"
> ],
> "model": [
> "m",
> "TEXT"
> ],
> "REF": [
> "r",
> "TEXT"
> ]
> }
> """
> 
> params={}
> for a in param_names:
>  #   dbg.set_trace()
> rows = db(db.attribute.name.lower()==a.lower()).select(
> db.attribute.name,
>   
> db.attribute.default_value,
>   
> db.attribute.unit)
> row = rows[0]
> param = ('{}'.format(row.default_value),
>  '{}'.format(row.unit))
> params.update({'{}'.format(row.name):param})
>
> return json(params)
>
> Any idea which is correct or how to fix it?
>
> Thank you,
> Bill
>
> -- 
>  
>  
>  
>
>
>
>

-- 





[web2py] Re: PowerFormWizard 0.1.4 - Bug Fixes and auto_validation (+ a new plugin for grids)

2013-01-19 Thread Bill Thayer
Hi Bruno,

Forgive me if I missed your updates. The link below does not work today. 
Where can I find the latest information.

Regards,
Bill

>
>> *# Whats next?
>> *working on a new plugin for the 'Power' family, it is a JSON based 
>> tableless grid (which is much more than a grid)
>> hope to release with examples, by the end of the week, preview -> 
>> http://labs.blouweb.com/PowerGrid
>>
>> Need help, contribution, test..
>> []'s
>> --
>> Bruno Rocha
>> [ About me: http://zerp.ly/rochacbruno ]
>
>
>  

-- 





[web2py] Re: Exposing validators as JSON?

2013-01-19 Thread Bill Thayer
+1

would a 'json:reference mytable' field type similar to 'list:reference 
mytable' or perhaps a format=lambda row: row.json() be possible? 

-Bill



On Tuesday, January 15, 2013 6:14:40 PM UTC-6, Derek wrote:
>
> That would be cool, perhaps you could add a class to the fields and key 
> off the classes. Or, have the validation function append error messages to 
> a list and return that as json?
>
> On Tuesday, January 15, 2013 10:03:06 AM UTC-7, Alec Taylor wrote:
>>
>> How do I expose validators as JSON? 
>>
>> I am not using web2py views in any capacity. Instead I am using 
>> AngularJS. 
>>
>> So with web2py I am exposing my models RESTfully as JSON, and then 
>> consuming them with AngularJS. 
>>
>> To reduce double-typing, how do I send field validators such as 
>> `IS_EMAIL` as JSON? 
>>
>> # Model 
>> db.define_table( 
>> 'foo', 
>> Field('email', requires=IS_EMAIL()) 
>> ) 
>>
>> # Controller 
>> @service.json 
>> def foo_form(): 
>> return dict(my_foo_form=crud.create(db.foo)) 
>>
>> # Output I want 
>> { 'my_foo_form': { 'type': 'form', 'fields' { 'email', 
>> 'validator:IS_EMAIL'}, 'csrf':  } } 
>>
>>  
>>
>> With this I can then write the equivalent functions in JavaScript and 
>> attach them to their corresponding fields. 
>>
>> How do I do this with web2py? 
>>
>> Thanks for all suggestions, 
>>
>> Alec Taylor 
>>
>

-- 





[web2py] json validation

2013-01-19 Thread Bill Thayer
My app stores EDA information (cad programs for designing microchips) so 
storing cell attributes in a json object and taking advantage of json rpc 
would be beneficial. I am trying out Alex's new 'json' data type and with 
the serializer and IS_JSON() validator. Using the controller function below 
I've manage to create a json object of cell parameters (aka, attributes). 
In the function's comments is the output from the function but this output 
fails validation in http://jsonlint.com/ saying that 
RESULTS:

Parse error on line 1:
myobj={"L": [ 
^
Expecting '{', '['


CONTROLLER FUNCTION: (the myobj value is copied from my cell's edit page 
after being inserted into my Oracle DB.
def json_parameters(param_names):
"""takes an array of parameter names which are attributes to a design 
cell
then looks up the default value and unit in the attributes table 
and returns an array of json dictionary objects to be inserted in the 
cell's
parameters field as a json object
if param_names = ["L", "len", "R", "INST", "model", "REF"]
myobj={
"L": [
"0.001",
"nH"
],
"len": [
"1",
"??m"
],
"R": [
"0.5",
"Ohm"
],
"INST": [
"i",
"TEXT"
],
"model": [
"m",
"TEXT"
],
"REF": [
"r",
"TEXT"
]
}
"""

params={}
for a in param_names:
 #   dbg.set_trace()
rows = 
db(db.attribute.name.lower()==a.lower()).select(db.attribute.name,
  
db.attribute.default_value,
  
db.attribute.unit)
row = rows[0]
param = ('{}'.format(row.default_value),
 '{}'.format(row.unit))
params.update({'{}'.format(row.name):param})
   
return json(params)

Any idea which is correct or how to fix it?

Thank you,
Bill

-- 





[web2py] 'DAL' object has no attribute 'auth_wiki' - trunk version

2013-01-17 Thread Bill Thayer
Working on trying out the json support but db won't get past this error.

Traceback (most recent call last):
  File "C:\web2py_src_2.2.1\web2py\gluon\restricted.py", line 212, in restricted
exec ccode in environment
  File "C:/web2py_src_2.2.1/web2py/applications/TAMOTO/models/db.py" 
, line 73, in 

auth.wiki(resolve=False)
  File "C:\web2py_src_2.2.1\web2py\gluon\tools.py", line 3330, in wiki
templates=templates)
  File "C:\web2py_src_2.2.1\web2py\gluon\tools.py", line 4766, in __init__
templates = db.auth_wiki.tags.contains('template')&\
  File "C:\web2py_src_2.2.1\web2py\gluon\dal.py", line 7256, in __getattr__
return ogetattr(self, key)
AttributeError: 'DAL' object has no attribute 'auth_wiki'


-- 





[web2py] aµzing...

2013-01-17 Thread Bill Thayer
Been searching a while now for the magic decoder ring that solves the UTF-8 
encoding issue.

If I enter a mu (µ) by typing alt+0181 into my form field it looks fine. 
Then looking at the data in SQLDeveloper (Oracle) the data is 2 little 
boxes. NP I think the client encoding is wrong so I set my preferences to 
UTF-8 but µ is still 2 boxes. Still not worried yet but then I refresh  or 
re-edit the field with the µ in it then it is returned from the database as 
two question marks. Same behavior occurs with the squared (²) sign...two 
boxes in db, two question marks in returned value on page.

Anyone solve this yet?

Thank you,
Bill

-- 





[web2py] Re: Solution for ORA-00932: inconsistent datatypes: expected - got CLOB

2013-01-02 Thread Bill Thayer

Another case:

format=lambda row: '{} {}'.format(row.thickness, row.material)
will throws the Oracle Error.


format='%(thickness)s %(material)s',
will not throw the error


-- 





[web2py] Re: Memory error with numpy large array

2012-12-12 Thread Bill Thayer


On Wednesday, December 12, 2012 12:15:12 PM UTC-6, Bill Thayer wrote:
>
> I am having the same issue  trying to serve large cad files.
>
> 1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.

Traceback (most recent call last):
  File "C:\web2py_src_2.2.1\web2py\gluon\restricted.py", line 212, in restricted
exec ccode in environment
  File "C:/web2py_src_2.2.1/web2py/applications/TAMOTO/controllers/core.py" 
<http://127.0.0.1:8000/admin/default/edit/TAMOTO/controllers/core.py>, line 
133, in 
  File "C:\web2py_src_2.2.1\web2py\gluon\globals.py", line 188, in 
self._caller = lambda f: f()
  File "C:\web2py_src_2.2.1\web2py\gluon\tools.py", line 2911, in f
return action(*a, **b)
  File "C:/web2py_src_2.2.1/web2py/applications/TAMOTO/controllers/core.py" 
<http://127.0.0.1:8000/admin/default/edit/TAMOTO/controllers/core.py>, line 39, 
in layout_wiki
return auth.wiki(resolve='layout')
  File "C:\web2py_src_2.2.1\web2py\gluon\tools.py", line 3299, in wiki
return self._wiki.read(slug)['content'] if slug else self._wiki()
  File "C:\web2py_src_2.2.1\web2py\gluon\tools.py", line 4814, in __call__
return self.editmedia(request.args(1) or 'index')
  File "C:\web2py_src_2.2.1\web2py\gluon\tools.py", line 4965, in editmedia
user_signature=False)
  File "C:\web2py_src_2.2.1\web2py\gluon\sqlhtml.py", line 1858, in grid
**sqlformargs)
  File "C:\web2py_src_2.2.1\web2py\gluon\sqlhtml.py", line 1037, in __init__
inp = represent(field, default, record)
  File "C:\web2py_src_2.2.1\web2py\gluon\sqlhtml.py", line 60, in represent
return f(value, record)
  File "C:/web2py_src_2.2.1/web2py/applications/TAMOTO/models/db.py" 
<http://127.0.0.1:8000/admin/default/edit/TAMOTO/models/db.py>, line 56, in 

A('get it', _href=URL('download', args=value))),
  File "C:\web2py_src_2.2.1\web2py\gluon\html.py", line 367, in URL
args, other, scheme, host, port)
  File "C:\web2py_src_2.2.1\web2py\gluon\rewrite.py", line 196, in url_out
url = regex_filter_out(url, environ)
  File "C:\web2py_src_2.2.1\web2py\gluon\rewrite.py", line 688, in 
regex_filter_out
log_rewrite('routes_out: [%s] not rewritten' % url)
MemoryError

 

> -Bill
>
> On Tuesday, May 17, 2011 3:02:50 AM UTC-5, Kostas M wrote:
>>
>> I tried the same application in a Linux (Ubuntu) machine, after the 
>> installation of the latest numpy version (1.6.0). 
>>
>> No MemoryError ticket occured in web2py... 
>>
>>

-- 





[web2py] Re: Memory error with numpy large array

2012-12-12 Thread Bill Thayer
I am having the same issue  trying to serve large cad files.

-Bill

On Tuesday, May 17, 2011 3:02:50 AM UTC-5, Kostas M wrote:
>
> I tried the same application in a Linux (Ubuntu) machine, after the 
> installation of the latest numpy version (1.6.0). 
>
> No MemoryError ticket occured in web2py... 
>
>

-- 





[web2py] Re: Lazy table bug in define table?

2012-12-06 Thread Bill Thayer
Would using an integer field or a list:reference help out?

-- 





[web2py] Re: is there a way to not use crud.archive

2012-12-05 Thread Bill Thayer
Perhaps check your controllers to see if an update call is being made. 
Seems I had an app created with the wizard that added update code to the 
controllers.

On Wednesday, December 5, 2012 2:18:46 PM UTC-6, pumplerod wrote:
>
> I went through the admin interface and deleted from there.  Then I went 
> into my models/*.py files and made sure no _Archive tables were being 
> created.
> When I go back through the admin interface I no longer see the _Auth 
> tables.
>
> On Wednesday, December 5, 2012 11:59:03 AM UTC-8, Niphlod wrote:
>>
>> seems that web2py is trying to create those tables: how exactly did you 
>> "delete" them ?
>>
>> On Wednesday, December 5, 2012 8:18:57 PM UTC+1, pumplerod wrote:
>>>
>>> I thought by deleting the _archive tables I would no longer be using 
>>> it.  However now when I try and submit a change to the db I get this error:
>>>   
>>> table myTable_archive already exists
>>>
>>>
>>> I'm just trying to learn this system and I don't feel I really need to 
>>> archive things just yet.  getting rid of those tables just made things a 
>>> lot cleaner for me but now I seem stuck.
>>>
>>>
>>>

-- 





[web2py] Re: How to know if you're getting a Set when you're expecting a dict?

2012-11-13 Thread Bill Thayer
Looks like I worked most of the bugs out of this. Hope it saves someone a 
lot of time. If you know of a more *obvious or elegant* solution please 
post it. Also, my slug field is returning a tuple now. Still works as a 
slug but I wish I didn't have the |slug|None| format.




def insert_wiki_if_not_exists(table, s, f):
"""Used for auto creation of wiki pages for use with items already
   in your table. On any update to the table set the wiki pages will be 
create if it
   doesn't exist.
   To use:
   In model file after table definition enter lines:
   db.extracted_linear.wiki_page.required=False
   db.mytable._before_update.append(lambda s,f: \
insert_wiki_if_not_exist(db.mytable, s, 
f))
   @see_also gluon.dal.RecordUpdater,
   @see_also 
http://web2py.com/books/default/chapter/29/06?search=_before_update
"""
tablename=table._tablename
table_wikis_set=db(db.wiki_page.tablename==tablename)
for s_row in s.select():
for row in table_wikis_set.select():
id = s_row.id
name = s_row.name or tablename + ' ' + id
f['wiki_page']=db.wiki_page.update_or_insert(
db.wiki_page.title==name,
title=name,
slug=table_slug(name.strip()),
body='#ADD PLUGIN CODE TO DISPLAY GRAPHS HERE\n' + \
 '##Use WIKI menu to edit or delete this page',
changelog='inserted after ' + tablename + ' table 
update',
tags=None,
tablename=tablename,
record_id=id)
s.update_naive()
return 


-- 





[web2py] Re: How many error tickets does a typical newbie handle?

2012-11-13 Thread Bill Thayer
Do I then need to use an iterator for my update function?

This is related to my other post where I am getting key errors 
https://groups.google.com/d/msg/web2py/3dgZiuDAZDc/DZnJYgaifjIJ

-- 





[web2py] Re: How to know if you're getting a Set when you're expecting a dict?

2012-11-12 Thread Bill Thayer
After finding some code in a class called RecordUpdater in gluon/dal.py i 
think I figured out how to get past my arguments as a set or a 
dictwellI was getting a keyerr for 'name' so I put it in a 
try-catch but now I'm getting a keyerror for 'id'
In the code below I've only been working on the _after_update.

Wonder why 'name' and 'id' throw the error but 'tablename' does not?

#This is after my table definition inside my model file
db.extracted_linear._after_insert.append(
lambda f, id:wiki_update_or_insert(
tablename='extracted_linear',
id=id,
name=f['name'] or f['measuremnt']))
db.extracted_linear._after_update.append(
lambda s, id:wiki_update_or_insert(
tablename='extracted_linear',
id=id,
colset=s(db.extracted_linear.id==id)))

#Here is function in the controller
def wiki_update_or_insert(**fields):
newfields = fields or dict(colset)
try:
title=newfields['name'] or newfields['tablename'] + ' ' + 
newfields['id']['id']
except:
title=newfields['tablename'] + ' ' + newfields['id']['id']
db.wiki_page.update_or_insert(
title=title,
slug=table_slug(title),
body=MARKMIN('#ADD CODE TO DISPLAY GRAPHS HERE'),
tablename=newfields['tablename'],
record_id=newfields['id']['id'])




Traceback (most recent call last):
  File "C:\web2py_src_2.2.1\web2py\gluon\restricted.py", line 212, in restricted
exec ccode in environment
  File "C:/web2py_src_2.2.1/web2py/applications/PROD/controllers/default.py" 
, line 
173, in 
  File "C:\web2py_src_2.2.1\web2py\gluon\globals.py", line 188, in 
self._caller = lambda f: f()
  File "C:\web2py_src_2.2.1\web2py\gluon\tools.py", line 2911, in f
return action(*a, **b)
  File "C:/web2py_src_2.2.1/web2py/applications/PROD/controllers/default.py" 
, line 
67, in linear_manage
form = SQLFORM.smartgrid(db.extracted_linear)
  File "C:\web2py_src_2.2.1\web2py\gluon\sqlhtml.py", line 2376, in smartgrid
user_signature=user_signature, **kwargs)
  File "C:\web2py_src_2.2.1\web2py\gluon\sqlhtml.py", line 1882, in grid
next=referrer)
  File "C:\web2py_src_2.2.1\web2py\gluon\html.py", line 2170, in process
self.validate(**kwargs)
  File "C:\web2py_src_2.2.1\web2py\gluon\html.py", line 2109, in validate
if self.accepts(**kwargs):
  File "C:\web2py_src_2.2.1\web2py\gluon\sqlhtml.py", line 1473, in accepts
self.id_field_name]).update(**fields)
  File "C:\web2py_src_2.2.1\web2py\gluon\dal.py", line 8814, in update
ret and [f(self,update_fields) for f in table._after_update]
  File "C:/web2py_src_2.2.1/web2py/applications/PROD/models/db_wizard.py" 
, line 118, 
in 
colset=s(db.extracted_linear.id==id)))
  File "C:/web2py_src_2.2.1/web2py/applications/PROD/controllers/default.py" 
, line 
44, in wiki_update_or_insert
title=newfields['tablename'] + ' ' + newfields['id']['id']
KeyError: 'id'



-- 





[web2py] Re: Salting tables with legacy data, when to turn on record versioning?

2012-11-12 Thread Bill Thayer
Did you get your answer?

-- 





[web2py] Re: How many error tickets does a typical newbie handle?

2012-11-12 Thread Bill Thayer
No the app never really got to 100%. Even when I try to simplify it farther 
and takes a different approach there is always a 'roadblock' of errors or 
related errors. I get about 90% (I feel) finished and can't get to the last 
10% without some round of errors that never gets 100% solved so I chalk it 
up to poor programing and study harder & simplify the design more. Spending 
so much time on the book and in the code is helpful but if there was a way 
to collect what the newbies are experiencing then some valuable index of 
errors or more focused documentation can be created. 


For exmample:
Today I'm trying to use ._after_insert_append(lambda f,id:... expecting f 
to be a dict however the book actually has two lambda functions (for after 
update & after insert) with the same signature but get passed different 
values.

So my frustration comes from not being able to find the correct way to 
access the Set object on the _after_update. Why cant they both just get 
dicts?

>>> db.define_table('person',Field('name'))
>>> def pprint(*args): print args
>>> db.person._before_insert.append(lambda f: pprint(f))
>>> db.person._after_insert.append(lambda f,id: pprint(f,id))
>>> db.person._before_update.append(lambda s,f: pprint(s,f))
>>> db.person._after_update.append(lambda s,f: pprint(s,f))
>>> db.person._before_delete.append(lambda s: pprint(s))
>>> db.person._after_delete.append(lambda s: pprint(s))



-- 





[web2py] How to know if you're getting a Set when you're expecting a dict?

2012-11-12 Thread Bill Thayer
 'Set' object has no attribute '__getitem__' 

db.person._after_insert.append(lambda f,id: pprint(f,id)) #book's example

#my code in model file after table definition code.
db.extracted_linear._after_insert.append(
lambda f, id:wiki_update_or_insert(
'extracted_linear',
f["name"],
table_slug(f["name"]),
id))

> The 
> booksays 
> Here f is a dict of fields passed to insert or update, id is the id of 
> the newly inserted record, s is the Set object used for update or delete.

-- 





Re: [web2py] deploying web2py apache wsgi

2012-11-11 Thread Bill Thayer
I had a couple of posts on this topic and omi chib has a blog at 
http://ochiba77.blogspot.com/2011/10/how-to-setup-web2py-apache-wsgi.html Wish 
I had more time for a better response but search for my topics and you 
should find some good info on setting up apache.

-- 





[web2py] Hope someone knows the answer to this one {was:....web2py math?}

2012-11-07 Thread Bill Thayer


So the same code above is now throwing an error and when I even visit 
http://127.0.0.1:8000/PROD/default/index. I know I don't feel right using 
request variable in my model file so I changed

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.

Traceback (most recent call last):
  File "C:\web2py_src_2.2.1\web2py\gluon\restricted.py", line 212, in restricted
exec ccode in environment
  File "C:/web2py_src_2.2.1/web2py/applications/PROD/models/db_wizard.py" 
, line 105, 
in 
db.loadpull.points.requires=loadpull_points_in_range(request.vars.pstop, 
request.vars.pstart)
  File "C:/web2py_src_2.2.1/web2py/applications/PROD/models/db_wizard.py" 
, line 59, 
in loadpull_points_in_range
(int(Decimal(pstop)-Decimal(pstart))*1),
  File "C:\Python27\lib\decimal.py", line 658, in __new__
raise TypeError("Cannot convert %r to Decimal" % value)
TypeError: Cannot convert None to Decimal


I don't feel right about using the request variable anyway so I changed 
this line:


db.loadpull.points.requires=lambda row: loadpull_points_in_range(row.pstop, 
row.pstart)

And get  'str' object has no attribute 
'pstop'

File "C:\web2py_src_2.2.1\web2py\gluon\html.py", line 1743, in _validate
(value, errors) = validator(value)
  File "C:/web2py_src_2.2.1/web2py/applications/PROD/models/db_wizard.py" 
, line 105, 
in 
db.loadpull.points.requires=lambda row: loadpull_points_in_range(row.pstop, 
row.pstart)
AttributeError: 'str' object has no attribute 'pstop'



db.loadpull.points.requires=lambda row: loadpull_points_in_range(
'%(row.pstop)s', '%(row.pstart)')
Is not right either 
 Invalid literal for Decimal: 
'%(row.pstop)s'

I really don't know what happened when my original code worked (math error 
aside) when request.vars but now it won't even run.

I have been reading up on lambda functions too since I went through another 
round of not having the correct number of arguments.



-- 





[web2py] Re: Here is one of my 81 tickets today....web2py math?

2012-11-07 Thread Bill Thayer
LOL Thanks,

On my re-design my previous table had

requires=lambda v,r:
IS_INTEGER_IN_RANGE(0, int((r.pstop-r.pstart)*1)), 

but that no longer works so I changed it and applied typecasting when I 
forgot forgot my order of ops.

Thanks a bunch.

-- 





[web2py] Re: join in DAL

2012-11-07 Thread Bill Thayer
I noticed that you do not add auth.signature to your table definition. Does 
it not work for you?

If is_my_chart was somthing I needed often like I'd be tempted to change:   
(full discloser: my track record is not good lately)
db.define_table('chart',
Field('chartName'),
Field('id_workbook',db.workbook),
Field('worksheet'),
Field('file','upload'),
auth.signature,
common_filter = lambda query: db.chart.created_by==auth.user_id,
format="%(id_workbook)s %(chartName)s",
)

Then when I needed a different controller function that returned all 
records I could:

db(query, ignore_common_filters=True).select(...) # copied from 
http://www.web2py.com/books/default/chapter/29/06?search=common_filter



Again I'm not that good at this but it seems logical.

-Bill

-- 





[web2py] Re: How many error tickets does a typical newbie handle?

2012-11-06 Thread Bill Thayer


> Didn't have ANY problems with this line of work in 2 years of deployment.
>
>
So your post does help with migration errors but...

I have 81 tickets today mostly related to lambda taking [1|2]  arguments 
but only [0|1] given. This leads to all sorts of variations leading to 
errors because sometimes '%(something)s' works and other times you just 
need r.something  or simply lambda val: function(val).

Much of my errors today were dealing with validators, looks like lambda 
functions and validators I had last week are not working now. Just when I 
figured my data tables were ready I have to go through each one line by 
line and rewrite validators & lambda functions (and requires= and default= 
etc) I've already removed most of my referenced fields.

Hope you guys plan on having a web2py boot camp very soon. There have been 
probably 74 or more posts made in this Google group in the last week so I 
can't think that I'm alone. I've read most of the code, all of the book and 
epidocs and most of the posts here and on stackoverflow. I bought the 
application developement cookbook, tried the slices. Kept my versions up to 
date etc...

Still, I am probably going to get fired & divorced for this project being 
so late after all the hours I put on it.

-Bill
 

-- 





[web2py] Here is one of my 81 tickets today....web2py math?

2012-11-06 Thread Bill Thayer
I'm no genius but (6-5)*1 should be 1 and 5 is between 0 and 10,000 
I think

Pstart:GHzPstop:GHzPoints:
enter an integer between 0 and -49995
GHz
from decimal import *
def loadpull_points_in_range(pstop, pstart):
return IS_INT_IN_RANGE(0,
int(Decimal(pstop)-Decimal(pstart)*1))

db.define_table('loadpull',
  .
  .
  .
Field('pstart', 'decimal(6,4)',
requires=IS_DECIMAL_IN_RANGE(0, 300), 
comment='GHz'),
Field('pstop', 'decimal(6,3)',
requires=IS_DECIMAL_IN_RANGE(0, 300), 
comment='GHz'),
Field('points', 'integer',
comment='GHz'),
auth.signature,
format='%(name)s',
migrate=settings.migrate)
db.loadpull.points.requires=loadpull_points_in_range(request.vars.pstop, 
request.vars.pstart)



-- 





[web2py] Re: auth.wiki() run Function

2012-11-06 Thread Bill Thayer
I don't think that functions in the controller are callable with a 
parameter from the web page like form objects are but I could be wrong...
without double checking my code I believe you can call controllers like 
this:
@{controller/function/args}

I found that on the markmin cheatsheet.

if you are not using markmin it might be 
{{=MARKMIN(@{controller/function/args)}} however that is just a wild guess.

(Maybe I shiould just keep to myself if I don't know exxactly but perhaps 
your pointed in a good direction.)

Regards,
Bill


On Tuesday, November 6, 2012 6:51:16 AM UTC-6, Simon Carr wrote:
>
> Is there a way to run a Controller or Model Function in a wiki page 
> created with auth.wiki()
>
> I am thinking some like 
> {{ =insertImage(5) }}
>
> as you would have in a view.
>
> Thanks
> Simon
>

-- 





Re: [web2py] SQLFORM.grid exports the whole table

2012-11-06 Thread Bill Thayer
FWIW, My users will be filtering test station settings to upload the csv to 
thier test bench software. My users will need only thier own filtered data 
in the CSVso big Me Too! here

-- 





Re: [web2py] Re: Looking for a way to combine auto-complete with adding a non-existing item.

2012-11-06 Thread Bill Thayer
Gave it a try...no luck.

-- 





[web2py] Re: How to add a column?

2012-11-05 Thread Bill Thayer
Very Interesting. Thank you!

-- 





[web2py] Re: How many error tickets does a typical newbie handle?

2012-11-05 Thread Bill Thayer
Niphold,

Really appreciate your taking the time to spell this procedure out. It will 
come in handy for me and others too I bet! 

Thanks,
Bill

-- 





Re: [web2py] Re: Looking for a way to combine auto-complete with adding a non-existing item.

2012-11-05 Thread Bill Thayer
Hi Richard,

In short...for myself and future searches...This widget works in a straight 
up crud form but with SQLFORM it has different behavior. Whether or not it 
is the source of appadmin not storing values is yet to be determined.

After my columns were successfully added, values were set to null 
automatically of course. When I tried using appadmin to change the values 
(note this has nothing to do with the widget except the widget happens to 
be rendered on the edit or create page) the values do not update. Not 
saying it's the widget, I just don't know.

Regards,
Bill


-- 





Re: [web2py] Re: Looking for a way to combine auto-complete with adding a non-existing item.

2012-11-05 Thread Bill Thayer
This widget wouldn't break appadmin? would it? These are the many unknown 
things that really frustrate me about web2py.

I edited the models file to test my current troubles adding columns to 
tables that are already created. With your sample app, I was able to add 
the new table and then add columns to cats. However when i edited the cat 
to add a color or collar those new values were not saved.


db.define_table('collars',
Field('material', requires=IS_IN_SET(['leather', 'chain'])),
Field('size', requires=IS_IN_SET(['small', 'med', 
'large'])),
format='%(size)s %(material)s')

db.define_table('cat',
Field('name','string'),
Field('color', 'string'),
Field('collar', 'reference collars'),
Field('person_id', 'reference person', 
widget=AutocompleteWidgetSelectOrAddOption(request, 
db.person.first_name, 
id_field=db.person.id, 
limitby=(0,10), 
min_length=2, 
form_title=T('Add new person'), 
controller="default", 
function="add_person", 
button_text = T('Add new'))
),
format='%()s'
)

Regards,
Bill

-- 





Re: [web2py] Re: Looking for a way to combine auto-complete with adding a non-existing item.

2012-11-05 Thread Bill Thayer
Now that is impressive. I did get it to work but not with SQLFORM or 
SQLFORM.smartgrid so that was a large part of my problem. 

When renderred in the view created by SQLGRID (clicking the ADD+ button) I 
would get the SQLFORM and the person fields were displayed with it's own 
submit button. This looked like it could be a bonus however the Add New 
link did not work (doesn't really need to if the form is already rendered) 
and information was not saved to the database. Confirmed this by visiting 
the grid again. I could see all of the users you added before.

Looks like I'll drop use of SQLFORM in favor of this widget.Thank you for 
the sample app. It made a big difference.

Regards,
Bill




-- 





[web2py] How to add a column?

2012-11-05 Thread Bill Thayer
Can't beleive this question does not come up in the search box. How do i 
add a column to a table using SQLlite? Simply adding hte field to the 
define table statement throws an error.

Using SQLlite I cannot add a Field. I get an error message:


OperationalError: no such column: source_via.substrate


No Joke Really? 


When I set migrate_enabled=True then the message changes to something like "the 
table sourc_via does not exist"


Of course it does since I just added the column that I'm being told does not 
exist either to it.


On top of all that I am back to the Rocket server locking up. It likes to do 
that so I have to use Task manager to close it. Could be that session.connect 
+SQLlite is not a good combinnation.

-- 





[web2py] How many error tickets does a typical newbie handle?

2012-11-05 Thread Bill Thayer
The other day I read on web2py developers a discussion detailing Massimo's 
vision of web3py. Perhaps us newbies can start collecting our tickets to 
aide Massimo and the developers in understanding what is particularly 
difficult or perhaps could use better documentation. Currently I have *480 
tickets since 10/8* on my application before I decide to re-do it from 
scratch for the 4th (hopefully last) time. Tickets would provide a wealth 
of statistics about what us newbies are going through.

This time I decided to break my app up into 4 smaller applications. Start 
over and my 2nd try this morning (after deleting and starting over) I 
currently have 19 tickets in 45 minutes. When developing using SQLite I am 
now getting the same errors that I had early on in my development  

Adding columns is not trivial especial with all the combinations of: 
migrate_enabled={True|False}, fake_migrate={True|False}, 
migrate='web2py_session_APPNAME', migrate.settings={True|False}, 
migrate={'table_name'|True|False|migrate.settings}. My approach was to use 
the wizard to quickly whip out the app then add extra fields later so that 
i can develop in small iterations. If just the tickets for what I am going 
through this morning could be eliminated that would be huge!

FWIW,
Bill

-- 





Re: [web2py] Re: Looking for a way to combine auto-complete with adding a non-existing item.

2012-11-05 Thread Bill Thayer
Thank youRichard. I've have exhausted everything I could think of to get it 
to work.

-- 





Re: [web2py] Re: Looking for a way to combine auto-complete with adding a non-existing item.

2012-11-04 Thread Bill Thayer
I still haven't gotten this to work but do need this functionality 
desperatley. Anyone else have any luck?

-- 





[web2py] Solution for ORA-00932: inconsistent datatypes: expected - got CLOB

2012-10-31 Thread Bill Thayer
This is a tricky error to figure out so I am documenting it here
 ORA-00932: inconsistent datatypes: 
expected - got CLOB

To get this error I had at the bottom of a table definition...
...
auth.signature,
format=IS_UPPER()('%(slug)s'),
migrate=settings.migrate)
Trying to make the slug display as uppercase.
Should just be:

auth.signature,
format='%(slug)s',
migrate=settings.migrate)
Note: This is an *Oracle error*, the web2py book says the IS_UPPER() 
function never returns an error. Also note the funky syntax for 
IS_UPPER()(argument) is the same as IS_SLUG()(argument)

-- 





[web2py] Re: Oracle: long text inserting

2012-10-30 Thread Bill Thayer
I guess in SergyPo's example db has changed since then because I cannot get 
a db._connection object and 


cursor = db._adapter.cursor
cursor.setinputsizes(value = cx_Oracle.CLOB) 

produces another error.

I would like to perhaps put these lines after db=DAL(...

Is there a way to get to the cursor object?

-Bill

-- 





[web2py] Re: Oracle: long text inserting

2012-10-30 Thread Bill Thayer
Hi Massimo,

Came along this group post while searching heare and dal.py to see if the 
fix for  ORA-01704: string literal too long

I am not finding it in a searc of gluon and subdirectories produces no 
results for the above fix. Is there a status update? I am getting that 
error now.

Thanks,
Bill


It's not the length of your statement, it's the length (as the error 
> message says) of your literal.
> Oracle does not support character literals with more than 8000 characters. 
> You need to use e.g. a prepared statement (with bind variables) in your 
> programming language.-
> http://www.dbforums.com/oracle/1636111-ora-01704-string-literal-too-long.html



-- 





[web2py] Re: Implementing a self-modifying form in web2py

2012-10-28 Thread Bill Thayer
Without testing it out it sounds like you are describing the default 
behavior from the list: Fields. I think there is a multiple = True 
argument perhaps. Check out 
http://web2py.com/books/default/chapter/29/06?search=list%3A#Many-to-many,-list:,-and-contains
 about 
2/3 down the page if it soesn't scroll automatically for you.

-- 





[web2py] Re: Looking for a way to combine auto-complete with adding a non-existing item.

2012-10-27 Thread Bill Thayer
If this works it will be very usefull

Is there a way to modify myfunction so that it can be passed to onvalidate 
or oncreate fields of SQLFORM.grid?

This is as close as I got but stiil get form validation error (value not in 
database) on the referenced field: add_wiki() is my myfunction()
def add_wiki():
table=db[request.args(0)]
form=SQLFORM(table)
if request.post_vars._autocomplete_name_aux and not request.post_vars.
wiki_page_id:
request.post_vars.wiki_page_id=db.wiki_page.insert(slug=IS_SLUG()(
request.post_vars._autocomplete_name_aux))
return form.process()

def manage():
table=db[request.args(0)]
table.id.readable = table.id.writable = False
left=None
oncreate=None
if table.wiki_page_id:
left=db.wiki_page.on(db.wiki_page.id==table.wiki_page_id)
oncreate=add_wiki()

content=SQLFORM.grid(
table,left=left,
details=False,editable=True,deletable=False,create=True,
oncreate=oncreate,
args=request.args,
user_signature=False)

return dict(content=content)

Thank you. The SELECT_OR_ADD_OPTION never did work for me plus this will be 
a more user friendly option!

Regards,
Bill

-- 





[web2py] Re: Where does auth.wiki save pages to?

2012-10-24 Thread Bill Thayer
Something like that sounds like you just write a controller to query the 
db.wiki_page then use the example view from the book. Don't know of a 
stratight db call but I will need the same function soon myself.

This view might work with the right controller:


{{if len(articles):}}
  Articles
  {{for article in articles:}}
{{=article.title}}

{{if article.image:}}


{{pass}}
{{=article.author}} wrote {{=article.body}}
  {{pass}}
{{else:}}
  No articles posted yet
{{pass}}
Post an article
{{=form}}

-- 





Re: [web2py] Re: All app redirected to https

2012-10-23 Thread Bill Thayer
2.2.1 stable seems to be going through http for me on Chrome.

-- 





[web2py] Re: Wiki Body CLOB ORA-01704: string literal too long?

2012-10-23 Thread Bill Thayer
Hi Massimo,

Sorry I didn't get back right away. After playing around...well re-entering 
the entire menu one line at a time...I discovered that if I took out the 
capitol letters in the slugs then it worked.

Regards,
Bill

-- 





[web2py] Re: Where does auth.wiki save pages to?

2012-10-21 Thread Bill Thayer
Ok,

Actually i am just getting there myself on my application. There is a 
cloud() function and a search() function inside gluon.tools so chances are 
writing a pre-defined search might get you 3/4 the way there. Wish I had a 
better strategy to give to you.

Regards,
Bill

On Sunday, October 21, 2012 4:48:49 PM UTC-5, HittingSmoke wrote:
>
> No no. I mean listing wiki articles for users to browse, like a CMS front 
> page.
>
> For example, I might want my front page to list articles with previews for 
> certain tags. For that I need to know what db table the wiki info is saved 
> to. It's not displayed by default in the appadmin database management.
>
> On Sunday, October 21, 2012 2:43:14 PM UTC-7, Bill Thayer wrote:
>>
>> When you say listing pages created by auth.wiki I take that to mean a 
>> listing to display within the web browser. On mine I do have my index() 
>> controller return auth.wiki and as long as I am logged into my application 
>> I see an option under the [wiki] menu that says "manage pages".
>>
>>
>>
>> On Friday, October 19, 2012 11:47:55 PM UTC-5, HittingSmoke wrote:
>>>
>>> I can't find them in my database...
>>>
>>> I'm trying to build a basic blog using auth.wiki but without 
>>> documentation and without database references I have no way of listing 
>>> pages created with auth.wiki.
>>>
>>

-- 





[web2py] Re: Where does auth.wiki save pages to?

2012-10-21 Thread Bill Thayer
When you say listing pages created by auth.wiki I take that to mean a 
listing to display within the web browser. On mine I do have my index() 
controller return auth.wiki and as long as I am logged into my application 
I see an option under the [wiki] menu that says "manage pages".



On Friday, October 19, 2012 11:47:55 PM UTC-5, HittingSmoke wrote:
>
> I can't find them in my database...
>
> I'm trying to build a basic blog using auth.wiki but without documentation 
> and without database references I have no way of listing pages created with 
> auth.wiki.
>

-- 





[web2py] Re: auth.wiki() '_create' doesn't redirect properly

2012-10-18 Thread Bill Thayer
Back on the original topic. When I click on a menu item I also get 
re-directed back to the _create page. Is this a permission thing perhaps? 
Now that I mention it, isn't there supposed to be a field to select the 
permission level for the page?

-- 





[web2py] Re: auth.wiki() '_create' doesn't redirect properly

2012-10-18 Thread Bill Thayer
This is in my db.py. Allen told me to add the second line after calling 
auth.define_tables



auth.define_tables(username=True, signature=False, migrate=True,fake_migrate
=True)
auth.wiki(resolve=False)
 the second line calls the wiki() function to create the tables.

Regards,
Bill

-- 





[web2py] Wiki Body CLOB ORA-01704: string literal too long?

2012-10-18 Thread Bill Thayer

Using the auth.wiki I am defining my menu. When I hit submit I get the 
error below. The menu I wrote in is currently long I guess but it couldn't 
be more than 4000 bytes (oracle CLOB length) could it? Perhaps it's the 
HTML that gets stored in the DB?...That's what I suspected then I 
remembered that in WIKI_MEDIA I added a blob field to store files on the 
database and the 3 jpg images all larger that 4kb loaded with no problem.



Traceback (most recent call last):
 File "C:\web2py_src_2.1.1\web2py\gluon\restricted.py", line 209, inrestricted
 exec ccode in environment
 File 
"C:/web2py_src_2.1.1/web2py/applications/TAMOTO/controllers/default.py"
, line 283, in 
 File "C:\web2py_src_2.1.1\web2py\gluon\globals.py", line 187, in 
 self._caller = lambda f: f()
 File 
"C:/web2py_src_2.1.1/web2py/applications/TAMOTO/controllers/default.py"
, line 22, in index
 return auth.wiki()
 File "C:\web2py_src_2.1.1\web2py\gluon\tools.py", line 3227, in wiki
 return self._wiki.read(slug)['content'] if slug else self._wiki()
 File "C:\web2py_src_2.1.1\web2py\gluon\tools.py", line 4697, in __call__
 return self.edit(request.args(1) or 'index')
 File "C:\web2py_src_2.1.1\web2py\gluon\tools.py", line 4791, in edit
 formstyle='table2cols',showid=False).process()
 File "C:\web2py_src_2.1.1\web2py\gluon\html.py", line 2135, in process
 self.validate(**kwargs)
 File "C:\web2py_src_2.1.1\web2py\gluon\html.py", line 2075, in validate
 if self.accepts(**kwargs):
 File "C:\web2py_src_2.1.1\web2py\gluon\sqlhtml.py", line 1439, in accepts
 self.table._db(self.table._id == self.record[self.id_field_name]).update(**
fields)
 File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 8814, in update
 ret = db._adapter.update(tablename,self.query,fields)
 File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 1371, in update
 self.execute(sql)
 File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 2856, in execute
 return self.log_execute(command, args)
 File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 1687, in log_execute
 ret = self.cursor.execute(*a, **b)
DatabaseError: ORA-01704: string literal too long




This article explains how to define a LOB field 
http://www.dba-oracle.com/t_table_blob_lob_storage.htm in SQL. The SQL I am 
reading in SQL developer from tables created by web2py is different but 
should work. Then I got to messing with my menu markmin and discovered if I 
remove the @ from two of my menu items then it submits fine.

- Request > @request
- - Measurement > @order-measurment
- - Model > @model
- Product > @Product
- - Measurements > Measurements
- - - S-Parameters > @S-Parameters
- - - DC-IV > DC-IV
- - - Load Pull > @Load-Pull
- - Models > @Models
.
.
.



https://groups.google.com/d/msg/web2py/f66R-f3QvDo/gZR40A87SJ4J - 
Discussion from September 09 where Massimo posted a fix to sql.py (a file 
only used for backward compatibility) but I'm not convinced it's a CLOB 
problem.

-Bill

-- 





[web2py] Re: How to access the auth tables in appadmin?

2012-10-18 Thread Bill Thayer
Sounds like those auth_ tables are not defined. If you already have those 
lines in your db.py then the tables should be listed in your apadmin. If so 
then you just follow the instructions in my other post. 
https://groups.google.com/d/msg/web2py/AEBFWeS8YSA/2LWC4NqdaiAJ to get the 
permissions set correctly.




On Thursday, October 18, 2012 11:21:39 AM UTC-5, mikech wrote:
>
> Thanks Bill.
> What I'm trying to find out is how do I access the tables involved with 
> security.  Do I need to create views, or is there already some associated 
> with the appadmin?
>
> On Wednesday, October 17, 2012 7:55:02 PM UTC-7, Bill Thayer wrote:
>>
>> Try this:
>> In db.py:
>> from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
>> auth = Auth(db)
>> crud, service, plugins = Crud(db), Service(), PluginManager()
>>
>> auth.define_tables(username=True) # arg makes it so you can use a 
>> username instead of email to login
>>
>>
>>
>> On Wednesday, October 17, 2012 6:20:48 PM UTC-5, mikech wrote:
>>>
>>> I'm working thru the book again, and when I get to the image tutorial it 
>>> mentions adding a manager group to the auth tables in appadmin: 
>>>
>>> "Using appadmin create a group "manager" and make some users members of 
>>> the group. They will not be able to access"  
>>>
>>> I cannot find where this is, when I bring up the appadmin it just shows 
>>> the two tables of the application - image and comment.
>>>
>>

-- 





[web2py] Re: auth.wiki usage - Another Oracle DB Gotcha

2012-10-18 Thread Bill Thayer

Oh. 

So that's why a reference field should not be named the same as the table 
it's referencing. In this case I didn't make the name but generally I do 
that all the time. Didn't realize that it makes error messages clearer. Duh.

-Bill

-- 





Re: [web2py] [FYI] Pyodel is now a plugin

2012-10-18 Thread Bill Thayer
Just tried it again. Logged in with my email and password then it took me 
to a blank page with one line on top that says to sign in with google 
password.

On Thursday, October 18, 2012 8:23:58 AM UTC-5, Alan Etkin wrote:
>
> >El martes, 16 de octubre de 2012 18:12:46 UTC-3, Bill Thayer escribió:Hi 
> Alan. 
> > I went through the registration process, got the Google sign in. Signed 
> in with google too and then did not get re-directed back.
>
> AFAIK, there's no need to authenticate with a Google account to use the 
> demo. Are you able to authenticate with the registered Auth user?
>
>

-- 





[web2py] Re: How to access the auth tables in appadmin?

2012-10-17 Thread Bill Thayer
Try this:
In db.py:
from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
auth = Auth(db)
crud, service, plugins = Crud(db), Service(), PluginManager()

auth.define_tables(username=True) # arg makes it so you can use a username 
instead of email to login



On Wednesday, October 17, 2012 6:20:48 PM UTC-5, mikech wrote:
>
> I'm working thru the book again, and when I get to the image tutorial it 
> mentions adding a manager group to the auth tables in appadmin: 
>
> "Using appadmin create a group "manager" and make some users members of 
> the group. They will not be able to access"  
>
> I cannot find where this is, when I bring up the appadmin it just shows 
> the two tables of the application - image and comment.
>

-- 





[web2py] Re: Auth Wiki functionality?

2012-10-17 Thread Bill Thayer
Cool! Thanks. I did not understand what ,load was for.

This morning I'm thinking that I'll have to add a "See Also" field of type 
'list:reference wiki_page' to the wiki_page table to handle my many to many 
relationships. Plus also add a wiki_page_id filed to my parts tables.

Thanks for the advice!

-Bill

On Tuesday, October 16, 2012 9:17:25 PM UTC-5, Massimo Di Pierro wrote:
>
> Try:
>
> @{component:default/part_manage.load}
>
> Or customize the part_manage.html to not {{extend 'layout.html'}}
>
> On Tuesday, 16 October 2012 19:20:35 UTC-5, Bill Thayer wrote:
>>
>> Hello everyone,
>>
>> Thanks to Allen, Villas, of course Massimo among a few others I have 
>> web2py auth.wiki with Oracle storing the media blobs and all the pages.  I 
>> believe I can use the wiki features in a structure way to improv 
>> productivity and cross department functionality in my workplace.
>>
>> Now what in the heck to do with it?
>>
>> The app wizard created a bunch of controllers like
>> @auth.requires_login()
>> def part_manage():
>> form = SQLFORM.smartgrid(db.part)
>> return locals()
>>
>>
>>
>> but if I add
>> @{component:default/part_manage}
>> to my markmin I get a page with my SQLFORM.smartgrid inside a page so I 
>> get two footers and two headers. Not to mention the add and edit pages 
>> should really be a wiki page with my table attributes added.
>>
>> Looks like auth-wiki is for creating web pages but what caught my 
>> attention was the media and tagging capability built in so I don't have to 
>> write my own app to do what's already there. However, I have a bunch of 
>> tables (parts, sub parts, orders, samples, testing, analyses for tested 
>> samples, etc...) defined for my application and  basically 75% of the items 
>> have attachments, images, files, user references and tags too. 
>>
>> Unless someone says different I guess I should be adding a wiki_page 
>> column to all of my tables? Then create separate edit/show/create 
>> controllers that generate the proper..."slug"...and return a wiki page? 
>> That shouldn't break my relationships I don't think.
>>
>> Just kind of wondering if there's already a know technique for my 
>> application that you know of?
>>
>> Regards,
>> Bill
>>
>

-- 





[web2py] Re: Problem with adding Grids in book

2012-10-16 Thread Bill Thayer
Hello Mike,

I'm not an expert but i think you need to go to 
http://127.0.0.1:8000/myapp/appadmin/index then click on the auth user 
table and add a user, 
then go to the groups table table and create a manager
then go to the membership table and make your new user a manager
then go to the permissions table and make 3 entries: permission = Create & 
group=manager; permission = read & group=manager; permission = update & 
group=manager,

This is a quick answer on my way out the door 

hope it helped.

-Bill


On Tuesday, October 16, 2012 6:33:19 PM UTC-5, mikech wrote:
>
> The section Adding Grids refers to using appadmin to create a group 
> manager, but I can't find anything in appadmin that allows that.
> Could someone give me a clue.  It seems that something is missing here.
>

-- 





[web2py] Auth Wiki functionality?

2012-10-16 Thread Bill Thayer
Hello everyone,

Thanks to Allen, Villas, of course Massimo among a few others I have web2py 
auth.wiki with Oracle storing the media blobs and all the pages.  I believe 
I can use the wiki features in a structure way to improv productivity and 
cross department functionality in my workplace.

Now what in the heck to do with it?

The app wizard created a bunch of controllers like
@auth.requires_login()
def part_manage():
form = SQLFORM.smartgrid(db.part)
return locals()



but if I add
@{component:default/part_manage}
to my markmin I get a page with my SQLFORM.smartgrid inside a page so I get 
two footers and two headers. Not to mention the add and edit pages should 
really be a wiki page with my table attributes added.

Looks like auth-wiki is for creating web pages but what caught my attention 
was the media and tagging capability built in so I don't have to write my 
own app to do what's already there. However, I have a bunch of tables 
(parts, sub parts, orders, samples, testing, analyses for tested samples, 
etc...) defined for my application and  basically 75% of the items have 
attachments, images, files, user references and tags too. 

Unless someone says different I guess I should be adding a wiki_page column 
to all of my tables? Then create separate edit/show/create controllers that 
generate the proper..."slug"...and return a wiki page? That shouldn't break 
my relationships I don't think.

Just kind of wondering if there's already a know technique for my 
application that you know of?

Regards,
Bill

-- 





[web2py] What are these odd menu dots from the auth.wiki menu?

2012-10-16 Thread Bill Thayer




-- 





Re: [web2py] [FYI] Pyodel is now a plugin

2012-10-16 Thread Bill Thayer
Hi Alan. 

I went through the registration process, got the Google sign in. Signed in 
with google too and then did not get re-directed back.

-Bill

On Wednesday, September 12, 2012 11:49:47 AM UTC-5, Alan Etkin wrote:
>
> El miércoles, 12 de septiembre de 2012 12:19:02 UTC-3, Tito Garrido 
> escribió:
>>
>> Hey Alan,
>>
>> I was about to test it but it requested access to my google account, is 
>> it expected?
>>
>>
> The Google account login activates if you register with an active google 
> user session. For now you can avoid the extra authentication by closing 
> your google user session before registration. Anyway, clicking the "... 
> google account" gives you normal access to the app too.
>  
>

-- 





[web2py] Re: auth.wiki usage - Another Oracle DB Gotcha

2012-10-16 Thread Bill Thayer
About 6 days ago I posted my "saga" of failed attempts to get plugin_wiki 
to work with oracle and to add the blob field. You told me to put return 
auth.wiki() in my controller and use the built in auth wiki but I needed a 
bit more information and Oracle was still complaining.

Alan told me to add auth.wiki(resolve=False) to my db.py file. Which 
eventually worked. But by that time the tables were created.

Looks like it's working as expected, even storing and retrieving the data 
with a blob field. So far so good except when I click on the search link 
for the wiki (/default/index/_search) I did get this error that I haven't 
yet dug into very deeply but here it is:

Traceback (most recent call last):
 File "C:\web2py_src_2.1.1\web2py\gluon\restricted.py", line 209, inrestricted
 exec ccode in environment
 File 
"C:/web2py_src_2.1.1/web2py/applications/TAMOTO/controllers/default.py"<http://127.0.0.1:8000/admin/default/edit/TAMOTO/controllers/default.py>
, line 240, in 
 File "C:\web2py_src_2.1.1\web2py\gluon\globals.py", line 187, in 
 self._caller = lambda f: f()
 File 
"C:/web2py_src_2.1.1/web2py/applications/TAMOTO/controllers/default.py"<http://127.0.0.1:8000/admin/default/edit/TAMOTO/controllers/default.py>
, line 20, in index
 return auth.wiki()
 File "C:\web2py_src_2.1.1\web2py\gluon\tools.py", line 3227, in wiki
 return self._wiki.read(slug)['content'] if slug else self._wiki()
 File "C:\web2py_src_2.1.1\web2py\gluon\tools.py", line 4705, in __call__
 return self.search()
 File "C:\web2py_src_2.1.1\web2py\gluon\tools.py", line 4990, in search
 content.append(self.cloud()['content'])
 File "C:\web2py_src_2.1.1\web2py\gluon\tools.py", line 5001, in cloud
 orderby = ~count, limitby=(0,20))
 File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 8790, in select
 return adapter.select(self.query,fields,attributes)
 File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 1615, in select
 return self._select_aux(sql,fields,attributes)
 File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 1580, in _select_aux
 self.execute(sql)
 File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 2856, in execute
 return self.log_execute(command, args)
 File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 1687, in log_execute
 ret = self.cursor.execute(*a, **b)
DatabaseError: ORA-00904: "WIKI_TAG"."WIKI_PAGE": invalid identifier







On Tuesday, October 16, 2012 12:20:30 PM UTC-5, Massimo Di Pierro wrote:
>
> On Tuesday, 16 October 2012 11:23:29 UTC-5, Bill Thayer wrote:
>
>> Note for future searchers & people as foolish as I am to try and use 
>> Oracle for web site backend.
>> 
>> I did not have this issue with tables created by web2py.
>>
>
> so why did you create the wiki tables manually? I am missing something.
>

-- 





[web2py] Re: auth.wiki usage - Another Oracle DB Gotcha

2012-10-16 Thread Bill Thayer
Note for future searchers & people as foolish as I am to try and use Oracle 
for web site backend.

This happened to me after I finally got the auth.wiki installed in my 
application and the application connected to Oracle. I had to manually 
create the wiki_page, wiki_media, and wiki_tab tables in SQLDEveloper and 
not web2py. My first attempt at creating a wiki page produced this error:
Traceback (most recent call last):
  File "C:\web2py_src_2.1.1\web2py\gluon\restricted.py", line 209, inrestricted
exec ccode in environment
  File 
"C:/web2py_src_2.1.1/web2py/applications/TAMOTO/controllers/default.py",line 
240, in 
  File "C:\web2py_src_2.1.1\web2py\gluon\globals.py", line 187, in 
self._caller = lambda f: f()
  File 
"C:/web2py_src_2.1.1/web2py/applications/TAMOTO/controllers/default.py",line 
20, in index
return auth.wiki()
  File "C:\web2py_src_2.1.1\web2py\gluon\tools.py", line 3227, in wiki
return self._wiki.read(slug)['content'] if slug else self._wiki()
  File "C:\web2py_src_2.1.1\web2py\gluon\tools.py", line 4697, in __call__
return self.edit(request.args(1) or 'index')
  File "C:\web2py_src_2.1.1\web2py\gluon\tools.py", line 4791, in edit
formstyle='table2cols',showid=False).process()
  File "C:\web2py_src_2.1.1\web2py\gluon\html.py", line 2135, in process
self.validate(**kwargs)
  File "C:\web2py_src_2.1.1\web2py\gluon\html.py", line 2075, in validate
if self.accepts(**kwargs):
  File "C:\web2py_src_2.1.1\web2py\gluon\sqlhtml.py", line 1441, in accepts
self.vars.id = self.table.insert(**fields)
  File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 7808, in insert
ret =  self._db._adapter.insert(self,self._listify(fields))
  File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 1160, in insert
raise e
DatabaseError: ORA-04098: trigger 'UWAVEDAT.WIKI_PAGE_TRIGGER' is invalid 
and failed re-validation


This was caused because although I created the trigger, the trigger did not 
have the sequence. Oracle does not have authoincrement so you need to 
create a sequence.


   CREATE SEQUENCE  "SCHEMANAME"."WIKI_PAGE_SEQUENCE"  MINVALUE 1 MAXVALUE 
 INCREMENT BY 1 START WITH 2001 CACHE 2000ORDER  
NOCYCLE 
;



Then create your trigger:


CREATE OR REPLACE TRIGGER "SCHEMANAME"."WIKI_PAGE_TRIGGER" BEFORE
  INSERT ON wiki_page FOR EACH ROW BEGIN
  SELECT wiki_page_sequence.nextval INTO :NEW.id FROM DUAL;
END;
/
ALTER TRIGGER "SCHEMANAME"."WIKI_PAGE_TRIGGER" ENABLE;





I did not have this issue with tables created by web2py.

Regards,
Bill

-- 





[web2py] Re: auth.wiki usage

2012-10-15 Thread Bill Thayer
After checking SQL developer and discovering the Triggers were not made for 
web2py_storage_tamoto table I recalled this post:
https://groups.google.com/d/msg/web2py/r7qMRK2Eir0/D91Ine9NMzkJ
from earlier today. That error occured at line 2865 in dal.py so the 
triggers never got created.

So using SQL Developer I created the trigger. Edited my connecction string 
to connect to Oracle and.

...SUCCESS!!!

The session was added to the database table.

No on to the wiki stuff I hope.

-- 





[web2py] Re: web2py memory leak

2012-10-15 Thread Bill Thayer
Generally I pay attention to the physical memory in the task manager. I 
generally use about 3.5 to 4.5 GB but if I leave the rocket server on for a 
very long time it will grow to 5.5 GB and give me problems. If I forget and 
leave it on all night I will have to hard boot my PC.

The basic behavior is that I will be working for a while then a page will 
take too long to load. I will stop the browser from loading the page and 
shut down the server. it turns white and fails to respond.

I just happened to be debugging my other isuue with a basic application and 
the problem got much worse with session.connect enabled. I shouldn't have 
any cron jobs running since I am using this mornings release of 2.1.1 and 
you said cron was disabled by default.

I do have logging enabled but I'm not getting an extraordinary amount of 
logged messages.

Regards,
Bill

On Monday, October 15, 2012 3:55:05 PM UTC-5, Massimo Di Pierro wrote:
>
> It would help if we could isolate the problem. How are you measuring it? 
> make sure you are not running cron jobs in background (with <2.1 cron was 
> always enabled) moreover web2py's memory usage may grows for the first 100 
> requests than some stuff is garbage collected and it stabilizes.
>
> massimo
>
> On Monday, 15 October 2012 15:39:30 UTC-5, Bill Thayer wrote:
>>
>> That's all I have right now. Haven't tried it with SQLLite.
>>
>>
>>
>> On Monday, October 15, 2012 3:35:25 PM UTC-5, Massimo Di Pierro wrote:
>>>
>>> I this only work Oracle?
>>>
>>> On Monday, 15 October 2012 14:56:44 UTC-5, Bill Thayer wrote:
>>>>
>>>>
>>>> Perhaps someone can check session.connect with Oracle for a rocket 
>>>> server memory leak?
>>>> To reproduce on windows 7 using web2py 2.1.1 from source:
>>>> 1) Create a new simple application called simpleapp where simpleapp is 
>>>> the name of an application with an Oracle table for storing sessions
>>>> 2) Create a new 0.py model file & 
>>>> set:settings.database_uri='oracle:username/password@server:1521/servicename'
>>>> 3) in db.py: 
>>>> line 14:
>>>>   
>>>>   db = DAL(settings.database_uri, check_reserved=['oracle'])
>>>>
>>>>
>>>> line 15:  & 16:
>>>> ## store sessions and tickets there
>>>> session.connect(request, response, db=db, migrate=
>>>> 'db.web2py_session_simpleapp')
>>>>
>>>>
>>>>
>>>> line 29:
>>>>
>>>> auth.define_tables(username=True, signature=False, migrate=False)
>>>>
>>>> Takes about an hour or less for rocket server to run out of memory so 
>>>> that it will just just spin and not respond to the stop server button 
>>>> click.
>>>>
>>>>
>>>>

-- 





[web2py] Re: auth.wiki usage

2012-10-15 Thread Bill Thayer
Hi Massimo.

Yes the problem is not with the sqlite. I just confirmed that it does work 
and the session table is in the databases folder.

My Oracle db already has the auth tables and web2py_session table defined. 
I suspect there is a null value for the user field since no one would be 
logged in when the app comes up. Somehow that is OK with SQL lite.

Here are the session variables:
Variables 
 session  
 request }> 
 session._try_store_in_db > 
 response  at 
0x03FE8F30>, 'view': 'default/index.html'}>


As I mentioned earlier. This is a brand new application. No tables other 
than auth_ and web2py_session_ defined here yet.

-Bill

On Monday, October 15, 2012 4:30:17 PM UTC-5, Massimo Di Pierro wrote:
>
> I am using sqlite and I tried sessions in db (again) and I cannot 
> reproduce this problem.
>
> On Monday, 15 October 2012 16:03:45 UTC-5, Bill Thayer wrote:
>>
>> Thought I'd start over with a brand new application & get the wiki 
>> working but I am running into difficulty before I even get to the wiki part.
>> I created a brand new app and started by moving my 0.py file into models 
>> then edited db.py like so:
>>
>>
>> if not request.env.web2py_runtime_gae:
>> ## if NOT running on Google App Engine use SQLite or other DB
>> db = DAL(settings.database_uri, check_reserved=['oracle'])
>> ## store sessions and tickets there
>> session.connect(request, response, db=db, migrate=
>> 'db.web2py_session_tamoto')
>> else:
>> .
>> .
>> .
>>
>>
>> ## create all tables needed by auth if not custom tables
>> auth.define_tables(username=True, signature=False, migrate=False)
>>
>>
>>
>> Of course I get an Oracle Error:
>>
>> Traceback (most recent call last):
>>  File "C:\web2py_src_2.1.1\web2py\gluon\restricted.py", line 209, 
>> inrestricted
>>  exec ccode in environment
>>  File 
>> "C:/web2py_src_2.1.1/web2py/applications/TAMOTO/models/db.py"<http://127.0.0.1:8000/admin/default/edit/TAMOTO/models/db.py>
>> , line 16, in 
>>  session.connect(request, response, db=db, migrate=
>> 'db.web2py_session_tamoto')
>>  File "C:\web2py_src_2.1.1\web2py\gluon\globals.py", line 581, in connect
>>  migrate=table_migrate,
>>  File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 7092, indefine_table
>>  table = self.lazy_define_table(tablename,*fields,**args)
>>  File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 7124, 
>> inlazy_define_table
>>  polymodel=polymodel)
>>  File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 920, increate_table
>>  self.create_sequence_and_triggers(query,table)
>>  File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 2865, 
>> increate_sequence_and_triggers
>>  self.execute(query)
>>  File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 2856, in execute
>>  return self.log_execute(command, args)
>>  File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 1687, inlog_execute
>>  ret = self.cursor.execute(*a, **b)
>> DatabaseError: ORA-00955: name is already used by an existing object
>>
>>
>> Thought I might give writing a patch a try so I tried catching and ignoring 
>> the exception in the OracleAdaptor but it does not work.
>>
>> After setting migrate_enabled to False:
>> db = DAL(settings.database_uri, check_reserved=['oracle'], 
>> migrate_enabled=False) 
>>
>>
>> I get this error:
>> Traceback (most recent call last):
>>  File "C:\web2py_src_2.1.1\web2py\gluon\main.py", line 541, in wsgibase
>>  session._try_store_in_db(request, response)
>>  File "C:\web2py_src_2.1.1\web2py\gluon\globals.py", line 670, in 
>> _try_store_in_db
>>  record_id = table.insert(**dd)
>>  File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 7812, in insert
>>  return ret
>>  File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 1160, in insert
>>  raise e
>> IntegrityError: ORA-01400: cannot insert NULL into 
>> ("UWAVEDAT"."WEB2PY_SESSION_TAMOTO"."ID")
>>
>>
>>
>>

-- 





[web2py] Re: auth.wiki usage

2012-10-15 Thread Bill Thayer
Hi villas,

Yes I agree and did do that. My development is at  point where my tables 
are defined. If I go much farther into development without deploying to the 
test server than it is too difficult to narrow down errors so i want to 
focus on the basic functionality up front. With all of the errors I have I 
really need to nail down the migration in small steps at a time.

To simplify my final design I'd really like to use the built in wiki. I'd 
also like to store my file objects in the database and not in the server. 
So my goal is to add a blob field to the auth.wiki(). So a small 
incremental approach is best for me while I fight through all of the 
challenges.

Thanks,
Bill

On Monday, October 15, 2012 4:21:24 PM UTC-5, villas wrote:
>
> Hi Bill
>
> My experience is that it isn't a good idea to do experimental development 
> on a tricky DB.  It is too easy to bite off more than you can  chew.  
>
> You will save heaps of time by prototyping your app on Sqlite first.  Only 
> when your data schema becomes more stable should you move over to your DB.  
>
> In this way you can more easily differentiate between your own coding 
> errors and any DB adaptor errors etc and this will make it quicker to learn 
> too.
>
> Just 2 cts, D
>

-- 





[web2py] Re: auth.wiki usage

2012-10-15 Thread Bill Thayer
Thought I'd start over with a brand new application & get the wiki working 
but I am running into difficulty before I even get to the wiki part.
I created a brand new app and started by moving my 0.py file into models 
then edited db.py like so:


if not request.env.web2py_runtime_gae:
## if NOT running on Google App Engine use SQLite or other DB
db = DAL(settings.database_uri, check_reserved=['oracle'])
## store sessions and tickets there
session.connect(request, response, db=db, migrate=
'db.web2py_session_tamoto')
else:
.
.
.


## create all tables needed by auth if not custom tables
auth.define_tables(username=True, signature=False, migrate=False)



Of course I get an Oracle Error:

Traceback (most recent call last):
 File "C:\web2py_src_2.1.1\web2py\gluon\restricted.py", line 209, inrestricted
 exec ccode in environment
 File 
"C:/web2py_src_2.1.1/web2py/applications/TAMOTO/models/db.py"
, line 16, in 
 session.connect(request, response, db=db, migrate=
'db.web2py_session_tamoto')
 File "C:\web2py_src_2.1.1\web2py\gluon\globals.py", line 581, in connect
 migrate=table_migrate,
 File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 7092, in define_table
 table = self.lazy_define_table(tablename,*fields,**args)
 File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 7124, inlazy_define_table
 polymodel=polymodel)
 File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 920, in create_table
 self.create_sequence_and_triggers(query,table)
 File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 2865, 
increate_sequence_and_triggers
 self.execute(query)
 File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 2856, in execute
 return self.log_execute(command, args)
 File "C:\web2py_src_2.1.1\web2py\gluon\dal.py", line 1687, in log_execute
 ret = self.cursor.execute(*a, **b)
DatabaseError: ORA-00955: name is already used by an existing object


Thought I might give writing a patch a try so I tried catching and ignoring the 
exception in the OracleAdaptor but it does not work.
  def create_sequence_and_triggers(self, query, table, **args):
from contrib.pg8000.errors import DatabaseError
err = DatabaseError
tablename = table._tablename
sequence_name = table._sequence_name
trigger_name = table._trigger_name
try:
self.execute(query)
self.execute('CREATE SEQUENCE %s START WITH 1 INCREMENT BY 1 
NOMAXVALUE MINVALUE -1;' % sequence_name)
self.execute("""
CREATE OR REPLACE TRIGGER %(trigger_name)s BEFORE INSERT ON 
%(tablename)s FOR EACH ROW
DECLARE
curr_val NUMBER;
diff_val NUMBER;
PRAGMA autonomous_transaction;
BEGIN
IF :NEW.id IS NOT NULL THEN
EXECUTE IMMEDIATE 'SELECT %(sequence_name)s.nextval 
FROM dual' INTO curr_val;
diff_val := :NEW.id - curr_val - 1;
IF diff_val != 0 THEN
  EXECUTE IMMEDIATE 'alter sequence %(sequence_name)s 
increment by '|| diff_val;
  EXECUTE IMMEDIATE 'SELECT %(sequence_name)s.nextval 
FROM dual' INTO curr_val;
  EXECUTE IMMEDIATE 'alter sequence %(sequence_name)s 
increment by 1';
END IF;
END IF;
SELECT %(sequence_name)s.nextval INTO :NEW.id FROM DUAL;
END;
""" % dict(trigger_name=trigger_name, tablename=tablename, 
sequence_name=sequence_name))
except DatabaseError as error:
if 'ORA-00955' in error.value():
pass


-- 





[web2py] Re: web2py memory leak

2012-10-15 Thread Bill Thayer
That's all I have right now. Haven't tried it with SQLLite.



On Monday, October 15, 2012 3:35:25 PM UTC-5, Massimo Di Pierro wrote:
>
> I this only work Oracle?
>
> On Monday, 15 October 2012 14:56:44 UTC-5, Bill Thayer wrote:
>>
>>
>> Perhaps someone can check session.connect with Oracle for a rocket server 
>> memory leak?
>> To reproduce on windows 7 using web2py 2.1.1 from source:
>> 1) Create a new simple application called simpleapp where simpleapp is 
>> the name of an application with an Oracle table for storing sessions
>> 2) Create a new 0.py model file & 
>> set:settings.database_uri='oracle:username/password@server:1521/servicename'
>> 3) in db.py: 
>> line 14:
>>   
>>   db = DAL(settings.database_uri, check_reserved=['oracle'])
>>
>>
>> line 15:  & 16:
>> ## store sessions and tickets there
>> session.connect(request, response, db=db, migrate=
>> 'db.web2py_session_simpleapp')
>>
>>
>>
>> line 29:
>>
>> auth.define_tables(username=True, signature=False, migrate=False)
>>
>> Takes about an hour or less for rocket server to run out of memory so 
>> that it will just just spin and not respond to the stop server button click.
>>
>>
>>

-- 





[web2py] Re: web2py memory leak

2012-10-15 Thread Bill Thayer

Perhaps someone can check session.connect with Oracle for a rocket server 
memory leak?
To reproduce on windows 7 using web2py 2.1.1 from source:
1) Create a new simple application called simpleapp where simpleapp is the 
name of an application with an Oracle table for storing sessions
2) Create a new 0.py model file & 
set:settings.database_uri='oracle:username/password@server:1521/servicename'
3) in db.py: 
line 14:
  
  db = DAL(settings.database_uri, check_reserved=['oracle'])


line 15:  & 16:
## store sessions and tickets there
session.connect(request, response, db=db, migrate=
'db.web2py_session_simpleapp')



line 29:

auth.define_tables(username=True, signature=False, migrate=False)

Takes about an hour or less for rocket server to run out of memory so that 
it will just just spin and not respond to the stop server button click.


-- 





[web2py] Re: auth.wiki usage

2012-10-14 Thread Bill Thayer
the index displays the login page but after logging in returns the login 
page without logging in the user (user is in db)
editing the user from auth_user edit user page returns the edit user page 
without committing the changes.
registering a new user or adding one from auth_user simply returns the same 
page without creating the user.


I thought I would try using the sqllite db like you did. The error said 
that auth user tables were not created so I cleared my session information, 
editited 

auth.define_tables(username=True, migrate=True) #set migrate=True

 and re-started the server...ooopsnot good.

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 209, in restricted
exec ccode in environment
  File "C:/web2py/applications/TAMOTO/models/db.py" 
, line 70, in 

auth.wiki(resolve=False)
  File "C:\web2py\gluon\tools.py", line 3192, in wiki
env=env)
  File "C:\web2py\gluon\tools.py", line 4597, in __init__
args.append(field)
UnboundLocalError: local variable 'args' referenced before assignment







On Sunday, October 14, 2012 6:59:09 PM UTC-5, Alan Etkin wrote:
>
> > Made 2 changes but don't know which one fixed the AtributeError. Hard to 
> tell if the filedata blob field is working because
>
> I doubt it has something to do with the changes in the patch to tools.py. 
> I have created a scaffolding app with the default Sqlite connection that 
> extends the wiki_page table with extra fields, list the wiki tables in 
> appadmin and does auth_user crud without issues.
>
> What is the output if you submit an auth_user create form? Does web2py 
> return any error traceback or anything?

-- 





[web2py] Re: auth.wiki usage

2012-10-14 Thread Bill Thayer
#code now looks like this, put the represent= inside the 
# call to extra_fileds
.
.
.
auth.settings.extra_fields["wiki_media"] = [
Field("filedata", "blob",
   represent = lambda value,row: \
A('get it', _href=URL('download', args=value))),]


auth.define_tables(username=True, migrate=False, fake_migrate=True)
auth.wiki(resolve=False)
db.wiki_media.filename.uploadfield='filedata'
Made 2 changes but don't know which one fixed the AtributeError. Hard to 
tell if the filedata blob field is working because 
i order to test it I need to log in but my ability to log in or create a 
user is still not working.


On Sunday, October 14, 2012 6:07:33 PM UTC-5, Alan Etkin wrote:
>
> > Hmmm. These lines do not work so I'm unsure where to insert them.
>
> I wonder if you shouldn't call .define_tables() before calling 
> auth.wiki(), there could be need of configuring auth tables before creating 
> the wiki tables.
>
>

-- 





[web2py] Re: auth.wiki usage

2012-10-14 Thread Bill Thayer
Hmmm. These lines do not work so I'm unsure where to insert them.


db.wiki_media.filename.uploadfield='filedata'
db.wiki_page.filedata.represent = lambda value,row: \
A('get it', _href=URL('download', args=value))
Here's the error as usual.

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 209, in restricted
exec ccode in environment
  File "C:/web2py/applications/TAMOTO/models/db.py" 
<http://127.0.0.1:8000/admin/default/edit/TAMOTO/models/db.py>, line 68, in 

db.wiki_page.filedata.represent = lambda value,row: \
  File "C:\web2py\gluon\dal.py", line 7626, in __getitem__
return ogetattr(self, str(key))
AttributeError: 'Table' object has no attribute 'filedata'

The code now looks like:
 db = DAL(settings.database_uri, check_reserved=['oracle'], migrate_enabled=
False, fake_migrate_all=True)
session.secure()
session.connect(request, response, db)
.
.
.
from gluon import DAL
from gluon.tools import Auth, Crud, Service, PluginManager, prettydate, Wiki
auth = Auth(db)
crud, service, plugins = Crud(db), Service(), PluginManager()
## create all tables needed by auth if not custom tables
auth.settings.extra_fields['auth_user']= [
  Field('business_unit', length=15),
  Field('default_charge_number', length=15),
  Field('location', length=15),
  Field('phone', length=12)]
auth.settings.extra_fields["wiki_media"] = [Field("filedata", "blob"),]


auth.wiki(resolve=False)
db.wiki_media.filename.uploadfield='filedata'
db.wiki_page.filedata.represent = lambda value,row: \
A('get it', _href=URL('download', args=value))

auth.define_tables(username=True, migrate=False, fake_migrate=True)
.
.
.





On Sunday, October 14, 2012 4:06:09 PM UTC-5, Alan Etkin wrote:
>
> El domingo, 14 de octubre de 2012 15:56:05 UTC-3, Bill Thayer escribió:
>>
>> I tried your patch but the tables were not defined. Is my db.py code 
>> correct? The commented out code causes an error> 'exceptions.AttributeError'>('DAL' object has no attribute 'wiki_media') 
>> but when commented out the appadmin displays all the tables except the 
>> wiki_ tables.
>>
>
> I think this command is missing:
>
> # after  auth.settings.extra_fields ...
> auth.wiki(resolve=False)
>
> Without that line, the tables will not be available within the controller 
> or the model
>

-- 





[web2py] Re: auth.wiki usage

2012-10-14 Thread Bill Thayer
Cool! The wiki_ tables are now visible in the app admin pages! My app does 
not produce errors wrt wiki_.

However, the login page will not login any users, I can not register a new 
user and cannot create or edit users from app admin although the auth_ 
tables are all visible. In fact I just tried to create a record for a 
completely different table and it would not create it. 

I think my db connection is OK since I did fix 2 web2py errors by creating 
2 missing columns in SQL Developer and corrected ora errors 'Table does not 
have attribute 'WIKI_PAGE'.'HTML' & 'WIKI_MEDIA'.'IS_ACTIVE'. Those columns 
were missing when I manually created the Oracle wiki_ tables.

Thank you for your help. My spirits are getting better now. Just need to 
figure out why my auth_tables are accessible.

Regards,
Bill



On Sunday, October 14, 2012 4:06:09 PM UTC-5, Alan Etkin wrote:
>
> El domingo, 14 de octubre de 2012 15:56:05 UTC-3, Bill Thayer escribió:
>>
>> I tried your patch but the tables were not defined. Is my db.py code 
>> correct? The commented out code causes an error> 'exceptions.AttributeError'>('DAL' object has no attribute 'wiki_media') 
>> but when commented out the appadmin displays all the tables except the 
>> wiki_ tables.
>>
>
> I think this command is missing:
>
> # after  auth.settings.extra_fields ...
> auth.wiki(resolve=False)
>
> Without that line, the tables will not be available within the controller 
> or the model
>

-- 





[web2py] Re: auth.wiki usage

2012-10-14 Thread Bill Thayer
I tried your patch but the tables were not defined. Is my db.py code 
correct? The commented out code causes an error('DAL' object has no attribute 'wiki_media') 
but when commented out the appadmin displays all the tables except the 
wiki_ tables.

from gluon import DAL
from gluon.tools import Auth, Crud, Service, PluginManager, prettydate, Wiki
auth = Auth(db)
crud, service, plugins = Crud(db), Service(), PluginManager()
## create all tables needed by auth if not custom tables
auth.settings.extra_fields['auth_user']= [
  Field('business_unit', length=15),
  Field('default_charge_number', length=15),
  Field('location', length=15),
  Field('phone', length=12)]
auth.settings.extra_fields["wiki_page"] = [Field("filedata", "blob"),]
auth.define_tables(username=True, migrate=False)
# 
# db.wiki_media.filename.uploadfield='filedata'
# db.wiki_page.filedata.represent = lambda value,row: \
# A('get it', _href=URL('download', args=value))


-- 





[web2py] Re: auth.wiki usage

2012-10-14 Thread Bill Thayer
Thank you. I voted for it.

On Sunday, October 14, 2012 9:43:03 AM UTC-5, Alan Etkin wrote:
>
> I didn't expect you wanted to add a field to the table after calling .,,
>>
>  
> I opened an issue in the project page
>
> http://code.google.com/p/web2py/issues/detail?id=1087
>
>

-- 





[web2py] Re: Legacy db / references

2012-10-13 Thread Bill Thayer
I'm certainly no expert but I might try to define:
ref_asset_category.format=('%(asset_category_name)s') or something like 
that. 

Check my syntax of course. Hope it works.

-Bill

On Saturday, October 13, 2012 7:11:35 PM UTC-5, Kenneth wrote:
>
> Hello, 
>
> this is my first time trying to connect to a legacy database. My 
> database models file looks like this: 
>
> db.define_table('ref_asset_category', 
>  Field('asset_category_id', type='id'), 
>  Field('asset_category_name', type='string')) 
>
>  
> db.define_table('assets', 
>  Field('asset_id', type='id'), 
>  Field('asset_label', type='string'), 
>  Field('asset_category_id', 'reference ref_asset_category')) 
>
> When using crud to edit a assets record the asset_catefory_id is only 
> shown as an text box, not as an drop down selection box. 
>
> What am I doing wrong? 
>
>
> Kenneth 
>
>

-- 





[web2py] Re: auth.wiki usage

2012-10-13 Thread Bill Thayer
Hello Allen,

my code looks like:
from gluon import DAL
from gluon.tools import Auth, Crud, Service, PluginManager, prettydate, Wiki
auth = Auth(db)
crud, service, plugins = Crud(db), Service(), PluginManager()
## create all tables needed by auth if not custom tables
auth.define_tables(username=True, migrate=False)
auth.wiki(resolve=False)
.
.
.


media=db.wiki_media
media.fields.append(Field('filedata', 'blob'))
media.filedata.represent = lambda value,row: \
A('get it', _href=URL('download', args=value))
db.wiki_media.filename.uploadfield='filedata'
And produces the error:

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 209, in restricted
exec ccode in environment
  File "C:/web2py/applications/TAMOTO/models/db.py" 
<http://127.0.0.1:8000/admin/default/edit/TAMOTO/models/db.py>, line 103, in 

media.filedata.represent = lambda value,row: \
  File "C:\web2py\gluon\dal.py", line 7626, in __getitem__
return ogetattr(self, str(key))
AttributeError: 'Table' object has no attribute 'filedata'

So I think I'm close. Just not aware of how to add that field yet.

-Bill



On Friday, October 12, 2012 5:08:18 PM UTC-5, Alan Etkin wrote:
>
> ¿What error do you get?
>
> To force the wiki class to define the tables before serving the wiki pages 
> (so you can customize them) you must add something like this to the model
>
> auth.wiki(resolve=False)
>
> El viernes, 12 de octubre de 2012 18:47:10 UTC-3, Bill Thayer escribió:
>>
>> I applied the patch to gluon tools (basically just give the 
>> Wiki.__init__(...,render=None,...) a default value of 'markmin' instead of 
>> None to remove the first error. Now I need to add an upload field to 
>> wiki_media but this does not work:
>>
>>
>>
>> media=db.tables(db.wiki_media)
>> media.fields.append(Field('filedata', 'blob'))
>> media.filedata.represent = lambda value,row: \
>> A('get it', _href=URL('download', args=value))
>> db.wiki_media.filename.uploadfield='filedata'
>>
>>
>>
>>
>>
>>
>>
>>
>> On Friday, October 12, 2012 3:48:11 PM UTC-5, Bill Thayer wrote:
>>>
>>> I'm just starting down the same road so I hope you found success or at 
>>> least some resources.
>>>
>>> So far I've had to manually add the tables found in tools.py to Oracle. 
>>>
>>> From here it looks like I might need:
>>>
>>>
>>>
>>> from gluon.tools import Auth, Crud, Service, PluginManager, prettydate, 
>>> Wiki
>>> auth = Auth(db)
>>> crud, service, plugins = Crud(db), Service(), PluginManager()
>>> wiki = Wiki(auth=auth, render='html')
>>> or perhaps I'll put it after
>>>
>>> auth.define_tables(username=True, migrate=False)
>>>
>>> I'll keep you posted.
>>>
>>> -Bill
>>>
>>> On Friday, September 21, 2012 7:44:13 PM UTC-5, guruyaya wrote:
>>>>
>>>> I'm trying to figure out how to use the built in auth.wiki feature. 
>>>> I read the markmin syntax allows expending the syntax using the "extra" 
>>>> tag. Is there a way to implement it in auth.wiki? where should the de of 
>>>> the extra functionality be?
>>>>
>>>> *Is there a guide containing all options for this feature?*
>>>>
>>>> Thanks in advance
>>>> Yair 
>>>>
>>>

-- 





[web2py] Re: Cannot connect to Oracle from web2py? — Just want to use the DAL…

2012-10-13 Thread Bill Thayer
I did not have much luck with 64 bit anything. I think Oracle XE might can 
be 64 bit but I am using cx_Oracle-5.1.2-11g.win32-py2.7 with 32 bit python 
2.7 and web2py 2.0.9.


On Saturday, October 13, 2012 4:58:55 AM UTC-5, Alec Taylor wrote:
>
> Getting this error:
> raise RuntimeError, "no driver available %s", self.drivers TypeError: 
> raise: arg 3 must be a traceback or None 
>
> Even though I've installed the driver 
> (instantclient-basic-windows.x64-11.2.0.3.0.zip from 
> http://www.oracle.com/technetwork/topics/winx64soft-089540.html; + set 
> ORACLE_HOME env_var to dir where it extracted + added it to PATH) and 
> python module (cx_Oracle-5.1.2-11g.win-amd64-py2.7.msi from 
> http://sourceforge.net/projects/cx-oracle/files/5.1.2/).
>
> Basically I just want to use web2py's DAL, so is there a way I can "fake" 
> everything?
>
> Just want to get the SQL Output to plug directly into my DB.
>
> Thanks for all suggestions,
>
> Alec Taylor
>

-- 





[web2py] Re: auth.wiki usage

2012-10-12 Thread Bill Thayer
I applied the patch to gluon tools (basically just give the 
Wiki.__init__(...,render=None,...) a default value of 'markmin' instead of 
None to remove the first error. Now I need to add an upload field to 
wiki_media but this does not work:



media=db.tables(db.wiki_media)
media.fields.append(Field('filedata', 'blob'))
media.filedata.represent = lambda value,row: \
A('get it', _href=URL('download', args=value))
db.wiki_media.filename.uploadfield='filedata'








On Friday, October 12, 2012 3:48:11 PM UTC-5, Bill Thayer wrote:
>
> I'm just starting down the same road so I hope you found success or at 
> least some resources.
>
> So far I've had to manually add the tables found in tools.py to Oracle. 
>
> From here it looks like I might need:
>
>
>
> from gluon.tools import Auth, Crud, Service, PluginManager, prettydate, 
> Wiki
> auth = Auth(db)
> crud, service, plugins = Crud(db), Service(), PluginManager()
> wiki = Wiki(auth=auth, render='html')
> or perhaps I'll put it after
>
> auth.define_tables(username=True, migrate=False)
>
> I'll keep you posted.
>
> -Bill
>
> On Friday, September 21, 2012 7:44:13 PM UTC-5, guruyaya wrote:
>>
>> I'm trying to figure out how to use the built in auth.wiki feature. 
>> I read the markmin syntax allows expending the syntax using the "extra" 
>> tag. Is there a way to implement it in auth.wiki? where should the de of 
>> the extra functionality be?
>>
>> *Is there a guide containing all options for this feature?*
>>
>> Thanks in advance
>> Yair 
>>
>

-- 





[web2py] Re: auth.wiki usage

2012-10-12 Thread Bill Thayer
I'm just starting down the same road so I hope you found success or at 
least some resources.

So far I've had to manually add the tables found in tools.py to Oracle. 

>From here it looks like I might need:



from gluon.tools import Auth, Crud, Service, PluginManager, prettydate, Wiki
auth = Auth(db)
crud, service, plugins = Crud(db), Service(), PluginManager()
wiki = Wiki(auth=auth, render='html')
or perhaps I'll put it after

auth.define_tables(username=True, migrate=False)

I'll keep you posted.

-Bill

On Friday, September 21, 2012 7:44:13 PM UTC-5, guruyaya wrote:
>
> I'm trying to figure out how to use the built in auth.wiki feature. 
> I read the markmin syntax allows expending the syntax using the "extra" 
> tag. Is there a way to implement it in auth.wiki? where should the de of 
> the extra functionality be?
>
> *Is there a guide containing all options for this feature?*
>
> Thanks in advance
> Yair 
>

-- 





[web2py] Re: editing gluon.tools

2012-10-11 Thread Bill Thayer
Thank you!

On Wednesday, October 10, 2012 8:54:16 PM UTC-5, Massimo Di Pierro wrote:
>
> This has already been fixed in trunk and the nightly built. file was 
> replaced by filename. 
>
> On Wednesday, 10 October 2012 19:18:24 UTC-5, Bill Thayer wrote:
>>
>> This question should show my lack of Python knowledge but here goes...
>>
>> In gluon.tools 
>>
>> def Wiki(object):
>> .
>> .
>> .
>> table_definitions = {
>> 'wiki_page':{
>> 'args':[
>> Field('slug',
>>   requires=[IS_SLUG(),
>> IS_NOT_IN_DB(db,'wiki_page.slug')],
>>   readable=False,writable=False),
>> Field('title',unique=True),
>> Field('body','text',notnull=True),
>> Field('tags','list:string'),
>> Field('can_read','list:string',
>>   writable=perms,
>>   readable=perms,
>>   default=[Wiki.everybody]),
>> Field('can_edit', 'list:string',
>>   writable=perms,readable=perms,
>>   default=[Wiki.everybody]),
>> Field('changelog'),
>> Field('html','text',compute=render,
>>   readable=False, writable=False),
>> auth.signature],
>> 'vars':{'format':'%(title)s'}},
>>  'wiki_tag':{
>> 'args':[
>> Field('name'),
>> Field('wiki_page','reference wiki_page'),
>> auth.signature],
>> 'vars':{'format':'%(name)s'}},
>>'wiki_media':{
>> 'args':[
>> Field('wiki_page','reference wiki_page'),
>> Field('title',required=True),
>> Field('file','upload',required=True),
>> auth.signature],
>> 'vars':{'format':'%(title)s'}}
>> }
>>
>>
>> Since file is an Oracle keyword and I'd like to save my file_data in the 
>> database how do I overwrite this Wiki class and still have it work in my 
>> application?
>>
>> Should I just edit gluon.tools? That seems dangerous when it comes time 
>> to upgrade. I also want 
>>
>>  db.wiki_media.file_data.represent = lambda value,row: \ A('get it',_href
>> =URL('download', args=value))
>>
>>
>> but I think I can add that to db.py
>>
>> Perhaps I should copy gluon.tools to my application modules folder and 
>> edit it there?
>>
>> Regards,
>> Bill
>>
>

-- 





[web2py] editing gluon.tools

2012-10-10 Thread Bill Thayer
This question should show my lack of Python knowledge but here goes...

In gluon.tools 

def Wiki(object):
.
.
.
table_definitions = {
'wiki_page':{
'args':[
Field('slug',
  requires=[IS_SLUG(),
IS_NOT_IN_DB(db,'wiki_page.slug')],
  readable=False,writable=False),
Field('title',unique=True),
Field('body','text',notnull=True),
Field('tags','list:string'),
Field('can_read','list:string',
  writable=perms,
  readable=perms,
  default=[Wiki.everybody]),
Field('can_edit', 'list:string',
  writable=perms,readable=perms,
  default=[Wiki.everybody]),
Field('changelog'),
Field('html','text',compute=render,
  readable=False, writable=False),
auth.signature],
'vars':{'format':'%(title)s'}},
 'wiki_tag':{
'args':[
Field('name'),
Field('wiki_page','reference wiki_page'),
auth.signature],
'vars':{'format':'%(name)s'}},
   'wiki_media':{
'args':[
Field('wiki_page','reference wiki_page'),
Field('title',required=True),
Field('file','upload',required=True),
auth.signature],
'vars':{'format':'%(title)s'}}
}


Since file is an Oracle keyword and I'd like to save my file_data in the 
database how do I overwrite this Wiki class and still have it work in my 
application?

Should I just edit gluon.tools? That seems dangerous when it comes time to 
upgrade. I also want 

 db.wiki_media.file_data.represent = lambda value,row: \ A('get it', _href=
URL('download', args=value))


but I think I can add that to db.py

Perhaps I should copy gluon.tools to my application modules folder and edit 
it there?

Regards,
Bill

-- 





[web2py] Re: My saga in parts bevcause Google is broken

2012-10-10 Thread Bill Thayer
Is this the correct controller?

def index():
"""
example action using the internationalization operator T and flash
rendered by views/default/index.html or views/generic.html

if you need a simple wiki simple replace the two lines below with:
return auth.wiki()
"""
response.flash = T("Welcome to web2py!")
return auth.wiki()



On Tuesday, October 9, 2012 9:30:00 PM UTC-5, Massimo Di Pierro wrote:
>
> Bill,
>
> have you tried using web2py wil sqlite only? does that work for you? I do 
> not understand the reason for migrate=false.
>
> On Tuesday, 9 October 2012 17:19:28 UTC-5, Bill Thayer wrote:
>>
>> Fixing broken migrations...
>>>
>>> db.define_table(,migrate=False,fake_migrate=True) means rebuild the 
>>> table meta data according to the table definitions.
>>> db = DAL(...,fake_migrate_all=True) means you are fixing all the tables at 
>>> once but will not help in narrowing down the problem.
>>>
>>> Looks like the metadata matches my table definitions. I have narrowed the 
>>> problem down to wiki page does not exist in the database. Since it doesn't 
>>> exist in 
>>> metadata either then what's the problem? Shouldn't the behavior be to 
>>> create the database table and the table metadata? That is my desire.
>>>
>>> if I delete all of my meta data that usually creates more problems. But in 
>>> theory setting migrate=False, fake_migrate_all=True then all the 
>>> metadata gets rebuilt without touching the database. Not my intention as I 
>>> want the missing tables added.
>>>
>>>
>>> db = DAL('oracle://uname/pw@dbserver:1521', migrate=False, 
>>> fake_migrate_all=True)
>>>
>>> 
>>> auth.define_tables(username=True, signature=False, migrate=False, 
>>> fake_migrate=True)
>>>
>>> Error: 
>>>
>>>  ORA-00942: table or view does not 
>>> exist 
>>>
>>>
>>> and Welcome /database has 6 auth tables and wiki_
>>>
>>> So this should not build metadata but go ahead and build the tables not in 
>>> the database:
>>>
>>> db = DAL('oracle://uname/pw@dbserver:1521', migrate=True)
>>>
>>> auth.define_tables(username=True, signature=False, migrate=True, 
>>> fake_migrate=False)
>>>
>>> Error:
>>>
>>>  ORA-00955: name is already used by an 
>>> existing object 
>>>
>>>
>>> No Kidding! There's no way I'm going to delete my auth_user table from 
>>> Oracle at this point, I have another app using it! 
>>>
>>>
>>> Perhaps this will create the missing tables?
>>>
>>>
>>> db = DAL('oracle://uname/pw@dbserver:1521', migrate=True)
>>>
>>> auth.define_tables(username=True, signature=False, migrate=False, 
>>> fake_migrate=False)
>>>
>>> Now my browser is spinning and spinning. I suspect that the rocket 
>>> server is hung again and I need to stop the process with the task manager. 
>>> I'll give it a few minutes and see.
>>>
>>>
>>>
>>>
>>>
>>>
>>>   

-- 





[web2py] Re: My saga in parts bevcause Google is broken

2012-10-10 Thread Bill Thayer

Hi Massimo,



auth.define_tables(username=True, signature=False, migrate=False, 
fake_migrate=False)

The migrate=false here was an attempt to supress the 
Error:

 ORA-00955: name is already used by an 
existing object 
Changed my connection string to sqllite and did get a wiki page that said 
to create page: index. So I entered - test index creation - in the body and 
got this error:

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 209, in restricted
exec ccode in environment
  File "C:/web2py/applications/welcome/controllers/default.py" 
<http://127.0.0.1:8000/admin/default/edit/welcome/controllers/default.py>, line 
75, in 
  File "C:\web2py\gluon\globals.py", line 186, in 
self._caller = lambda f: f()
  File "C:/web2py/applications/welcome/controllers/default.py" 
<http://127.0.0.1:8000/admin/default/edit/welcome/controllers/default.py>, line 
21, in index
return dict(form=auth.wiki())
  File "C:\web2py\gluon\tools.py", line 3198, in wiki
return self._wiki.read(slug)['content'] if slug else self._wiki()
  File "C:\web2py\gluon\tools.py", line 4647, in __call__
return self.read(zero)
  File "C:\web2py\gluon\tools.py", line 4695, in read
return dict(content=XML(self.fix_hostname(page.html)))
  File "C:\web2py\gluon\tools.py", line 4678, in fix_hostname
return body.replace('://HOSTNAME','://%s' % self.host)
AttributeError: 'NoneType' object has no attribute 'replace'









On Tuesday, October 9, 2012 9:30:00 PM UTC-5, Massimo Di Pierro wrote:
>
> Bill,
>
> have you tried using web2py wil sqlite only? does that work for you? I do 
> not understand the reason for migrate=false.
>
> On Tuesday, 9 October 2012 17:19:28 UTC-5, Bill Thayer wrote:
>>
>> Fixing broken migrations...
>>>
>>> db.define_table(,migrate=False,fake_migrate=True) means rebuild the 
>>> table meta data according to the table definitions.
>>> db = DAL(...,fake_migrate_all=True) means you are fixing all the tables at 
>>> once but will not help in narrowing down the problem.
>>>
>>> Looks like the metadata matches my table definitions. I have narrowed the 
>>> problem down to wiki page does not exist in the database. Since it doesn't 
>>> exist in 
>>> metadata either then what's the problem? Shouldn't the behavior be to 
>>> create the database table and the table metadata? That is my desire.
>>>
>>> if I delete all of my meta data that usually creates more problems. But in 
>>> theory setting migrate=False, fake_migrate_all=True then all the 
>>> metadata gets rebuilt without touching the database. Not my intention as I 
>>> want the missing tables added.
>>>
>>>
>>> db = DAL('oracle://uname/pw@dbserver:1521', migrate=False, 
>>> fake_migrate_all=True)
>>>
>>> 
>>> auth.define_tables(username=True, signature=False, migrate=False, 
>>> fake_migrate=True)
>>>
>>> Error: 
>>>
>>>  ORA-00942: table or view does not 
>>> exist 
>>>
>>>
>>> and Welcome /database has 6 auth tables and wiki_
>>>
>>> So this should not build metadata but go ahead and build the tables not in 
>>> the database:
>>>
>>> db = DAL('oracle://uname/pw@dbserver:1521', migrate=True)
>>>
>>> auth.define_tables(username=True, signature=False, migrate=True, 
>>> fake_migrate=False)
>>>
>>> Error:
>>>
>>>  ORA-00955: name is already used by an 
>>> existing object 
>>>
>>>
>>> No Kidding! There's no way I'm going to delete my auth_user table from 
>>> Oracle at this point, I have another app using it! 
>>>
>>>
>>> Perhaps this will create the missing tables?
>>>
>>>
>>> db = DAL('oracle://uname/pw@dbserver:1521', migrate=True)
>>>
>>> auth.define_tables(username=True, signature=False, migrate=False, 
>>> fake_migrate=False)
>>>
>>> Now my browser is spinning and spinning. I suspect that the rocket 
>>> server is hung again and I need to stop the process with the task manager. 
>>> I'll give it a few minutes and see.
>>>
>>>
>>>
>>>
>>>
>>>
>>>   

-- 





[web2py] Rocket server hanging

2012-10-09 Thread Bill Thayer
Anyone know of obvious causes of the rocket server hanging? I set logging 
to debug and here is the output if it helps.

web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2012
Version 2.0.9 (2012-09-13 23:51:30) stable
Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
MySQL(MySQLdb), Pos
tgreSQL(pg8000), Oracle(cx_Oracle), IMAP(imaplib)
2012-10-09 18:25:19,938 - Rocket.Errors.ThreadPool - DEBUG - Initializing 
Thread
Pool.
please visit:
http://127.0.0.1:8000
starting browser...
2012-10-09 18:25:19,941 - Rocket.Errors.ThreadPool - INFO - Starting Rocket 
1.2.
4
2012-10-09 18:25:19,951 - Rocket.Errors.ThreadPool - DEBUG - Starting 
threads.
2012-10-09 18:25:19,953 - Rocket.Errors.ThreadPool - DEBUG - Growing by 10.
2012-10-09 18:25:19,953 - Rocket.Errors.Thread-4 - DEBUG - Entering main 
loop.
2012-10-09 18:25:19,953 - Rocket.Errors.Thread-5 - DEBUG - Entering main 
loop.
2012-10-09 18:25:19,954 - Rocket.Errors.Thread-6 - DEBUG - Entering main 
loop.
2012-10-09 18:25:19,954 - Rocket.Errors.Thread-7 - DEBUG - Entering main 
loop.
2012-10-09 18:25:19,956 - Rocket.Errors.Thread-8 - DEBUG - Entering main 
loop.
2012-10-09 18:25:19,956 - Rocket.Errors.Thread-9 - DEBUG - Entering main 
loop.
2012-10-09 18:25:19,957 - Rocket.Errors.Thread-10 - DEBUG - Entering main 
loop.
2012-10-09 18:25:19,957 - Rocket.Errors.Thread-11 - DEBUG - Entering main 
loop.
2012-10-09 18:25:19,957 - Rocket.Errors.Thread-12 - DEBUG - Entering main 
loop.
2012-10-09 18:25:19,959 - Rocket.Errors.Thread-13 - DEBUG - Entering main 
loop.
2012-10-09 18:25:19,960 - Rocket.Errors.ThreadPool - INFO - Listening on 
sockets
: 127.0.0.1:8000
2012-10-09 18:25:19,960 - Rocket.Monitor - DEBUG - Entering monitor loop.
2012-10-09 18:25:19,960 - Rocket.Errors.Port8000 - DEBUG - Entering main 
loop.
2012-10-09 18:25:20,371 - Rocket.Errors.Thread-4 - DEBUG - Received a 
connection
.
2012-10-09 18:25:20,371 - Rocket.Errors.Thread-4 - DEBUG - Serving a request
2012-10-09 18:25:20,372 - Rocket.Errors.Thread-4 - DEBUG - Getting sock_file
2012-10-09 18:25:20,437 - Rocket.Errors.Thread-4 - DEBUG - Sending Headers: 
'HTT
P/1.1 303 SEE OTHER\r\nContent-Type: text/html; charset=UTF-8\r\nLocation: 
/welc
ome/default/index\r\nDate: Tue, 09 Oct 2012 23:25:20 GMT\r\nServer: Rocket 
1.2.4
 Python/2.7.3\r\nContent-Length: 66\r\nConnection: keep-alive\r\n\r\n'
2012-10-09 18:25:20,438 - Rocket.Errors.Thread-4 - DEBUG - Finally closing 
outpu
t and sock_file
2012-10-09 18:25:20,440 - Rocket.Requests - INFO - 127.0.0.1 - "GET / 
HTTP/1.1"
- 303 66
2012-10-09 18:25:20,441 - Rocket.Errors.Thread-4 - DEBUG - Serving a request
2012-10-09 18:25:20,441 - Rocket.Errors.Thread-4 - DEBUG - Getting sock_file
2012-10-09 18:25:20,960 - Rocket.Errors.ThreadPool - DEBUG - Examining 
ThreadPoo
l. 10 threads and 0 Q'd conxions
2012-10-09 18:25:21,628 - Rocket.Errors.Thread-4 - DEBUG - Sending Headers: 
'HTT
P/1.1 500 INTERNAL SERVER ERROR\r\nContent-Type: text/html; 
charset=UTF-8\r\nweb
2py_error: ticket 
welcome/127.0.0.1.2012-10-09.18-25-20.562956fb-3074-41e4-abca-
640bf13d9229\r\nDate: Tue, 09 Oct 2012 23:25:21 GMT\r\nServer: Rocket 1.2.4 
Pyth
on/2.7.3\r\nContent-Length: 841\r\nConnection: keep-alive\r\n\r\n'
2012-10-09 18:25:21,630 - Rocket.Errors.Thread-4 - DEBUG - Finally closing 
outpu
t and sock_file
2012-10-09 18:25:21,630 - Rocket.Requests - INFO - 127.0.0.1 - "GET 
/welcome/def
ault/index HTTP/1.1" - 500 841
2012-10-09 18:25:21,631 - Rocket.Errors.Thread-4 - DEBUG - Serving a request
2012-10-09 18:25:21,631 - Rocket.Errors.Thread-4 - DEBUG - Getting sock_file
2012-10-09 18:25:21,961 - Rocket.Errors.ThreadPool - DEBUG - Examining 
ThreadPoo
l. 10 threads and 0 Q'd conxions
2012-10-09 18:25:22,631 - Rocket.Errors.Thread-4 - DEBUG - Finally closing 
outpu
t and sock_file
2012-10-09 18:25:22,631 - Rocket.Errors.Thread-4 - DEBUG - Socket timed out
2012-10-09 18:25:22,961 - Rocket.Errors.ThreadPool - DEBUG - Examining 
ThreadPoo
l. 10 threads and 0 Q'd conxions
2012-10-09 18:25:22,963 - Rocket.Monitor - DEBUG - In "receive timed-out 
connect
ions" loop.
2012-10-09 18:25:22,963 - Rocket.Monitor - DEBUG - Received a timed out 
connecti
on.
2012-10-09 18:25:22,963 - Rocket.Monitor - DEBUG - Adding connection to 
monitor
list.
2012-10-09 18:25:23,963 - Rocket.Errors.ThreadPool - DEBUG - Examining 
ThreadPoo
l. 10 threads and 0 Q'd conxions
2012-10-09 18:25:24,964 - Rocket.Errors.ThreadPool - DEBUG - Examining 
ThreadPoo
l. 10 threads and 0 Q'd conxions
2012-10-09 18:25:25,964 - Rocket.Errors.ThreadPool - DEBUG - Examining 
ThreadPoo
l. 10 threads and 0 Q'd conxions
2012-10-09 18:25:26,964 - Rocket.Errors.ThreadPool - DEBUG - Examining 
ThreadPoo
l. 10 threads and 0 Q'd conxions
2012-10-09 18:25:27,964 - Rocket.Errors.ThreadPool - DEBUG - Examining 
ThreadPoo
l. 10 threads and 0 Q'd conxions
2012-10-09 18:25:28,964 - Rocket.Errors.ThreadPool - DEBUG - Examining 
ThreadPoo
l. 10 threads and 0 Q'd conxions
2012-10-09 18:25:29,964 - Rocket.Errors.ThreadPool

  1   2   >