Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defroute package lookup #112

Open
mfiano opened this issue May 3, 2019 · 3 comments
Open

defroute package lookup #112

mfiano opened this issue May 3, 2019 · 3 comments
Projects

Comments

@mfiano
Copy link

mfiano commented May 3, 2019

Is it possible at all to create an <app> instance in one package, and defroute definitions in another? I'd like to split my project up into multiple packages but caveman2.app::*package-app-map* stores the app object in a different package than what defroute's expansion looks for.

@knobo
Copy link
Contributor

knobo commented May 6, 2019

You could add in your defroute file file something like this:

(define-symbol-macro *web* your-app-package::*your-app-map*)

@fukamachi fukamachi added this to Inbox in Personal Aug 9, 2019
@sheepduke
Copy link

I encountered the same problem when trying to separate my route settings.

I noticed that defroute is calling functions from ningle package, but I would say defroute is doing too much - it should not be locked in the current package. It is not a good design IMHO.

Practically speak, the current implementation is very unfriendly to package-per-file programming style: all routes must be defined in one file. IMHO it would be better if we can specify the <app> instance in defroute declaration.

@iamFIREcracker
Copy link

Run into the same today and thought I would share my solution in case anyone was still looking for a workaround for this.

To make DEFROUTE work you have to register the current package into CAVEMAN2.APP::*PACKAGE-APP-MAP* and make sure it points to the main instance (i.e. *WEB* in my case):

(defun register-routes-package (package)
  (setf (gethash package caveman2.app::*package-app-map*) *web*))

With this, you then need to remember to call (register-routes-package *package*) from each package in which you want to define new routes.

It's ugly, I know, otherwise I would not have called it a workaround ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Personal
  
Inbox
Development

No branches or pull requests

4 participants