Hi,

I've been trying to go through malu's factor-blog-gitutorial[1] and
I'm at commit 3e91728fd6b2021fc11d, where I should be able to at least
show the list of recent posts and create new posts.
Using the following instructions in the listener, I keep running into
a 500 error from Furnace.

USING: blog db db.sqlite http.server namespaces threads ;
<blog> main-responder set-global
[ "blog.db" <sqlite-db> [ 8080 httpd ] with-db ] in-thread

When I look into the http log (logs/http.server/1.log), it showed the
following errors:
[2011-01-06T01:15:32-05:00] ERROR do-request: sqlite-error
[--------------------] ERROR do-request: n      21
[--------------------] ERROR do-request: string "Library used incorrectly"

I sprinkled debug log-messages throughout the code and saw that the
problem occurs when attempting to execute select-tuples within the
page-action init quotation, specifically a problem with the
recent-posts word.
The particular code fragments (with debug log messages removed):

: recent-posts ( num -- posts )
    f <post> >query
        swap >>limit
        "created_at desc" >>order
    select-tuples ;

: <recent-posts-action> ( -- action )
    <page-action>
        [ 5 recent-posts "posts" set-value ] >>init
        { blog "recent-posts" } >>template ;

Executing the recent-posts word from the listener:
( scratchpad ) "blog.db" <sqlite-db> [ 5 recent-posts ] with-db

... returns a proper result (either an empty array, or a result,
depending on whether I entered a post or not previously).

I thought that the problem might be the gitutorial, so I went and
tried to launch webapps.blogs since they seem rather similar.
In the listener, I typed the following:

( scratchpad ) "temp.db" <sqlite-db> [ <blogs> main-responder
set-global 8080 httpd ] with-db

However, this resulted in the same error in the http log. With
additional debug messages in webapps.blogs, I was able to narrow down
the issue in a similar place.
In this case, the problem occurs when the select-tuples is called
within the list-posts word.

Checking basis/db/sqlite/ffi/ffi.factor shows the "CONSTANT:
SQLITE_MISUSE      21 ! Library used incorrectly" line. Since that
seemed like a sqlite3.dll lib throwing an error, I ran "db.sqlite"
test in the listener and all of the unit tests passed.

I'm hoping it's just the way that I'm setting up the environment or
perhaps misusing with-db.
At the limit of my Factor capabilities trying to figure this out.

Further information if required:
- Factor win32-2010-12-27
- sqlite3 version 3.7.4


Thanks,
Dave

------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to