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

use with mito or other db package? #4

Open
mooseyboots opened this issue Jan 18, 2024 · 7 comments
Open

use with mito or other db package? #4

mooseyboots opened this issue Jan 18, 2024 · 7 comments

Comments

@mooseyboots
Copy link

hi, thanks for this package.

i'm using it while playing around with a toy AP server in CL, to learn stuff, and starting to look at storage. i assumed i would use mito, but it requires that classes are of its own metaclass. is it possible to add a metaclass to nactivitypub classes, or is there a better way to go about handling database interactions generally?

@mooseyboots
Copy link
Author

mooseyboots commented Jan 18, 2024

i tried adding (:metaclass mito:dao-table-class) to the definition of the base class, and adding a validate super class method:

(defmethod closer-mop:validate-superclass ((class mito:dao-table-class)
                                           (superclass standard-class))
  t)

I was able to create a base object with the mito superclass, but nothing further, and slime errors on compiling the file (on the object class i think, which comes first). perhaps it needs to be added also to the define-json-type macro?

I'm also not sure if this is the right rabbit hole to wander down.

@mooseyboots
Copy link
Author

i think i got something at least roughly working:
https://codeberg.org/martianh/nactivitypub/commit/e9a96351e87675c2f6de0c09c44642b670109330

@aartaka
Copy link
Contributor

aartaka commented Jan 22, 2024

While we're waiting for maintainers' response: yes, your approach is good—especially so given that metaclass should be added to every class separately.

I'm pretty sure that one can monkey-patch the metaclass into the class via Closer MOP or Moptilities, but I can't reclass which function/macro does that. As an alternative monkey-patching solution that I'm not sure even makes sense is redefining a class with new metaclass in your code instead of altering the library code.

@mooseyboots
Copy link
Author

thanks for your response!

i'm fairly new to CLOS, so happy just to have something hackable working.

i also wondered about new class with the mito metaclass and then some inheriting for here or somesuch, but i didn't get my head around it yet. i can't see (by name at least) any closer-mop function regarding metaclasses. but can check the docs later.

i think i'll have to patch the library anyway to handle instantiating objects not just from incoming JSON data but also from the database/locally.

btw, aren't you the author/maintainer of this cool package?

@aartaka
Copy link
Contributor

aartaka commented Jan 22, 2024

i can't see (by name at least) any closer-mop function regarding metaclasses. but can check the docs later.

Neither can I, so I'm clueless 🙈 But there are many ways to hack the functionality into a CL library, so I believe in you 🖤

btw, aren't you the author/maintainer of this cool package?

I am the author, but I no longer am a maintainer. Refer to Atlas Engineer people for maintenance 😜

@mooseyboots
Copy link
Author

i thought my rough hacks were ok, but alas, as is i can't work with any linked objects and the database (duh). so i'm not at all sure how to make this package play with a database.

it seems like i would either have to reimplement everything in parallel as db friendly (mito) objects (everything separate, no nested objects/lists of objects, then define relationships), or somehow magically add that functionality to nactivitypub.

i managed to implement collection items and init them to a collection's "Items" slot, and same with webfinger with webfinger links in a slot, but that's just baby steps. and it gets confusing implementing the same phenomenon as an AP object and then a separate db one.

do you have any sense about how one might ideally go about it? i don't know this package's code well enough to know if it's realistic to try to do it all in there. no sweat if you have no thoughts at all.

@aartaka
Copy link
Contributor

aartaka commented Jan 29, 2024 via email

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

No branches or pull requests

2 participants